Coverage for python/lsst/sims/maf/utils/astrometryUtils.py : 29%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1import numpy as np
2"""Some simple functions that are useful for astrometry calculations. """
4__all__ = ['sigma_slope', 'm52snr', 'astrom_precision']
6def sigma_slope(x, sigma_y):
7 """
8 Calculate the uncertainty in fitting a line, as
9 given by the spread in x values and the uncertainties
10 in the y values.
12 Parameters
13 ----------
14 x : numpy.ndarray
15 The x values of the data
16 sigma_y : numpy.ndarray
17 The uncertainty in the y values
19 Returns
20 -------
21 float
22 The uncertainty in the line fit
23 """
24 w = 1./sigma_y**2
25 denom = np.sum(w)*np.sum(w*x**2)-np.sum(w*x)**2
26 if denom <= 0:
27 return np.nan
28 else:
29 result = np.sqrt(np.sum(w)/denom )
30 return result
32def m52snr(m, m5):
33 """
34 Calculate the SNR for a star of magnitude m in an
35 observation with 5-sigma limiting magnitude depth m5.
36 Assumes gaussian distribution of photons and might not be
37 strictly due in bluer filters. See table 2 and equation 5
38 in astroph/0805.2366.
40 Parameters
41 ----------
42 m : float or numpy.ndarray
43 The magnitude of the star
44 m5 : float or numpy.ndarray
45 The m5 limiting magnitude of the observation
47 Returns
48 -------
49 float or numpy.ndarray
50 The SNR
51 """
52 snr = 5.*10.**(-0.4*(m-m5))
53 return snr
55def astrom_precision(fwhm, snr):
56 """
57 Calculate the approximate precision of astrometric measurements,
58 given a particular seeing and SNR value.
60 Parameters
61 ----------
62 fwhm : float or numpy.ndarray
63 The seeing (FWHMgeom) of the observation.
64 snr : float or numpy.ndarray
65 The SNR of the object.
67 Returns
68 -------
69 float or numpy.ndarray
70 The astrometric precision.
71 """
72 result = fwhm/(snr)
73 return result