From fcfe35a20662b0b82cea51bd0d54f2eb9b0c8835 Mon Sep 17 00:00:00 2001 From: LukasK13 Date: Wed, 13 May 2020 14:33:22 +0200 Subject: [PATCH] Initial commit --- esbo_etc/classes/sensor/SensorFactory.py | 52 ++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 esbo_etc/classes/sensor/SensorFactory.py diff --git a/esbo_etc/classes/sensor/SensorFactory.py b/esbo_etc/classes/sensor/SensorFactory.py new file mode 100644 index 0000000..9169c36 --- /dev/null +++ b/esbo_etc/classes/sensor/SensorFactory.py @@ -0,0 +1,52 @@ +from ..IRadiant import IRadiant +from ..Entry import Entry +from .ASensor import ASensor +from .Imager import Imager +from ...lib.helpers import error + + +class SensorFactory: + """ + A Factory creating objects of the type ASensor + """ + def __init__(self, parent: IRadiant, common_conf: Entry): + """ + Instantiate a new factory object + """ + self.__common_conf = common_conf + self.__parent = parent + + def create(self, options: Entry) -> ASensor: + """ + Create a new object of the type ASensor + + Parameters + ---------- + options : Entry + The options to be used as parameters for the instantiation of the new object. + Returns + ------- + obj : ASensor + The created sensor object + """ + if options.type == "Imager": + args = dict(parent=self.__parent, quantum_efficiency=options.pixel.quantum_efficiency(), + pixel_geometry=options.pixel_geometry(), pixel_size=options.pixel.pixel_size(), + read_noise=options.pixel.sigma_read_out(), dark_current=options.pixel.dark_current(), + f_number=options.f_number(), common_conf=self.__common_conf) + if hasattr(options, "center_offset"): + # noinspection PyCallingNonCallable + args["center_offset"] = options.center_offset() + if hasattr(options, "photometric_aperture"): + if hasattr(options.photometric_aperture, "shape") and isinstance( + options.photometric_aperture.shape, Entry): + args["shape"] = options.photometric_aperture.shape() + if hasattr(options.photometric_aperture, "contained_energy") and isinstance( + options.photometric_aperture.contained_energy, Entry): + args["contained_energy"] = options.photometric_aperture.contained_energy() + if hasattr(options.photometric_aperture, "contained_pixels") and isinstance( + options.photometric_aperture.contained_pixels, Entry): + args["contained_pixels"] = options.photometric_aperture.contained_pixels() + return Imager(**args) + else: + error("Wrong sensor type: " + options.type)