diff --git a/esbo_etc/classes/Config.py b/esbo_etc/classes/Config.py index 3df5182..adca288 100644 --- a/esbo_etc/classes/Config.py +++ b/esbo_etc/classes/Config.py @@ -139,6 +139,14 @@ class Configuration(object): mes is not None and error("Configuration check: common -> jitter_sigma: " + mes) if not hasattr(self.conf.common, "output_path"): setattr(self.conf.common, "output_path", Entry(val=".")) + if hasattr(self.conf.common, "exposure_time"): + mes = self.conf.common.exposure_time.check_quantity("val", u.s) + mes is not None and error("Configuration check: common -> exposure_time: " + mes) + elif hasattr(self.conf.common, "snr"): + mes = self.conf.common.snr.check_quantity("val", u.dimensionless_unscaled) + mes is not None and error("Configuration check: common -> snr: " + mes) + else: + error("Configuration check: common: Expected one of the containers 'exposure_time' or 'snr' but got none.") # Check astroscene if not hasattr(self.conf, "astroscene"): diff --git a/esbo_etc/esbo-etc.py b/esbo_etc/esbo-etc.py index 1729759..2a58942 100644 --- a/esbo_etc/esbo-etc.py +++ b/esbo_etc/esbo-etc.py @@ -3,7 +3,6 @@ import argparse import logging import sys - if __name__ == "__main__": parser = argparse.ArgumentParser(prog="esbo_etc/esbo-etc.py", description='Exposure time calculator for ESBO-DS') parser.add_argument("-c", "--config", dest='config', default="esbo-etc_defaults.xml", @@ -15,10 +14,18 @@ if __name__ == "__main__": help="show version information") args, _ = parser.parse_known_args() # fix for PyCharm python console - logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.WARNING if args.logging is None else - getattr(logging, args.logging.upper()), stream=sys.stdout) + logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.WARNING if args.logging is None else getattr( + logging, args.logging.upper()), stream=sys.stdout) conf = etc.Configuration(args.config).conf - factory = etc.classes.RadiantFactory(conf.common.wl_bins()) - parent = factory.fromConfig(conf) + oc_factory = etc.classes.RadiantFactory(conf.common.wl_bins()) + parent = oc_factory.fromConfigBatch(conf) + sensor_factory = etc.SensorFactory(parent, conf.common) + imager = sensor_factory.create(conf.instrument.sensor) + if hasattr(conf.common, "exposure_time"): + snr = imager.getSNR(conf.common.exposure_time()) + print("The SNR is: %.2f" % snr) + elif hasattr(conf.common, "snr"): + exp_time = imager.getExpTime(conf.common.snr()) + print("The necessary exposure time is: %.2f s" % exp_time.value)