Coverage for python/lsst/sims/maf/plots/nightPointingPlotter.py : 18%

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
2import matplotlib.pyplot as plt
4from .plotHandler import BasePlotter
6__all__ = ['NightPointingPlotter']
9class NightPointingPlotter(BasePlotter):
11 def __init__(self, mjdCol='observationStartMJD', altCol='alt', azCol='az'):
13 # Just call it Hourglass so it gets treated the same way
14 self.plotType = 'Hourglass'
15 self.mjdCol = mjdCol
16 self.altCol = altCol
17 self.azCol = azCol
18 self.objectPlotter = True
19 self.defaultPlotDict = {'title': None, 'xlabel': 'MJD',
20 'ylabels': ['Alt', 'Az']}
21 self.filter2color = {'u': 'purple', 'g': 'blue', 'r': 'green',
22 'i': 'cyan', 'z': 'orange', 'y': 'red'}
24 def __call__(self, metricValue, slicer, userPlotDict, fignum=None):
26 fig, (ax1, ax2) = plt.subplots(2, sharex=True)
27 mv = metricValue[0]
29 u_filters = np.unique(mv['dataSlice']['filter'])
30 for filt in u_filters:
31 good = np.where(mv['dataSlice']['filter'] == filt)
32 ax1.plot(mv['dataSlice'][self.mjdCol][good],
33 mv['dataSlice'][self.altCol][good],
34 'o', color=self.filter2color[filt], markersize=5, alpha=.5)
35 ax2.plot(mv['dataSlice'][self.mjdCol][good],
36 mv['dataSlice'][self.azCol][good],
37 'o', color=self.filter2color[filt], markersize=5, alpha=.5)
39 good = np.where(np.degrees(mv['moon_alts']) > -10.)
40 ax1.plot(mv['mjds'][good], np.degrees(mv['moon_alts'][good]), 'ko', markersize=3, alpha=.1)
41 ax2.plot(mv['mjds'][good], np.degrees(mv['moon_azs'][good]), 'ko', markersize=3, alpha=.1)
42 ax2.set_xlabel('MJD')
43 ax1.set_ylabel('Altitude (deg)')
44 ax2.set_ylabel('Azimuth (deg)')
46 good = np.where(np.degrees(mv['sun_alts']) > -20.)
47 ax1.plot(mv['mjds'][good], np.degrees(mv['sun_alts'][good]), 'yo', markersize=3)
48 ax2.plot(mv['mjds'][good], np.degrees(mv['sun_azs'][good]), 'yo', markersize=3)
50 ax1.set_ylim([-20., 90.])
51 ax2.set_ylim([0., 360.])
53 for i, key in enumerate(['u', 'g', 'r', 'i', 'z', 'y']):
54 ax1.text(1.05, .9 - i * 0.07, key, color=self.filter2color[key], transform=ax1.transAxes)
56 return fig.number