Coverage for python/lsst/sims/maf/batches/altazBatch.py : 17%

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 lsst.sims.maf.metrics as metrics
2import lsst.sims.maf.slicers as slicers
3import lsst.sims.maf.metricBundles as mb
4import lsst.sims.maf.plots as plots
5from .colMapDict import ColMapDict
6from .common import filterList
8__all__ = ['altazHealpix', 'altazLambert']
11def basicSetup(metricName, colmap=None, nside=64):
13 if colmap is None:
14 colmap = ColMapDict('opsimV4')
16 slicer = slicers.HealpixSlicer(nside=nside, latCol=colmap['alt'], lonCol=colmap['az'],
17 latLonDeg=colmap['raDecDeg'], useCache=False)
18 metric = metrics.CountMetric(colmap['mjd'], metricName=metricName)
20 return colmap, slicer, metric
23def altazHealpix(colmap=None, runName='opsim', extraSql=None,
24 extraMetadata=None, metricName='NVisits Alt/Az'):
26 """Generate a set of metrics measuring the number visits as a function of alt/az
27 plotted on a HealpixSkyMap.
29 Parameters
30 ----------
31 colmap : dict, opt
32 A dictionary with a mapping of column names. Default will use OpsimV4 column names.
33 runName : str, opt
34 The name of the simulated survey. Default is "opsim".
35 extraSql : str, opt
36 Additional constraint to add to any sql constraints (e.g. 'propId=1' or 'fieldID=522').
37 Default None, for no additional constraints.
38 extraMetadata : str, opt
39 Additional metadata to add before any below (i.e. "WFD"). Default is None.
40 metricName : str, opt
41 Unique name to assign to metric
43 Returns
44 -------
45 metricBundleDict
46 """
48 colmap, slicer, metric = basicSetup(metricName=metricName, colmap=colmap)
50 # Set up basic all and per filter sql constraints.
51 filterlist, colors, orders, sqls, metadata = filterList(all=True,
52 extraSql=extraSql,
53 extraMetadata=extraMetadata)
55 bundleList = []
57 plotDict = {'rot': (90, 90, 90), 'flip': 'geo'}
58 plotFunc = plots.HealpixSkyMap()
60 for f in filterlist:
61 if f == 'all':
62 subgroup = 'All Observations'
63 else:
64 subgroup = 'Per filter'
65 displayDict = {'group': 'Alt/Az', 'order': orders[f], 'subgroup': subgroup,
66 'caption':
67 'Pointing History on the alt-az sky (zenith center) for filter %s' % f}
68 bundle = mb.MetricBundle(metric, slicer, sqls[f], plotDict=plotDict,
69 runName=runName, metadata = metadata[f],
70 plotFuncs=[plotFunc], displayDict=displayDict)
71 bundleList.append(bundle)
73 for b in bundleList:
74 b.setRunName(runName)
75 return mb.makeBundlesDictFromList(bundleList)
78def altazLambert(colmap=None, runName='opsim', extraSql=None,
79 extraMetadata=None, metricName='Nvisits as function of Alt/Az'):
81 """Generate a set of metrics measuring the number visits as a function of alt/az
82 plotted on a LambertSkyMap.
84 Parameters
85 ----------
86 colmap : dict, opt
87 A dictionary with a mapping of column names. Default will use OpsimV4 column names.
88 runName : str, opt
89 The name of the simulated survey. Default is "opsim".
90 extraSql : str, opt
91 Additional constraint to add to any sql constraints (e.g. 'propId=1' or 'fieldID=522').
92 Default None, for no additional constraints.
93 extraMetadata : str, opt
94 Additional metadata to add before any below (i.e. "WFD"). Default is None.
95 metricName : str, opt
96 Unique name to assign to metric
98 Returns
99 -------
100 metricBundleDict
101 """
103 colmap, slicer, metric = basicSetup(metricName=metricName, colmap=colmap)
105 # Set up basic all and per filter sql constraints.
106 filterlist, colors, orders, sqls, metadata = filterList(all=True,
107 extraSql=extraSql,
108 extraMetadata=extraMetadata)
110 bundleList = []
112 plotFunc = plots.LambertSkyMap()
114 for f in filterlist:
115 if f == 'all':
116 subgroup = 'All Observations'
117 else:
118 subgroup = 'Per filter'
119 displayDict = {'group': 'Alt/Az', 'order': orders[f], 'subgroup': subgroup,
120 'caption':
121 'Alt/Az pointing distribution for filter %s' % f}
122 bundle = mb.MetricBundle(metric, slicer, sqls[f],
123 runName=runName, metadata = metadata[f],
124 plotFuncs=[plotFunc], displayDict=displayDict)
125 bundleList.append(bundle)
127 for b in bundleList:
128 b.setRunName(runName)
129 return mb.makeBundlesDictFromList(bundleList)