Allow multiple values with units
This commit is contained in:
parent
1f47f718da
commit
95c8e6d031
@ -1,12 +1,12 @@
|
||||
<root>
|
||||
<common>
|
||||
<wl_min val="400" units="nanometer" comment="Shortest wavelength used for binning input spectra"/>
|
||||
<wl_max val="5" units="micron" comment="Shortest wavelength used for binning input spectra"/>
|
||||
<wl_delta val="10" units="nanometer" comment="Wavelength increment used for binning input spectra"/>
|
||||
<!-- <res val="1000" units=""-->
|
||||
<wl_min val="400" val_unit="nm" comment="Shortest wavelength used for binning input spectra"/>
|
||||
<wl_max val="500" val_unit="nm" comment="Shortest wavelength used for binning input spectra"/>
|
||||
<wl_delta val="10" val_unit="nm" comment="Wavelength increment used for binning input spectra"/>
|
||||
<!-- <res val="1000" val_unit=""-->
|
||||
<!-- comment="Resolving power for common spectral binning. A linear binning wavelength integral is estimated as wl_min/R"/>-->
|
||||
<d_aperture val="5" units="m" comment="Diameter of the telescope aperture"/>
|
||||
<jitter_rms val="0.1" units="arcsec" comment="Sigma RMS of the telescope jitter"/>
|
||||
<d_aperture val="5" val_unit="m" comment="Diameter of the telescope aperture"/>
|
||||
<jitter_rms val="0.1" val_unit="arcsec" comment="Sigma RMS of the telescope jitter"/>
|
||||
<output_path val="output" comment="Output directory to store output files"/>
|
||||
</common>
|
||||
|
||||
@ -17,38 +17,38 @@
|
||||
</noise>
|
||||
|
||||
<astroscene>
|
||||
<target type="BlackBodyTarget" val="5778" units="K" mag="10" band="G"
|
||||
<target type="BlackBodyTarget" temp="5778" temp_unit="K" mag="10" band="V"
|
||||
comment="Modeling the sun as mag 10 star"/>
|
||||
<optical_component type="Atmosphere" transmissivity="data/atmosphere/transmittance.csv"
|
||||
<optical_component type="Atmosphere" transmittance="data/atmosphere/transmittance.csv"
|
||||
emission="data/atmosphere/emission.csv" comment="Including the atmosphere"/>
|
||||
<optical_component type="StrayLight" emission="data/strayLight/emission.csv"
|
||||
comment="Including arbitrary noise sources"/>
|
||||
</astroscene>
|
||||
|
||||
<common_optics>
|
||||
<optical_component type="Mirror" reflectivity="data/mirror/reflectivity.csv"
|
||||
emissivity="data/mirror/emissivity.csv" val="70" units="K" comment="M1"/>
|
||||
<optical_component type="Mirror" reflectivity="data/mirror/reflectivity.csv"
|
||||
emissivity="data/mirror/emissivity.csv" val="70" units="K" comment="M2"/>
|
||||
<optical_component type="Mirror" reflectivity="data/mirror/reflectivity.csv"
|
||||
emissivity="data/mirror/emissivity.csv" val="70" units="K" comment="M3"/>
|
||||
<optical_component type="Filter" band="G"
|
||||
emissivity="data/filter/emissivity.csv" val="70" units="K" comment="Filter wheel"/>
|
||||
<optical_component type="Mirror" reflectance="data/mirror/reflectance.csv"
|
||||
emissivity="data/mirror/emissivity.csv" temp="70" temp_unit="K" comment="M1"/>
|
||||
<optical_component type="Mirror" reflectance="data/mirror/reflectance.csv"
|
||||
emissivity="data/mirror/emissivity.csv" temp="70" temp_unit="K" comment="M2"/>
|
||||
<optical_component type="Mirror" reflectance="data/mirror/reflectance.csv"
|
||||
emissivity="data/mirror/emissivity.csv" temp="70" temp_unit="K" comment="M3"/>
|
||||
<!-- <optical_component type="Filter" band="B"-->
|
||||
<!-- emissivity="data/filter/emissivity.csv" val="70" val_unit="K" comment="Filter wheel"/>-->
|
||||
<optical_component type="Filter" start="400" start_unit="nm" end="480" end_unit="nm"
|
||||
emissivity="data/filter/emissivity.csv" temp="70" temp_unit="K" comment="Filter wheel"/>
|
||||
</common_optics>
|
||||
|
||||
<instrument>
|
||||
<optical_component type="Mirror" reflectivity="data/mirror/reflectivity.csv"
|
||||
emissivity="data/mirror/emissivity.csv" val="70" units="K" comment="M4"/>
|
||||
<optical_component type="Filter" band="G"
|
||||
emissivity="data/filter/emissivity.csv" val="70" units="K" comment="Filter wheel"/>
|
||||
<optical_component type="Lens" transmittance="data/lens/transmittance.csv"
|
||||
emissivity="data/lens/emissivity.csv" temp="70" temp_unit="K" comment="M4"/>
|
||||
<sensor type="CCD">
|
||||
<f_number val="18.5" units="" comment="The working f/#"/>
|
||||
<pixel_geometry val="1024, 1024" units="" comment="Pixel geometry"/>
|
||||
<f_number val="18.5" val_unit="" comment="The working f/#"/>
|
||||
<pixel_geometry val="1024, 1024" val_unit="" comment="Pixel geometry"/>
|
||||
<pixel>
|
||||
<quantum_efficiency val="data/ccd/qe.csv" comment="Quantum efficiency of the detector pixel"/>
|
||||
<pixel_size val="15" units="micron"/>
|
||||
<dark_current val="20" units="1/s" comment="Detector dark current"/>
|
||||
<sigma_read_out val="10.0" units="" comment="Detector readout noise in e-rms"/>
|
||||
<pixel_size val="15" val_unit="micron"/>
|
||||
<dark_current val="20" val_unit="1/s" comment="Detector dark current"/>
|
||||
<sigma_read_out val="10.0" val_unit="" comment="Detector readout noise in e-rms"/>
|
||||
</pixel>
|
||||
</sensor>
|
||||
</instrument>
|
||||
|
@ -5,6 +5,7 @@ import os
|
||||
import logging
|
||||
from ..lib.helpers import error
|
||||
from typing import Union
|
||||
import re
|
||||
|
||||
|
||||
class Entry(object):
|
||||
@ -33,17 +34,22 @@ class Entry(object):
|
||||
# Copy the XML attributes to object attributes
|
||||
for attrib in xml.attrib.keys():
|
||||
setattr(self, attrib, xml.attrib[attrib])
|
||||
|
||||
# Convert to python datatype and apply the corresponding unit (if applicable)
|
||||
if hasattr(self, 'units'):
|
||||
try:
|
||||
self.val = u.Quantity(list(map(float, self.val.split(','))),
|
||||
self.units)
|
||||
if len(self.val) == 1:
|
||||
self.val = self.val[0]
|
||||
except (ValueError, LookupError):
|
||||
error("unable to convert units in entry '" + xml.tag + "': " + self.val + " " + self.units, exit_=False)
|
||||
elif hasattr(self, "val") and self.val.lower() in ["false", "true"]:
|
||||
# parse units
|
||||
attribs = list(xml.attrib.keys())
|
||||
units = list(filter(re.compile(".*_unit$").match, attribs))
|
||||
for unit in units:
|
||||
var = unit.replace("_unit", "")
|
||||
if hasattr(self, var):
|
||||
try:
|
||||
val = u.Quantity(list(map(float, getattr(self, var).split(','))), getattr(self, unit))
|
||||
if len(val) == 1:
|
||||
val = val[0]
|
||||
setattr(self, var, val)
|
||||
except (ValueError, LookupError):
|
||||
error("unable to convert units in entry '" + xml.tag + "': " + getattr(self, var) + " " +
|
||||
getattr(self, unit), exit_=False)
|
||||
# Convert boolean values
|
||||
if hasattr(self, "val") and type(self.val) == str and self.val.lower() in ["false", "true"]:
|
||||
self.val = (self.val.lower() == "true")
|
||||
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
<root>
|
||||
<common>
|
||||
<wl_min val="400" units="nanometer" comment="Shortest wavelength used for binning input spectra"/>
|
||||
<wl_max val="5" units="micron" comment="Shortest wavelength used for binning input spectra"/>
|
||||
<wl_delta val="10" units="nanometer" comment="Wavelength increment used for binning input spectra"/>
|
||||
<!-- <res val="1000" units=""-->
|
||||
<wl_min val="400" val_unit="nm" comment="Shortest wavelength used for binning input spectra"/>
|
||||
<wl_max val="500" val_unit="nm" comment="Shortest wavelength used for binning input spectra"/>
|
||||
<wl_delta val="10" val_unit="nm" comment="Wavelength increment used for binning input spectra"/>
|
||||
<!-- <res val="1000" val_unit=""-->
|
||||
<!-- comment="Resolving power for common spectral binning. A linear binning wavelength integral is estimated as wl_min/R"/>-->
|
||||
<d_aperture val="5" units="m" comment="Diameter of the telescope aperture"/>
|
||||
<jitter_rms val="0.1" units="arcsec" comment="Sigma RMS of the telescope jitter"/>
|
||||
<d_aperture val="5" val_unit="m" comment="Diameter of the telescope aperture"/>
|
||||
<jitter_rms val="0.1" val_unit="arcsec" comment="Sigma RMS of the telescope jitter"/>
|
||||
<output_path val="output" comment="Output directory to store output files"/>
|
||||
</common>
|
||||
|
||||
@ -17,38 +17,38 @@
|
||||
</noise>
|
||||
|
||||
<astroscene>
|
||||
<target type="BlackBodyTarget" val="5778" units="K" mag="10" band="G"
|
||||
<target type="BlackBodyTarget" temp="5778" temp_unit="K" mag="10" band="V"
|
||||
comment="Modeling the sun as mag 10 star"/>
|
||||
<optical_component type="Atmosphere" transmissivity="data/atmosphere/transmittance.csv"
|
||||
<optical_component type="Atmosphere" transmittance="data/atmosphere/transmittance.csv"
|
||||
emission="data/atmosphere/emission.csv" comment="Including the atmosphere"/>
|
||||
<optical_component type="StrayLight" emission="data/strayLight/emission.csv"
|
||||
comment="Including arbitrary noise sources"/>
|
||||
</astroscene>
|
||||
|
||||
<common_optics>
|
||||
<optical_component type="Mirror" reflectivity="data/mirror/reflectivity.csv"
|
||||
emissivity="data/mirror/emissivity.csv" val="70" units="K" comment="M1"/>
|
||||
<optical_component type="Mirror" reflectivity="data/mirror/reflectivity.csv"
|
||||
emissivity="data/mirror/emissivity.csv" val="70" units="K" comment="M2"/>
|
||||
<optical_component type="Mirror" reflectivity="data/mirror/reflectivity.csv"
|
||||
emissivity="data/mirror/emissivity.csv" val="70" units="K" comment="M3"/>
|
||||
<optical_component type="Filter" band="G"
|
||||
emissivity="data/filter/emissivity.csv" val="70" units="K" comment="Filter wheel"/>
|
||||
<optical_component type="Mirror" reflectance="data/mirror/reflectance.csv"
|
||||
emissivity="data/mirror/emissivity.csv" temp="70" temp_unit="K" comment="M1"/>
|
||||
<optical_component type="Mirror" reflectance="data/mirror/reflectance.csv"
|
||||
emissivity="data/mirror/emissivity.csv" temp="70" temp_unit="K" comment="M2"/>
|
||||
<optical_component type="Mirror" reflectance="data/mirror/reflectance.csv"
|
||||
emissivity="data/mirror/emissivity.csv" temp="70" temp_unit="K" comment="M3"/>
|
||||
<!-- <optical_component type="Filter" band="B"-->
|
||||
<!-- emissivity="data/filter/emissivity.csv" val="70" val_unit="K" comment="Filter wheel"/>-->
|
||||
<optical_component type="Filter" start="400" start_unit="nm" end="480" end_unit="nm"
|
||||
emissivity="data/filter/emissivity.csv" temp="70" temp_unit="K" comment="Filter wheel"/>
|
||||
</common_optics>
|
||||
|
||||
<instrument>
|
||||
<optical_component type="Mirror" reflectivity="data/mirror/reflectivity.csv"
|
||||
emissivity="data/mirror/emissivity.csv" val="70" units="K" comment="M4"/>
|
||||
<optical_component type="Filter" band="G"
|
||||
emissivity="data/filter/emissivity.csv" val="70" units="K" comment="Filter wheel"/>
|
||||
<optical_component type="Lens" transmittance="data/lens/transmittance.csv"
|
||||
emissivity="data/lens/emissivity.csv" temp="70" temp_unit="K" comment="M4"/>
|
||||
<sensor type="CCD">
|
||||
<f_number val="18.5" units="" comment="The working f/#"/>
|
||||
<pixel_geometry val="1024, 1024" units="" comment="Pixel geometry"/>
|
||||
<f_number val="18.5" val_unit="" comment="The working f/#"/>
|
||||
<pixel_geometry val="1024, 1024" val_unit="" comment="Pixel geometry"/>
|
||||
<pixel>
|
||||
<quantum_efficiency val="data/ccd/qe.csv" comment="Quantum efficiency of the detector pixel"/>
|
||||
<pixel_size val="15" units="micron"/>
|
||||
<dark_current val="20" units="1/s" comment="Detector dark current"/>
|
||||
<sigma_read_out val="10.0" units="" comment="Detector readout noise in e-rms"/>
|
||||
<pixel_size val="15" val_unit="micron"/>
|
||||
<dark_current val="20" val_unit="1/s" comment="Detector dark current"/>
|
||||
<sigma_read_out val="10.0" val_unit="" comment="Detector readout noise in e-rms"/>
|
||||
</pixel>
|
||||
</sensor>
|
||||
</instrument>
|
||||
|
Loading…
x
Reference in New Issue
Block a user