Skip to content

Commit

Permalink
make astrom_precision and m2snr more backwards compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
rhiannonlynne committed Sep 18, 2023
1 parent 91ba6a0 commit 6bb799b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 deletions.
4 changes: 1 addition & 3 deletions rubin_sim/maf/metrics/brown_dwarf_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,7 @@ def run(self, data_slice, slice_point=None):
self.mags[str(filt)][:, np.newaxis], data_slice[self.m5_col][good]
)

position_errors = np.sqrt(
mafUtils.astrom_precision(data_slice[self.seeing_col], snr) ** 2 + self.atm_err**2
)
position_errors = mafUtils.astrom_precision(data_slice[self.seeing_col], snr, self.atm_err)
# uncertainty in the parallax in mas
sigma = self._final_sigma(position_errors, data_slice["ra_pi_amp"], data_slice["dec_pi_amp"])
fitted_parallax_snr = self.parallaxes / sigma
Expand Down
11 changes: 3 additions & 8 deletions rubin_sim/maf/metrics/calibration_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,8 @@ def run(self, data_slice, slice_point=None):
else:
snr = mafUtils.m52snr(self.mags[f], data_slice[self.m5_col][observations])
precis[observations] = mafUtils.astrom_precision(
data_slice[self.seeing_col][observations], snr
data_slice[self.seeing_col][observations], snr, self.atm_err
)
precis[observations] = np.sqrt(precis[observations] ** 2 + self.atm_err**2)
good = np.where(precis != self.badval)
result = mafUtils.sigma_slope(data_slice[self.mjd_col][good], precis[good])
result = result * 365.25 * 1e3 # Convert to mas/yr
Expand Down Expand Up @@ -364,9 +363,7 @@ def _theta_check(self, ra_pi_amp, dec_pi_amp, snr):

def _compute_weights(self, data_slice, snr):
# Compute centroid uncertainty in each visit
position_errors = np.sqrt(
mafUtils.astrom_precision(data_slice[self.seeing_col], snr) ** 2 + self.atm_err**2
)
position_errors = mafUtils.astrom_precision(data_slice[self.seeing_col], snr, self.atm_err)
weights = 1.0 / position_errors**2
return weights

Expand Down Expand Up @@ -493,9 +490,7 @@ def run(self, data_slice, slice_point=None):
# Compute the centroiding uncertainties
# Note that these centroiding uncertainties depend on the physical size of the PSF, thus
# we are using seeingFwhmGeom for these metrics, not seeingFwhmEff.
position_errors = np.sqrt(
mafUtils.astrom_precision(data_slice[self.seeing_col], snr) ** 2 + self.atm_err**2
)
position_errors = mafUtils.astrom_precision(data_slice[self.seeing_col], snr, self.atm_err)
# Construct the vectors of RA/Dec offsets. xdata is the "input data". ydata is the "output".
xdata = np.empty((2, data_slice.size * 2), dtype=float)
xdata[0, :] = np.concatenate((data_slice["ra_pi_amp"], data_slice["dec_pi_amp"]))
Expand Down
17 changes: 9 additions & 8 deletions rubin_sim/maf/utils/astrometry_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def sigma_slope(x, sigma_y):
return result


def m52snr(m, m5):
def m52snr(m, m5, gamma=0.039):
"""
Calculate the SNR for a star of magnitude m in an
observation with 5-sigma limiting magnitude depth m5.
Expand All @@ -52,14 +52,13 @@ def m52snr(m, m5):
snr : `float` or `np.ndarray` (N,)
The SNR
"""
# gamma varies per band, but is fairly close to this value
rgamma = 0.039
# gamma varies per band, but is fairly close to 0.039 or 0.04
xval = np.power(10, 0.4 * (m - m5))
snr = 1 / np.sqrt((0.04 - rgamma) * xval + rgamma * xval * xval)
snr = 1 / np.sqrt((0.04 - gamma) * xval + gamma * xval * xval)
return snr


def astrom_precision(fwhm, snr, systematic_floor=0.01):
def astrom_precision(fwhm, snr, systematic_floor=0.00):
"""
Calculate the approximate precision of astrometric measurements,
given a particular seeing and SNR value.
Expand All @@ -71,12 +70,14 @@ def astrom_precision(fwhm, snr, systematic_floor=0.01):
snr : float` or `np.ndarray` (N,)
The SNR of the object.
systematic_floor : `float`
Systematic noise floor for astrometric error.
Systematic noise floor for astrometric error, in arcseconds.
Default here is 0, for backwards compatibility.
General Rubin use should be 0.01.
Returns
-------
astrp,+err " `float` or `numpy.ndarray` (N,)
The astrometric precision.
astrom_err : `float` or `numpy.ndarray` (N,)
The astrometric precision, in arcseconds.
"""
astrom_err = np.sqrt((fwhm / snr) ** 2 + systematic_floor**2)
return astrom_err

0 comments on commit 6bb799b

Please sign in to comment.