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

1import numpy as np 

2import matplotlib.pyplot as plt 

3 

4from .plotHandler import BasePlotter 

5 

6__all__ = ['NightPointingPlotter'] 

7 

8 

9class NightPointingPlotter(BasePlotter): 

10 

11 def __init__(self, mjdCol='observationStartMJD', altCol='alt', azCol='az'): 

12 

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'} 

23 

24 def __call__(self, metricValue, slicer, userPlotDict, fignum=None): 

25 

26 fig, (ax1, ax2) = plt.subplots(2, sharex=True) 

27 mv = metricValue[0] 

28 

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) 

38 

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)') 

45 

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) 

49 

50 ax1.set_ylim([-20., 90.]) 

51 ax2.set_ylim([0., 360.]) 

52 

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) 

55 

56 return fig.number