Hide keyboard shortcuts

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 

2from .baseMetric import BaseMetric 

3import lsst.sims.maf.utils as mafUtils 

4import lsst.sims.utils as utils 

5 

6 

7__all__ = ['DcrPrecisionMetric'] 

8 

9 

10class DcrPrecisionMetric(BaseMetric): 

11 """Determine how precise a DCR correction could be made 

12 

13 Parameters 

14 ---------- 

15 atm_err : float 

16 Minimum error in photometry centroids introduced by the atmosphere (arcseconds). Default 0.01. 

17 """ 

18 

19 def __init__(self, metricName='DCRprecision', seeingCol='seeingFwhmGeom', 

20 m5Col='fiveSigmaDepth', HACol='HA', PACol='paraAngle', 

21 filterCol='filter', atm_err=0.01, SedTemplate='flat', 

22 rmag=20., **kwargs): 

23 

24 self.m5Col = m5Col 

25 self.filterCol = filterCol 

26 self.PACol = PACol 

27 self.seeingCol = seeingCol 

28 self.mags = {} 

29 self.filters = ['u', 'g', 'r', 'i', 'z', 'y'] 

30 if SedTemplate == 'flat': 

31 for f in self.filters: 

32 self.mags[f] = rmag 

33 else: 

34 self.mags = utils.stellarMags(SedTemplate, rmag=rmag) 

35 cols = ['ra_dcr_amp', 'dec_dcr_amp', seeingCol, m5Col, filterCol, 'zenithDistance', PACol] 

36 units = 'arcseconds' 

37 self.atm_err = atm_err 

38 super(DcrPrecisionMetric, self).__init__(cols, metricName=metricName, units=units, 

39 **kwargs) 

40 

41 def run(self, dataSlice, slicePoint=None): 

42 

43 snr = np.zeros(len(dataSlice), dtype='float') 

44 for filt in self.filters: 

45 inFilt = np.where(dataSlice[self.filterCol] == filt) 

46 snr[inFilt] = mafUtils.m52snr(self.mags[filt], dataSlice[self.m5Col][inFilt]) 

47 

48 position_errors = np.sqrt(mafUtils.astrom_precision(dataSlice[self.seeingCol], snr)**2 + 

49 self.atm_err**2) 

50 

51 x_coord = np.tan(dataSlice['zenithDistance'])*np.sin(dataSlice[self.PACol]) 

52 # Things should be the same for RA and dec. 

53 # Now I want to compute the error if I interpolate/extrapolate to +/-1. 

54 

55 # function is of form, y=ax. a=y/x. da = dy/x. 

56 # Only strictly true if we know the unshifted position. But this should be a reasonable approx. 

57 slope_uncerts = position_errors/x_coord 

58 total_slope_uncert = 1./np.sqrt(np.sum(1./slope_uncerts**2)) 

59 

60 # So, this will be the uncertainty in the RA or Dec offset at x= +/- 1. 

61 result = total_slope_uncert 

62 

63 return result