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

1from builtins import zip 

2from builtins import object 

3from .baseStacker import BaseStacker 

4 

5__all__ = ['ColInfo'] 

6 

7 

8class ColInfo(object): 

9 """Class to hold the unit and source locations for columns. 

10 

11 The stacker classes which will generate stacker columns are tracked here, as well as 

12 some default units for common opsim columns. 

13 

14 Inspect ColInfo.unitDict for more information.""" 

15 def __init__(self): 

16 self.defaultDataSource = None 

17 self.defaultUnit = '' 

18 self.unitDict = {'fieldId': '#', 

19 'filter': 'filter', 

20 'seqnNum': '#', 

21 'expMJD': 'MJD', 

22 'observationStartMJD': 'MJD', 

23 'observationStartLST': 'deg', 

24 'visitExposureTime': 's', 

25 'slewTime': 's', 

26 'slewDist': 'rad', 

27 'rotSkyPos': 'deg', 

28 'rotTelPos': 'deg', 

29 'rawSeeing': 'arcsec', 

30 'finSeeing': 'arcsec', 

31 'FWHMeff': 'arcsec', 

32 'FWHMgeom': 'arcsec', 

33 'seeingFwhmEff': 'arcsec', 

34 'seeingFwhmGeom': 'arcsec', 

35 'seeingFwhm500': 'arcsec', 

36 'seeing': 'arcsec', 

37 'airmass': 'X', 

38 'night': 'days', 

39 'moonRA': 'rad', 

40 'moonDec': 'rad', 

41 'moonAlt': 'rad', 

42 'dist2Moon': 'rad', 

43 'filtSkyBrightness': 'mag/sq arcsec', 

44 'skyBrightness': 'mag/sq arcsec', 

45 'fiveSigmaDepth': 'mag', 

46 'solarElong': 'degrees'} 

47 # Go through the available stackers and add any units, and identify their 

48 # source methods. 

49 self.sourceDict = {} 

50 for stackerClass in BaseStacker.registry.values(): 

51 stacker = stackerClass() 

52 for col, units in zip(stacker.colsAdded, stacker.units): 

53 self.sourceDict[col] = stackerClass 

54 self.unitDict[col] = units 

55 # Note that a 'unique' list of methods should be built from the resulting returned 

56 # methods, at whatever point the derived data columns will be calculated. (i.e. in the driver) 

57 

58 def getUnits(self, colName): 

59 """Return the appropriate units for colName. 

60 

61 If no units have been defined for a given column, return the default units (''). 

62 

63 Parameters 

64 ---------- 

65 colName : str 

66 The name of the column 

67 

68 Returns 

69 ------- 

70 str 

71 """ 

72 if colName is None or colName not in self.unitDict: 

73 return self.defaultUnit 

74 else: 

75 return self.unitDict[colName] 

76 

77 def getDataSource(self, colName): 

78 """Identify the appropriate source for a given column. 

79 

80 For values which are calculated via a stacker, the returned value is the stacker class. 

81 For values which do not have a recorded source or are known to be coming from the database, the result 

82 is self.defaultDataSource (None), which will be assumed to be queryable from the database. 

83 

84 Parameters 

85 ---------- 

86 colName : str 

87 The name of the column. 

88 

89 Returns 

90 ------- 

91 lsst.sims.maf.stacker or None 

92 """ 

93 if colName in self.sourceDict: 

94 return self.sourceDict[colName] 

95 else: 

96 return self.defaultDataSource