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

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

"""Evaluate some bulk properties of the sky coverage 

""" 

import numpy as np 

import lsst.sims.maf.metrics as metrics 

import lsst.sims.maf.slicers as slicers 

import lsst.sims.maf.metricBundles as mb 

from .colMapDict import ColMapDict 

 

__all__ = ['meanRADec', 'eastWestBias'] 

 

def meanRADec(colmap=None, runName='opsim', extraSql=None, extraMetadata=None): 

"""Plot the range of RA/Dec as a function of night. 

 

Parameters 

---------- 

colmap : dict, opt 

A dictionary with a mapping of column names. Default will use OpsimV4 column names. 

runName : str, opt 

The name of the simulated survey. Default is "opsim". 

extraSql : str, opt 

Additional constraint to add to any sql constraints (e.g. 'night<365') 

Default None, for no additional constraints. 

extraMetadata : str, opt 

Additional metadata to add before any below (i.e. "WFD"). Default is None. 

""" 

if colmap is None: 

colmap = ColMapDict('opsimV4') 

bundleList = [] 

plotBundles = [] 

 

group = 'RA Dec coverage' 

 

subgroup = 'All visits' 

if extraMetadata is not None: 

subgroup = extraMetadata 

 

displayDict = {'group': group, 'subgroup': subgroup, 'order': 0} 

 

ra_metrics = [metrics.MeanAngleMetric(colmap['ra']), metrics.FullRangeAngleMetric(colmap['ra'])] 

dec_metrics = [metrics.MeanMetric(colmap['dec']), metrics.MinMetric(colmap['dec']), 

metrics.MaxMetric(colmap['dec'])] 

for m in ra_metrics: 

slicer = slicers.OneDSlicer(sliceColName=colmap['night'], binsize=1) 

if not colmap['raDecDeg']: 

plotDict = {'yMin': np.radians(-5), 'yMax': np.radians(365)} 

else: 

plotDict = {'yMin': -5, 'yMax': 365} 

bundle = mb.MetricBundle(m, slicer, extraSql, metadata=extraMetadata, 

displayDict=displayDict, plotDict=plotDict) 

bundleList.append(bundle) 

 

for m in dec_metrics: 

slicer = slicers.OneDSlicer(sliceColName=colmap['night'], binsize=1) 

bundle = mb.MetricBundle(m, slicer, extraSql, metadata=extraMetadata, 

displayDict=displayDict) 

bundleList.append(bundle) 

 

# Set the runName for all bundles and return the bundleDict. 

for b in bundleList: 

b.setRunName(runName) 

return mb.makeBundlesDictFromList(bundleList), plotBundles 

 

 

 

def eastWestBias(colmap=None, runName='opsim', extraSql=None, extraMetadata=None): 

"""Plot the number of observations to the east vs to the west, per night. 

 

Parameters 

---------- 

colmap : dict, opt 

A dictionary with a mapping of column names. Default will use OpsimV4 column names. 

runName : str, opt 

The name of the simulated survey. Default is "opsim". 

extraSql : str, opt 

Additional constraint to add to any sql constraints (e.g. 'night<365') 

Default None, for no additional constraints. 

extraMetadata : str, opt 

Additional metadata to add before any below (i.e. "WFD"). Default is None. 

""" 

if colmap is None: 

colmap = ColMapDict('opsimV4') 

bundleList = [] 

plotBundles = [] 

 

group = 'East vs West' 

 

subgroup = 'All visits' 

if extraMetadata is not None: 

subgroup = extraMetadata 

 

displayDict = {'group': group, 'subgroup': subgroup, 'order': 0} 

 

eastvswest = 180 

if not colmap['raDecDeg']: 

eastvswest = np.radians(eastvswest) 

 

displayDict['caption'] = 'Number of visits per night that occur with azimuth <= 180.' 

if extraSql is not None: 

displayDict['caption'] += ' With additional sql constraint %s.' % extraSql 

metric = metrics.CountMetric(colmap['night'], metricName='Nvisits East') 

slicer = slicers.OneDSlicer(sliceColName=colmap['night'], binsize=1) 

sql = '%s <= %f' % (colmap['az'], eastvswest) 

if extraSql is not None: 

sql = '(%s) and (%s)' % (sql, extraSql) 

plotDict = {'color': 'orange', 'label': 'East'} 

bundle = mb.MetricBundle(metric, slicer, sql, metadata=extraMetadata, 

displayDict=displayDict, plotDict=plotDict) 

bundleList.append(bundle) 

 

displayDict['caption'] = 'Number of visits per night that occur with azimuth > 180.' 

if extraSql is not None: 

displayDict['caption'] += ' With additional sql constraint %s.' % extraSql 

metric = metrics.CountMetric(colmap['night'], metricName='Nvisits West') 

slicer = slicers.OneDSlicer(sliceColName=colmap['night'], binsize=1) 

sql = '%s > %f' % (colmap['az'], eastvswest) 

if extraSql is not None: 

sql = '(%s) and (%s)' % (sql, extraSql) 

plotDict = {'color': 'blue', 'label': 'West'} 

bundle = mb.MetricBundle(metric, slicer, sql, metadata=extraMetadata, 

displayDict=displayDict, plotDict=plotDict) 

bundleList.append(bundle) 

 

# Set the runName for all bundles and return the bundleDict. 

for b in bundleList: 

b.setRunName(runName) 

return mb.makeBundlesDictFromList(bundleList), plotBundles