ESBO-ETC/esbo_etc/esbo-etc.py

32 lines
1.6 KiB
Python
Raw Normal View History

2020-04-21 14:47:31 +02:00
import esbo_etc as etc
2020-04-06 17:17:31 +02:00
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",
metavar="config.xml", help="path to the configuration file")
2020-04-24 11:05:41 +02:00
parser.add_argument("-l", "--logging", dest="logging", default="WARNING", help="print debug information")
2020-04-06 17:17:31 +02:00
parser.add_argument("-o", "--output-dir", dest="output_dir", help="path to the output directory",
default="output")
parser.add_argument("-v", "--version", action="version", version="ESBO-ETC version 1.0.0",
help="show version information")
2020-04-21 14:47:31 +02:00
args, _ = parser.parse_known_args() # fix for PyCharm python console
2020-04-06 17:17:31 +02:00
2020-05-15 14:59:07 +02:00
logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.WARNING if args.logging is None else getattr(
logging, args.logging.upper()), stream=sys.stdout)
2020-04-06 17:17:31 +02:00
2020-04-21 14:47:31 +02:00
conf = etc.Configuration(args.config).conf
2020-04-06 17:17:31 +02:00
2020-05-15 14:59:07 +02:00
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)