Coverage for python/lsst/sims/maf/batches/skycoverage.py : 8%

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"""Evaluate some bulk properties of the sky coverage
2"""
3import numpy as np
4import lsst.sims.maf.metrics as metrics
5import lsst.sims.maf.slicers as slicers
6import lsst.sims.maf.metricBundles as mb
7from .colMapDict import ColMapDict
9__all__ = ['meanRADec', 'eastWestBias']
12def meanRADec(colmap=None, runName='opsim', extraSql=None, extraMetadata=None):
13 """Plot the range of RA/Dec as a function of night.
15 Parameters
16 ----------
17 colmap : dict, opt
18 A dictionary with a mapping of column names. Default will use OpsimV4 column names.
19 runName : str, opt
20 The name of the simulated survey. Default is "opsim".
21 extraSql : str, opt
22 Additional constraint to add to any sql constraints (e.g. 'night<365')
23 Default None, for no additional constraints.
24 extraMetadata : str, opt
25 Additional metadata to add before any below (i.e. "WFD"). Default is None.
26 """
27 if colmap is None:
28 colmap = ColMapDict('opsimV4')
29 bundleList = []
30 plotBundles = []
32 group = 'RA Dec coverage'
34 subgroup = 'All visits'
35 if extraMetadata is not None:
36 subgroup = extraMetadata
38 displayDict = {'group': group, 'subgroup': subgroup, 'order': 0}
40 ra_metrics = [metrics.MeanAngleMetric(colmap['ra']), metrics.FullRangeAngleMetric(colmap['ra'])]
41 dec_metrics = [metrics.MeanMetric(colmap['dec']), metrics.MinMetric(colmap['dec']),
42 metrics.MaxMetric(colmap['dec'])]
43 for m in ra_metrics:
44 slicer = slicers.OneDSlicer(sliceColName=colmap['night'], binsize=1)
45 if not colmap['raDecDeg']:
46 plotDict = {'yMin': np.radians(-5), 'yMax': np.radians(365)}
47 else:
48 plotDict = {'yMin': -5, 'yMax': 365}
49 bundle = mb.MetricBundle(m, slicer, extraSql, metadata=extraMetadata,
50 displayDict=displayDict, plotDict=plotDict)
51 bundleList.append(bundle)
53 for m in dec_metrics:
54 slicer = slicers.OneDSlicer(sliceColName=colmap['night'], binsize=1)
55 bundle = mb.MetricBundle(m, slicer, extraSql, metadata=extraMetadata,
56 displayDict=displayDict)
57 bundleList.append(bundle)
59 # Set the runName for all bundles and return the bundleDict.
60 for b in bundleList:
61 b.setRunName(runName)
62 return mb.makeBundlesDictFromList(bundleList), plotBundles
65def eastWestBias(colmap=None, runName='opsim', extraSql=None, extraMetadata=None):
66 """Plot the number of observations to the east vs to the west, per night.
68 Parameters
69 ----------
70 colmap : dict, opt
71 A dictionary with a mapping of column names. Default will use OpsimV4 column names.
72 runName : str, opt
73 The name of the simulated survey. Default is "opsim".
74 extraSql : str, opt
75 Additional constraint to add to any sql constraints (e.g. 'night<365')
76 Default None, for no additional constraints.
77 extraMetadata : str, opt
78 Additional metadata to add before any below (i.e. "WFD"). Default is None.
79 """
80 if colmap is None:
81 colmap = ColMapDict('opsimV4')
82 bundleList = []
83 plotBundles = []
85 group = 'East vs West'
87 subgroup = 'All visits'
88 if extraMetadata is not None:
89 subgroup = extraMetadata
91 displayDict = {'group': group, 'subgroup': subgroup, 'order': 0}
93 eastvswest = 180
94 if not colmap['raDecDeg']:
95 eastvswest = np.radians(eastvswest)
97 displayDict['caption'] = 'Number of visits per night that occur with azimuth <= 180.'
98 if extraSql is not None:
99 displayDict['caption'] += ' With additional sql constraint %s.' % extraSql
100 metric = metrics.CountMetric(colmap['night'], metricName='Nvisits East')
101 slicer = slicers.OneDSlicer(sliceColName=colmap['night'], binsize=1)
102 sql = '%s <= %f' % (colmap['az'], eastvswest)
103 if extraSql is not None:
104 sql = '(%s) and (%s)' % (sql, extraSql)
105 plotDict = {'color': 'orange', 'label': 'East'}
106 bundle = mb.MetricBundle(metric, slicer, sql, metadata=extraMetadata,
107 displayDict=displayDict, plotDict=plotDict)
108 bundleList.append(bundle)
110 displayDict['caption'] = 'Number of visits per night that occur with azimuth > 180.'
111 if extraSql is not None:
112 displayDict['caption'] += ' With additional sql constraint %s.' % extraSql
113 metric = metrics.CountMetric(colmap['night'], metricName='Nvisits West')
114 slicer = slicers.OneDSlicer(sliceColName=colmap['night'], binsize=1)
115 sql = '%s > %f' % (colmap['az'], eastvswest)
116 if extraSql is not None:
117 sql = '(%s) and (%s)' % (sql, extraSql)
118 plotDict = {'color': 'blue', 'label': 'West'}
119 bundle = mb.MetricBundle(metric, slicer, sql, metadata=extraMetadata,
120 displayDict=displayDict, plotDict=plotDict)
121 bundleList.append(bundle)
123 # Set the runName for all bundles and return the bundleDict.
124 for b in bundleList:
125 b.setRunName(runName)
126 return mb.makeBundlesDictFromList(bundleList), plotBundles