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