From a9749994759934c7ae8432dac6abc316bfc6daf0 Mon Sep 17 00:00:00 2001 From: LukasK13 Date: Wed, 9 Sep 2020 13:14:01 +0200 Subject: [PATCH] parameter contained_pixels renamed to aperture_size --- docs/source/configuration/sensor.rst | 14 +++++++------- esbo_etc/classes/sensor/Imager.py | 20 ++++++++++---------- esbo_etc/classes/sensor/SensorFactory.py | 6 +++--- tests/data/esbo-etc_defaults.xml | 2 +- tests/sensor/test_Imager.py | 2 +- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/docs/source/configuration/sensor.rst b/docs/source/configuration/sensor.rst index b15996c..acbc2bb 100644 --- a/docs/source/configuration/sensor.rst +++ b/docs/source/configuration/sensor.rst @@ -31,7 +31,7 @@ The Imager sensor type allows to model a generic imaging sensor which uses a pix - + @@ -178,7 +178,7 @@ The photometric_aperture-container contains parameters for the photometric apert - + shape @@ -209,21 +209,21 @@ Attributes: * | **val:** (float, str) | The energy to be contained within the photometric aperture. This can be either the percentage of contained energy or one of [``Peak``, ``FWHM``, ``Min``]. -contained_pixels +aperture_size """""""""""""""" *optional* -The number of pixels to be contained within the photometric aperture. If this parameter is given, the :ref:`contained_energy` parameter will be ignored. The square root of this value will be used as the radius of the photometric aperture. +The radius respectively the edge length of the photometric aperture in pixels. If this parameter is given, the :ref:`contained_energy` parameter will be ignored. .. code-block:: xml - + Attributes: * | **val:** float - | The number of pixels to be contained within the photometric aperture. + | The radius respectively the edge length of the photometric aperture. * | **val_unit:** str, *optional* = "pix" - | The unit of the number of pixels to be contained within the photometric aperture. This has to be ``pix``. + | The unit of the radius respectively the edge length of the photometric aperture. This has to be ``pix``. Heterodyne ---------- diff --git a/esbo_etc/classes/sensor/Imager.py b/esbo_etc/classes/sensor/Imager.py index 1e93edf..c960372 100644 --- a/esbo_etc/classes/sensor/Imager.py +++ b/esbo_etc/classes/sensor/Imager.py @@ -26,7 +26,7 @@ class Imager(ASensor): pixel_geometry: u.Quantity, pixel_size: u.Quantity, read_noise: u.Quantity, dark_current: u.Quantity, well_capacity: u.Quantity, f_number: Union[int, float], common_conf: Entry, center_offset: u.Quantity = np.array([0, 0]) << u.pix, shape: str = "circle", - contained_energy: Union[str, int, float] = "FWHM", contained_pixels: u.Quantity = None): + contained_energy: Union[str, int, float] = "FWHM", aperture_size: u.Quantity = None): """ Initialize a new Image-sensor model. Initialize a new Image-sensor model. @@ -60,8 +60,8 @@ class Imager(ASensor): The shape of the photometric aperture. Can be either square or circle contained_energy : Union[str, int, float] The energy contained within the photometric aperture. - contained_pixels : u.Quantity - The pixels contained within the photometric aperture. + aperture_size : u.Quantity + The radius respectively the edge length of the photometric aperture. """ super().__init__(parent) if type(quantum_efficiency) == str: @@ -77,7 +77,7 @@ class Imager(ASensor): self.__center_offset = center_offset self.__shape = shape self.__contained_energy = contained_energy - self.__contained_pixels = contained_pixels + self.__aperture_size = aperture_size self.__common_conf = common_conf # Calculate central wavelength self.__central_wl = self.__common_conf.wl_min() + ( @@ -361,9 +361,9 @@ class Imager(ASensor): mask.createPhotometricAperture("circle", d_photometric_ap / 2, np.array([0, 0]) << u.pix) else: # Target is a point source - if self.__contained_pixels is not None: + if self.__aperture_size is not None: # Calculate the diameter of the photometric aperture as square root of the contained pixels - d_photometric_ap = np.sqrt(self.__contained_pixels.value) * u.pix + d_photometric_ap = np.sqrt(self.__aperture_size.value) * u.pix # Mask the pixels to be exposed mask.createPhotometricAperture("square", d_photometric_ap / 2, np.array([0, 0]) << u.pix) else: @@ -379,7 +379,7 @@ class Imager(ASensor): read_noise = mask * self.__read_noise * u.pix # Calculate the dark current PixelMask dark_current = mask * self.__dark_current * u.pix - if self.__contained_pixels is None and size.lower() != "extended": + if self.__aperture_size is None and size.lower() != "extended": if type(self.__contained_energy) == str: if self.__contained_energy.lower() == "peak": logger.info("The radius of the photometric aperture is %.2f pixels. This equals the peak value" % ( @@ -552,10 +552,10 @@ class Imager(ASensor): if not hasattr(sensor, "photometric_aperture"): setattr(sensor, "photometric_aperture", Entry(shape=Entry(val="circle"), contained_energy=Entry(val="FWHM"))) - if hasattr(sensor.photometric_aperture, "contained_pixels"): - mes = sensor.photometric_aperture.contained_pixels.check_quantity("val", u.pix) + if hasattr(sensor.photometric_aperture, "aperture_size"): + mes = sensor.photometric_aperture.aperture_size.check_quantity("val", u.pix) if mes is not None: - return "photometric_aperture -> contained_pixels: " + mes + return "photometric_aperture -> aperture_size: " + mes else: if not hasattr(sensor.photometric_aperture, "shape"): return "Missing container 'shape'." diff --git a/esbo_etc/classes/sensor/SensorFactory.py b/esbo_etc/classes/sensor/SensorFactory.py index 7084dee..e23ad1c 100644 --- a/esbo_etc/classes/sensor/SensorFactory.py +++ b/esbo_etc/classes/sensor/SensorFactory.py @@ -46,9 +46,9 @@ class SensorFactory: 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() + if hasattr(options.photometric_aperture, "aperture_size") and isinstance( + options.photometric_aperture.aperture_size, Entry): + args["aperture_size"] = options.photometric_aperture.aperture_size() return Imager(**args) elif options.type == "Heterodyne": args = dict(parent=self.__parent, aperture_efficiency=options.aperture_efficiency(), diff --git a/tests/data/esbo-etc_defaults.xml b/tests/data/esbo-etc_defaults.xml index 72232f3..bd016e6 100644 --- a/tests/data/esbo-etc_defaults.xml +++ b/tests/data/esbo-etc_defaults.xml @@ -54,7 +54,7 @@ - + diff --git a/tests/sensor/test_Imager.py b/tests/sensor/test_Imager.py index 84c98ce..75ad568 100644 --- a/tests/sensor/test_Imager.py +++ b/tests/sensor/test_Imager.py @@ -16,7 +16,7 @@ class TestImager(TestCase): pixel_size=6.5 * u.um, read_noise=1.4 * u.electron ** 0.5 / u.pix, dark_current=0.6 * u.electron / u.pix / u.second, well_capacity=30000 * u.electron, f_number=13, common_conf=self.config.common, center_offset=np.array([0, 0]) << u.pix, - shape="circle", contained_energy="FWHM", contained_pixels=None) + shape="circle", contained_energy="FWHM", aperture_size=None) self.target = FileTarget("tests/data/target/target_demo_1.csv", np.arange(200, 210) << u.nm) self.zodiac = StrayLight(self.target, "tests/data/straylight/zodiacal_emission_1.csv") self.imager = Imager(self.zodiac, **self.imager_args)