Sensor configuration checking improved
This commit is contained in:
parent
c014131574
commit
63e9ded9d4
@ -171,13 +171,13 @@ class Configuration(object):
|
|||||||
if not hasattr(self.conf.instrument, "sensor"):
|
if not hasattr(self.conf.instrument, "sensor"):
|
||||||
error("Configuration check: instrument: Missing required container 'sensor'.")
|
error("Configuration check: instrument: Missing required container 'sensor'.")
|
||||||
if not hasattr(self.conf.instrument.sensor, "type"):
|
if not hasattr(self.conf.instrument.sensor, "type"):
|
||||||
error("Configuration check: instrument -> target: Missing required parameter 'type'.")
|
error("Configuration check: instrument -> sensor: Missing required parameter 'type'.")
|
||||||
if self.conf.instrument.sensor.type not in dir(sensor):
|
if self.conf.instrument.sensor.type not in dir(sensor):
|
||||||
# noinspection PyTypeChecker
|
# noinspection PyTypeChecker
|
||||||
error("Configuration check: sensor -> target: Sensor type '" + self.conf.instrument.sensor.type +
|
error("Configuration check: instrument -> sensor: Sensor type '" + self.conf.instrument.sensor.type +
|
||||||
"' does not exist. Did you mean '" + difflib.get_close_matches(self.conf.instrument.sensor.type,
|
"' does not exist. Did you mean '" + difflib.get_close_matches(self.conf.instrument.sensor.type,
|
||||||
dir(sensor), 1)[0] + "'?")
|
dir(sensor), 1)[0] + "'?")
|
||||||
mes = getattr(sensor, self.conf.instrument.sensor.type).check_config(self.conf.instrument.sensor)
|
mes = getattr(sensor, self.conf.instrument.sensor.type).check_config(self.conf.instrument.sensor, self.conf)
|
||||||
mes is not None and error("Configuration check: instrument -> sensor -> " + mes)
|
mes is not None and error("Configuration check: instrument -> sensor -> " + mes)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -56,14 +56,16 @@ class ASensor:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def check_config(conf: Entry) -> Union[None, str]:
|
def check_config(sensor: Entry, conf: Entry) -> Union[None, str]:
|
||||||
"""
|
"""
|
||||||
Check the configuration for this class
|
Check the configuration for this class
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
conf : Entry
|
sensor : Entry
|
||||||
The configuration entry to be checked.
|
The configuration entry to be checked.
|
||||||
|
conf: Entry
|
||||||
|
The complete configuration.
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
|
@ -220,75 +220,93 @@ class Imager(ASensor):
|
|||||||
return signal_current, size, obstruction, background_current
|
return signal_current, size, obstruction, background_current
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def check_config(conf: Entry) -> Union[None, str]:
|
def check_config(sensor: Entry, conf: Entry) -> Union[None, str]:
|
||||||
"""
|
"""
|
||||||
Check the configuration for this class
|
Check the configuration for this class
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
conf : Entry
|
sensor : Entry
|
||||||
The configuration entry to be checked.
|
The configuration entry to be checked.
|
||||||
|
conf: Entry
|
||||||
|
The complete configuration.
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
mes : Union[None, str]
|
mes : Union[None, str]
|
||||||
The error message of the check. This will be None if the check was successful.
|
The error message of the check. This will be None if the check was successful.
|
||||||
"""
|
"""
|
||||||
if not hasattr(conf, "f_number"):
|
if not hasattr(sensor, "f_number"):
|
||||||
return "Missing container 'f_number'."
|
return "Missing container 'f_number'."
|
||||||
mes = conf.f_number.check_float("val")
|
mes = sensor.f_number.check_float("val")
|
||||||
if mes is not None:
|
if mes is not None:
|
||||||
return "f_number: " + mes
|
return "f_number: " + mes
|
||||||
if not hasattr(conf, "pixel_geometry"):
|
if not hasattr(sensor, "pixel_geometry"):
|
||||||
return "Missing container 'pixel_geometry'."
|
return "Missing container 'pixel_geometry'."
|
||||||
mes = conf.pixel_geometry.check_quantity("val", u.pix)
|
mes = sensor.pixel_geometry.check_quantity("val", u.pix)
|
||||||
if mes is not None:
|
if mes is not None:
|
||||||
return "pixel_geometry: " + mes
|
return "pixel_geometry: " + mes
|
||||||
if hasattr(conf, "center_offset") and isinstance(conf.center_offset, Entry):
|
if hasattr(sensor, "center_offset") and isinstance(sensor.center_offset, Entry):
|
||||||
mes = conf.center_offset.check_quantity("val", u.pix)
|
mes = sensor.center_offset.check_quantity("val", u.pix)
|
||||||
if mes is not None:
|
if mes is not None:
|
||||||
return "center_offset: " + mes
|
return "center_offset: " + mes
|
||||||
|
|
||||||
# Check pixel
|
# Check pixel
|
||||||
if not hasattr(conf, "pixel"):
|
if not hasattr(sensor, "pixel"):
|
||||||
return "Missing container 'pixel'."
|
return "Missing container 'pixel'."
|
||||||
if not hasattr(conf.pixel, "quantum_efficiency"):
|
if not hasattr(sensor.pixel, "quantum_efficiency"):
|
||||||
return "Missing container 'quantum_efficiency'."
|
return "Missing container 'quantum_efficiency'."
|
||||||
mes = conf.pixel.quantum_efficiency.check_float("val")
|
mes = sensor.pixel.quantum_efficiency.check_float("val")
|
||||||
if mes is not None:
|
if mes is not None:
|
||||||
mes = conf.pixel.quantum_efficiency.check_file("val")
|
mes = sensor.pixel.quantum_efficiency.check_file("val")
|
||||||
if mes is not None:
|
if mes is not None:
|
||||||
return "pixel -> quantum_efficiency: " + mes
|
return "pixel -> quantum_efficiency: " + mes
|
||||||
if not hasattr(conf.pixel, "pixel_size"):
|
if not hasattr(conf.pixel, "pixel_size"):
|
||||||
return "Missing container 'pixel_size'."
|
return "Missing container 'pixel_size'."
|
||||||
mes = conf.pixel.pixel_size.check_quantity("val", u.m)
|
mes = sensor.pixel.pixel_size.check_quantity("val", u.m)
|
||||||
if mes is not None:
|
if mes is not None:
|
||||||
return "pixel -> pixel_size: " + mes
|
return "pixel -> pixel_size: " + mes
|
||||||
if not hasattr(conf.pixel, "dark_current"):
|
if not hasattr(sensor.pixel, "dark_current"):
|
||||||
return "Missing container 'dark_current'."
|
return "Missing container 'dark_current'."
|
||||||
mes = conf.pixel.dark_current.check_quantity("val", u.electron / (u.pix * u.s))
|
mes = sensor.pixel.dark_current.check_quantity("val", u.electron / (u.pix * u.s))
|
||||||
if mes is not None:
|
if mes is not None:
|
||||||
return "pixel -> dark_current: " + mes
|
return "pixel -> dark_current: " + mes
|
||||||
if not hasattr(conf.pixel, "sigma_read_out"):
|
if not hasattr(sensor.pixel, "sigma_read_out"):
|
||||||
return "Missing container 'sigma_read_out'."
|
return "Missing container 'sigma_read_out'."
|
||||||
mes = conf.pixel.sigma_read_out.check_quantity("val", u.electron ** 0.5 / u.pix)
|
mes = sensor.pixel.sigma_read_out.check_quantity("val", u.electron ** 0.5 / u.pix)
|
||||||
if mes is not None:
|
if mes is not None:
|
||||||
return "pixel -> sigma_read_out: " + mes
|
return "pixel -> sigma_read_out: " + mes
|
||||||
|
if not hasattr(sensor.pixel, "well_capacity"):
|
||||||
|
return "Missing container 'well_capacity'."
|
||||||
|
mes = sensor.pixel.well_capacity.check_quantity("val", u.electron)
|
||||||
|
if mes is not None:
|
||||||
|
return "pixel -> well_capacity: " + mes
|
||||||
|
|
||||||
# Check photometric aperture
|
# Check photometric aperture
|
||||||
if not hasattr(conf, "photometric_aperture"):
|
if conf.astroscene.target.size == "point":
|
||||||
return "Missing container 'photometric_aperture'."
|
if not hasattr(sensor, "photometric_aperture"):
|
||||||
if hasattr(conf.photometric_aperture, "shape"):
|
return "Missing container 'photometric_aperture'."
|
||||||
mes = conf.photometric_aperture.shape.check_selection("val", ["square", "circle"])
|
if hasattr(sensor.photometric_aperture, "contained_pixels"):
|
||||||
if mes is not None:
|
mes = sensor.photometric_aperture.contained_pixels.check_quantity("val", u.pix)
|
||||||
return "photometric_aperture -> shape: " + mes
|
|
||||||
if hasattr(conf.photometric_aperture, "contained_energy"):
|
|
||||||
mes = conf.photometric_aperture.contained_energy.check_float("val")
|
|
||||||
if mes is not None:
|
|
||||||
mes = conf.photometric_aperture.contained_energy.check_selection("val", ["peak", "FWHM", "fwhm", "min"])
|
|
||||||
if mes is not None:
|
if mes is not None:
|
||||||
return "photometric_aperture -> contained_energy: " + mes
|
return "photometric_aperture -> contained_pixels: " + mes
|
||||||
if hasattr(conf.photometric_aperture, "contained_pixels"):
|
else:
|
||||||
mes = conf.photometric_aperture.contained_pixels.check_quantity("val", u.pix)
|
if not hasattr(sensor.photometric_aperture, "shape"):
|
||||||
if mes is not None:
|
return "Missing container 'shape'."
|
||||||
return "photometric_aperture -> contained_pixels: " + mes
|
mes = sensor.photometric_aperture.shape.check_selection("val", ["square", "circle"])
|
||||||
|
if mes is not None:
|
||||||
|
return "photometric_aperture -> shape: " + mes
|
||||||
|
if not hasattr(sensor.photometric_aperture, "contained_energy"):
|
||||||
|
return "Missing container 'contained_energy'."
|
||||||
|
mes = sensor.photometric_aperture.contained_energy.check_float("val")
|
||||||
|
if mes is not None:
|
||||||
|
if conf.common.psf().lower() == "airy":
|
||||||
|
mes = sensor.photometric_aperture.contained_energy.check_selection("val",
|
||||||
|
["peak", "FWHM", "fwhm",
|
||||||
|
"min"])
|
||||||
|
if mes is not None:
|
||||||
|
return "photometric_aperture -> contained_energy: " + mes
|
||||||
|
else:
|
||||||
|
mes = sensor.photometric_aperture.contained_energy.check_selection("val", ["FWHM", "fwhm"])
|
||||||
|
if mes is not None:
|
||||||
|
return "photometric_aperture -> contained_energy: " + mes
|
||||||
|
Loading…
Reference in New Issue
Block a user