Coverage for python/lsst/sims/maf/metrics/calibrationMetrics.py : 86%

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
'ParallaxCoverageMetric', 'ParallaxDcrDegenMetric']
"""Calculate the uncertainty in a parallax measurement given a series of observations.
Uses columns ra_pi_amp and dec_pi_amp, calculated by the ParallaxFactorStacker.
Parameters ---------- metricName : str, opt Default 'parallax'. m5Col : str, opt The default column name for m5 information in the input data. Default fiveSigmaDepth. filterCol : str, opt The column name for the filter information. Default filter. seeingCol : str, opt The column name for the seeing information. Since the astrometry errors are based on the physical size of the PSF, this should be the FWHM of the physical psf. Default seeingFwhmGeom. rmag : float, opt The r magnitude of the fiducial star in r band. Other filters are sclaed using sedTemplate keyword. Default 20.0 SedTemplate : str, opt The template to use. This can be 'flat' or 'O','B','A','F','G','K','M'. Default flat. atm_err : float, opt The expected centroiding error due to the atmosphere, in arcseconds. Default 0.01. normalize : boolean, opt Compare the astrometric uncertainty to the uncertainty that would result if half the observations were taken at the start and half at the end. A perfect survey will have a value close to 1, while a poorly scheduled survey will be close to 0. Default False. badval : float, opt The value to return when the metric value cannot be calculated. Default -666. """ filterCol='filter', seeingCol='seeingFwhmGeom', rmag=20., SedTemplate='flat', badval=-666, atm_err=0.01, normalize=False, **kwargs): else: badval=badval, **kwargs) # set return type else: self.mags = utils.stellarMags(SedTemplate, rmag=rmag) '(assuming no proper motion or that proper motion ' 'and estimates astrometric error based on SNR ' 'estimated uncertainty in the parallax measurement, ' '(if all visits were six ' 'scheduling for parallax measurement.'
"""Assume parallax in RA and DEC are fit independently, then combined. All inputs assumed to be arcsec """ # Combine RA and Dec uncertainties, convert to mas
filters = [str(f.decode('utf-8')) for f in filters] # compute SNR for all observations snr)**2+self.atm_err**2) # Leave the dec parallax as zero since one can't have ra and dec maximized at the same time. dataslice['ra_pi_amp']*0+1., dataslice['dec_pi_amp']*0)/sigma
"""Calculate the uncertainty in the returned proper motion.
This metric assumes gaussian errors in the astrometry measurements.
Parameters ---------- metricName : str, opt Default 'properMotion'. m5Col : str, opt The default column name for m5 information in the input data. Default fiveSigmaDepth. mjdCol : str, opt The column name for the exposure time. Default observationStartMJD. filterCol : str, opt The column name for the filter information. Default filter. seeingCol : str, opt The column name for the seeing information. Since the astrometry errors are based on the physical size of the PSF, this should be the FWHM of the physical psf. Default seeingFwhmGeom. rmag : float, opt The r magnitude of the fiducial star in r band. Other filters are sclaed using sedTemplate keyword. Default 20.0 SedTemplate : str, opt The template to use. This can be 'flat' or 'O','B','A','F','G','K','M'. Default flat. atm_err : float, opt The expected centroiding error due to the atmosphere, in arcseconds. Default 0.01. normalize : boolean, opt Compare the astrometric uncertainty to the uncertainty that would result if half the observations were taken at the start and half at the end. A perfect survey will have a value close to 1, while a poorly scheduled survey will be close to 0. Default False. baseline : float, opt The length of the survey used for the normalization, in years. Default 10. badval : float, opt The value to return when the metric value cannot be calculated. Default -666. """ m5Col='fiveSigmaDepth', mjdCol='observationStartMJD', filterCol='filter', seeingCol='seeingFwhmGeom', rmag=20., SedTemplate='flat', badval= -666, atm_err=0.01, normalize=False, baseline=10., **kwargs): else: badval=badval, **kwargs) # set return type else: self.mags = utils.stellarMags(SedTemplate, rmag=rmag) '(assuming no parallax or that parallax is well fit). ' 'astrometric errors using the SNR in each visit. ' 'the estimated uncertainty in the proper ' '(if all visits were '
precis[observations] = self.badval else: dataslice[self.m5Col][observations]) dataslice[self.seeingCol][observations], snr) # Observations that are very close together can still fail result = self.badval
""" Check how well the parallax factor is distributed. Subtracts the weighted mean position of the parallax offsets, then computes the weighted mean radius of the points. If points are well distributed, the mean radius will be near 1. If phase coverage is bad, radius will be close to zero.
For points on the Ecliptic, uniform sampling should result in a metric value of ~0.5. At the poles, uniform sampling would result in a metric value of ~1. Conceptually, it is helpful to remember that the parallax motion of a star at the pole is a (nearly circular) ellipse while the motion of a star on the ecliptic is a straight line. Thus, any pair of observations separated by 6 months will give the full parallax range for a star on the pole but only observations on very specific dates will give the full range for a star on the ecliptic.
Optionally also demand that there are observations above the snrLimit kwarg spanning thetaRange radians.
Parameters ---------- m5Col: str, opt Column name for individual visit m5. Default fiveSigmaDepth. mjdCol: str, opt Column name for exposure time dates. Default observationStartMJD. filterCol: str, opt Column name for filter. Default filter. seeingCol: str, opt Column name for seeing (assumed FWHM). Default seeingFwhmGeom. rmag: float, opt Magnitude of fiducial star in r filter. Other filters are scaled using sedTemplate keyword. Default 20.0 sedTemplate: str, opt Template to use (can be 'flat' or 'O','B','A','F','G','K','M'). Default 'flat'. atm_err: float, opt Centroiding error due to atmosphere in arcsec. Default 0.01 (arcseconds). thetaRange: float, opt Range of parallax offset angles to demand (in radians). Default=0 (means no range requirement). snrLimit: float, opt Only include points above the snrLimit when computing thetaRange. Default 5.
Returns -------- metricValue: float Returns a weighted mean of the length of the parallax factor vectors. Values near 1 imply that the points are well distributed. Values near 0 imply that the parallax phase coverage is bad. Near the ecliptic, uniform sampling results in metric values of about 0.5.
Notes ----- Uses the ParallaxFactor stacker to calculate ra_pi_amp and dec_pi_amp. """ mjdCol='observationStartMJD', filterCol='filter', seeingCol='seeingFwhmGeom', rmag=20., SedTemplate='flat', atm_err=0.01, thetaRange=0., snrLimit=5, **kwargs): metricName=metricName, units=units, **kwargs)
# Demand the range of theta values
else: self.mags = utils.stellarMags(SedTemplate, rmag=rmag)
good = np.where(snr >= self.snrLimit) theta = np.arctan2(dec_pi_amp[good], ra_pi_amp[good]) # Make values between 0 and 2pi theta = theta-np.min(theta) result = 0. if np.max(theta) >= self.thetaRange: # Check that things are in differnet quadrants theta = (theta+np.pi) % 2.*np.pi theta = theta-np.min(theta) if np.max(theta) >= self.thetaRange: result = 1 return result
# Compute centroid uncertainty in each visit snr)**2+self.atm_err**2)
return self.badval
# compute SNR for all observations
thetaCheck = self._thetaCheck(dataSlice['ra_pi_amp'], dataSlice['dec_pi_amp'], snr) else:
"""Use the full parallax and DCR displacement vectors to find if they are degenerate.
Parameters ---------- metricName : str, opt Default 'ParallaxDcrDegenMetric'. seeingCol : str, opt Default 'FWHMgeom' m5Col : str, opt Default 'fiveSigmaDepth' filterCol : str Default 'filter' atm_err : float Minimum error in photometry centroids introduced by the atmosphere (arcseconds). Default 0.01. rmag : float r-band magnitude of the fiducual star that is being used (mag). SedTemplate : str The SED template to use for fiducia star colors, passed to lsst.sims.utils.stellarMags. Default 'flat' tol : float Tolerance for how well curve_fit needs to work before believing the covariance result. Default 0.05.
Returns ------- metricValue : float Returns the correlation coefficient between the best-fit parallax amplitude and DCR amplitude. The RA and Dec offsets are fit simultaneously. Values close to zero are good, values close to +/- 1 are bad. Experience with fitting Monte Carlo simulations suggests the astrometric fits start becoming poor around a correlation of 0.7. """ m5Col='fiveSigmaDepth', atm_err=0.01, rmag=20., SedTemplate='flat', filterCol='filter', tol=0.05, **kwargs): # just put all the columns that all the stackers will need here? seeingCol, m5Col] **kwargs) else: self.mags = utils.stellarMags(SedTemplate, rmag=rmag)
""" Function to find parallax and dcr amplitudes
x should be a vector with [[parallax_x1, parallax_x2..., parallax_y1, parallax_y2...], [dcr_x1, dcr_x2..., dcr_y1, dcr_y2...]] """
# The idea here is that we calculate position errors (in RA and Dec) for all observations. # Then we generate arrays of the parallax offsets (delta RA parallax = ra_pi_amp, etc) # and the DCR offsets (delta RA DCR = ra_dcr_amp, etc), and just add them together into one # RA (and Dec) offset. Then, we try to fit for how we combined these offsets, but while # considering the astrometric noise. If we can figure out that we just added them together # (i.e. the curve_fit result is [a=1, b=1] for the function _positions above) # then we should be able to disentangle the parallax and DCR offsets when fitting 'for real'. # compute SNR for all observations # 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. self.atm_err**2) # Construct the vectors of RA/Dec offsets. xdata is the "input data". ydata is the "output". # Use curve_fit to compute covariance between parallax and dcr amplitudes # Set the initial guess slightly off from the correct [1,1] to make sure it iterates. sigma=np.concatenate((position_errors, position_errors)), absolute_sigma=True) # Catch if the fit failed to converge on the correct solution. return self.badval # Covariance between best fit parallax amplitude and DCR amplitude. # Convert covarience between parallax and DCR amplitudes to normalized correlation # This can throw infs. result = self.badval
# Taken from simSelfCalib.py """Calculates distance on a sphere using spherical law of cosines.
Give this function RA/Dec values in radians. Returns angular distance(s), in radians. Note that since this is all numpy, you could input arrays of RA/Decs.""" # This formula can have rounding errors for case where distances are small. # Oh, the joys of wikipedia - http://en.wikipedia.org/wiki/Great-circle_distance # For the purposes of these calculations, this is probably accurate enough.
"""find the radius in the focal plane. returns things in degrees."""
units='radians', **kwargs): metricName=metricName, units=units, **kwargs)
np.radians(dataSlice[self.decCol]))
|