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

import numpy as np 

import matplotlib.pyplot as plt 

 

from .plotHandler import BasePlotter 

 

__all__ = ['NightPointingPlotter'] 

 

 

class NightPointingPlotter(BasePlotter): 

 

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

 

# Just call it Hourglass so it gets treated the same way 

self.plotType = 'Hourglass' 

self.mjdCol = mjdCol 

self.altCol = altCol 

self.azCol = azCol 

self.objectPlotter = True 

self.defaultPlotDict = {'title': None, 'xlabel': 'MJD', 

'ylabels': ['Alt', 'Az']} 

self.filter2color = {'u': 'purple', 'g': 'blue', 'r': 'green', 

'i': 'cyan', 'z': 'orange', 'y': 'red'} 

 

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

 

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

mv = metricValue[0] 

 

u_filters = np.unique(mv['dataSlice']['filter']) 

for filt in u_filters: 

good = np.where(mv['dataSlice']['filter'] == filt) 

ax1.plot(mv['dataSlice'][self.mjdCol][good], 

mv['dataSlice'][self.altCol][good], 

'o', color=self.filter2color[filt], markersize=5, alpha=.5) 

ax2.plot(mv['dataSlice'][self.mjdCol][good], 

mv['dataSlice'][self.azCol][good], 

'o', color=self.filter2color[filt], markersize=5, alpha=.5) 

 

good = np.where(np.degrees(mv['moon_alts']) > -10.) 

ax1.plot(mv['mjds'][good], np.degrees(mv['moon_alts'][good]), 'ko', markersize=3, alpha=.1) 

ax2.plot(mv['mjds'][good], np.degrees(mv['moon_azs'][good]), 'ko', markersize=3, alpha=.1) 

ax2.set_xlabel('MJD') 

ax1.set_ylabel('Altitude (deg)') 

ax2.set_ylabel('Azimuth (deg)') 

 

good = np.where(np.degrees(mv['sun_alts']) > -20.) 

ax1.plot(mv['mjds'][good], np.degrees(mv['sun_alts'][good]), 'yo', markersize=3) 

ax2.plot(mv['mjds'][good], np.degrees(mv['sun_azs'][good]), 'yo', markersize=3) 

 

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

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

 

for i, key in enumerate(['u', 'g', 'r', 'i', 'z', 'y']): 

ax1.text(1.05, .9 - i * 0.07, key, color=self.filter2color[key], transform=ax1.transAxes) 

 

return fig.number