Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modified ETCs so a sub exposure time is not required #44

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions gunagala/imager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down