parameter contained_pixels renamed to aperture_size

This commit is contained in:
Lukas Klass 2020-09-09 13:14:01 +02:00
parent 081304a9fc
commit a974999475
5 changed files with 22 additions and 22 deletions

View File

@ -31,7 +31,7 @@ The Imager sensor type allows to model a generic imaging sensor which uses a pix
<photometric_aperture> <photometric_aperture>
<shape val="circle"/> <shape val="circle"/>
<contained_energy val="80"/> <contained_energy val="80"/>
<contained_pixels val="100" val_unit="pix"/> <aperture_size val="100" val_unit="pix"/>
</photometric_aperture> </photometric_aperture>
</sensor> </sensor>
@ -178,7 +178,7 @@ The photometric_aperture-container contains parameters for the photometric apert
<photometric_aperture/> <photometric_aperture/>
<shape val="circle"/> <shape val="circle"/>
<contained_energy val="80"/> <contained_energy val="80"/>
<contained_pixels val="100" val_unit="pix"/> <aperture_size val="100" val_unit="pix"/>
</photometric_aperture> </photometric_aperture>
shape shape
@ -209,21 +209,21 @@ Attributes:
* | **val:** (float, str) * | **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``]. | 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* *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 .. code-block:: xml
<contained_pixels val="100" val_unit="pix"/> <aperture_size val="100" val_unit="pix"/>
Attributes: Attributes:
* | **val:** float * | **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" * | **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 Heterodyne
---------- ----------

View File

@ -26,7 +26,7 @@ class Imager(ASensor):
pixel_geometry: u.Quantity, pixel_size: u.Quantity, read_noise: u.Quantity, dark_current: u.Quantity, 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, 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", 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.
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 The shape of the photometric aperture. Can be either square or circle
contained_energy : Union[str, int, float] contained_energy : Union[str, int, float]
The energy contained within the photometric aperture. The energy contained within the photometric aperture.
contained_pixels : u.Quantity aperture_size : u.Quantity
The pixels contained within the photometric aperture. The radius respectively the edge length of the photometric aperture.
""" """
super().__init__(parent) super().__init__(parent)
if type(quantum_efficiency) == str: if type(quantum_efficiency) == str:
@ -77,7 +77,7 @@ class Imager(ASensor):
self.__center_offset = center_offset self.__center_offset = center_offset
self.__shape = shape self.__shape = shape
self.__contained_energy = contained_energy self.__contained_energy = contained_energy
self.__contained_pixels = contained_pixels self.__aperture_size = aperture_size
self.__common_conf = common_conf self.__common_conf = common_conf
# Calculate central wavelength # Calculate central wavelength
self.__central_wl = self.__common_conf.wl_min() + ( 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) mask.createPhotometricAperture("circle", d_photometric_ap / 2, np.array([0, 0]) << u.pix)
else: else:
# Target is a point source # 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 # 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 the pixels to be exposed
mask.createPhotometricAperture("square", d_photometric_ap / 2, np.array([0, 0]) << u.pix) mask.createPhotometricAperture("square", d_photometric_ap / 2, np.array([0, 0]) << u.pix)
else: else:
@ -379,7 +379,7 @@ class Imager(ASensor):
read_noise = mask * self.__read_noise * u.pix read_noise = mask * self.__read_noise * u.pix
# Calculate the dark current PixelMask # Calculate the dark current PixelMask
dark_current = mask * self.__dark_current * u.pix 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 type(self.__contained_energy) == str:
if self.__contained_energy.lower() == "peak": if self.__contained_energy.lower() == "peak":
logger.info("The radius of the photometric aperture is %.2f pixels. This equals the peak value" % ( 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"): if not hasattr(sensor, "photometric_aperture"):
setattr(sensor, "photometric_aperture", Entry(shape=Entry(val="circle"), setattr(sensor, "photometric_aperture", Entry(shape=Entry(val="circle"),
contained_energy=Entry(val="FWHM"))) contained_energy=Entry(val="FWHM")))
if hasattr(sensor.photometric_aperture, "contained_pixels"): if hasattr(sensor.photometric_aperture, "aperture_size"):
mes = sensor.photometric_aperture.contained_pixels.check_quantity("val", u.pix) mes = sensor.photometric_aperture.aperture_size.check_quantity("val", u.pix)
if mes is not None: if mes is not None:
return "photometric_aperture -> contained_pixels: " + mes return "photometric_aperture -> aperture_size: " + mes
else: else:
if not hasattr(sensor.photometric_aperture, "shape"): if not hasattr(sensor.photometric_aperture, "shape"):
return "Missing container 'shape'." return "Missing container 'shape'."

View File

@ -46,9 +46,9 @@ class SensorFactory:
if hasattr(options.photometric_aperture, "contained_energy") and isinstance( if hasattr(options.photometric_aperture, "contained_energy") and isinstance(
options.photometric_aperture.contained_energy, Entry): options.photometric_aperture.contained_energy, Entry):
args["contained_energy"] = options.photometric_aperture.contained_energy() args["contained_energy"] = options.photometric_aperture.contained_energy()
if hasattr(options.photometric_aperture, "contained_pixels") and isinstance( if hasattr(options.photometric_aperture, "aperture_size") and isinstance(
options.photometric_aperture.contained_pixels, Entry): options.photometric_aperture.aperture_size, Entry):
args["contained_pixels"] = options.photometric_aperture.contained_pixels() args["aperture_size"] = options.photometric_aperture.aperture_size()
return Imager(**args) return Imager(**args)
elif options.type == "Heterodyne": elif options.type == "Heterodyne":
args = dict(parent=self.__parent, aperture_efficiency=options.aperture_efficiency(), args = dict(parent=self.__parent, aperture_efficiency=options.aperture_efficiency(),

View File

@ -54,7 +54,7 @@
<photometric_aperture comment="The photometric aperture used to calculate signal and noise."> <photometric_aperture comment="The photometric aperture used to calculate signal and noise.">
<shape val="square" comment="Shape of the photometric aperture. Can be square / circle"/> <shape val="square" comment="Shape of the photometric aperture. Can be square / circle"/>
<contained_energy val="min" comment="Contained energy for calculating the SNR. Can be Peak, FWHM, Min or the percentage of encircled energy."/> <contained_energy val="min" comment="Contained energy for calculating the SNR. Can be Peak, FWHM, Min or the percentage of encircled energy."/>
<!-- <contained_pixels val="20" val_unit="pix" comment="Number of contained pixels."/>--> <!-- <aperture_size val="20" val_unit="pix" comment="Number of contained pixels."/>-->
</photometric_aperture> </photometric_aperture>
</sensor> </sensor>
</instrument> </instrument>

View File

@ -16,7 +16,7 @@ class TestImager(TestCase):
pixel_size=6.5 * u.um, read_noise=1.4 * u.electron ** 0.5 / u.pix, 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, 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, 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.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.zodiac = StrayLight(self.target, "tests/data/straylight/zodiacal_emission_1.csv")
self.imager = Imager(self.zodiac, **self.imager_args) self.imager = Imager(self.zodiac, **self.imager_args)