From 0bb3e429af95980364a9e625a1583b65b76907ec Mon Sep 17 00:00:00 2001 From: Lee Spitler Date: Sun, 22 Nov 2020 08:04:43 +1100 Subject: [PATCH] added functionality --- gunagala/imager.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/gunagala/imager.py b/gunagala/imager.py index 50b9fcd..6bcd7b5 100644 --- a/gunagala/imager.py +++ b/gunagala/imager.py @@ -511,7 +511,7 @@ def extended_source_etc(self, surface_brightness, filter_name, snr_target, sub_e snr_target : astropy.units.Quantity The desired signal to noise ratio, dimensionless unscaled units sub_exp_time : astropy.units.Quantity - length of individual sub-exposures + length of individual sub-exposures, or None if no sub-exposures are needed calc_type : {'per pixel', 'per arcsecond squared'} Calculation type, either signal to noise ratio per pixel or signal to noise ratio per arcsecond^2. Default is 'per pixel' @@ -563,7 +563,12 @@ def extended_source_etc(self, surface_brightness, filter_name, snr_target, sub_e # Measuring the sky background itself. rate = self.sky_rate[filter_name] - sub_exp_time = ensure_unit(sub_exp_time, u.second) + if sub_exp_time is None: + no_sub_exp_time = True + sub_exp_time = 1 * u.second + else: + sub_exp_time = ensure_unit(sub_exp_time, u.second) + no_sub_exp_time = False # If required total exposure time is much greater than the length of a sub-exposure then # all noise sources (including read noise) are proportional to t^0.5 and we can use a @@ -582,6 +587,9 @@ def extended_source_etc(self, surface_brightness, filter_name, snr_target, sub_e noise_squared_rate = noise_squared_rate.to(u.electron**2 / (u.pixel**2 * u.second)) total_exp_time = (snr_target**2 * noise_squared_rate / rate**2).to(u.second) + if no_sub_exp_time: + sub_exp_time = total_exp_time + # Now just round up to the next integer number of sub-exposures, being careful because the total_exp_time # and/or sub_exp_time could be Quantity arrays instead of scalars. The simplified expression above is exact # for integer numbers of sub exposures and signal to noise ratio monotonically increases with exposure time @@ -1061,7 +1069,7 @@ def point_source_etc(self, brightness, filter_name, snr_target, sub_exp_time, sa snr_target : astropy.units.Quantity The desired signal to noise ratio, dimensionless unscaled units sub_exp_time : astropy.units.Quantity - length of individual sub-exposures + length of individual sub-exposures, or None if no sub-exposures are needed saturation_check : bool, optional If `True` will set the exposure time to zero where the electrons per pixel in a single sub-exposure exceed the @@ -1087,6 +1095,9 @@ def point_source_etc(self, brightness, filter_name, snr_target, sub_exp_time, sa total_exp_time = self.extended_source_etc(rate / self.psf.n_pix, filter_name, snr_target, sub_exp_time, saturation_check=False, binning=self.psf.n_pix / u.pixel) + if sub_exp_time is None: + sub_exp_time = total_exp_time + # Saturation check. For point sources need to know maximum fraction of total electrons that will end up # in a single pixel, this is available as psf.peak. Can use this to calculate maximum electrons per pixel # in a single sub exposure, and check against saturation_level.