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 

2from .baseMetric import BaseMetric 

3from lsst.sims.utils import Site 

4import ephem 

5 

6 

7__all__ = ['NightPointingMetric'] 

8 

9 

10class NightPointingMetric(BaseMetric): 

11 """ 

12 Gather relevant information for a night to plot. 

13 """ 

14 

15 def __init__(self, altCol='altitude', azCol='azimuth', filterCol='filter', 

16 mjdCol='observationStartMJD', metricName='NightPointing', telescope='LSST', **kwargs): 

17 

18 cols = [altCol, azCol, filterCol, mjdCol] 

19 super(NightPointingMetric, self).__init__(col=cols, metricName=metricName, metricDtype='object', **kwargs) 

20 self.telescope = Site(name=telescope) 

21 self.altCol = altCol 

22 self.azCol = azCol 

23 self.filterCol = filterCol 

24 self.mjdCol = mjdCol 

25 

26 def run(self, dataSlice, slicePoint=None): 

27 

28 lsstObs = ephem.Observer() 

29 lsstObs.lat = self.telescope.latitude_rad 

30 lsstObs.lon = self.telescope.longitude_rad 

31 lsstObs.elevation = self.telescope.height 

32 

33 pad = 30./60./24. 

34 mjd_min = dataSlice[self.mjdCol].min() - pad 

35 mjd_max = dataSlice[self.mjdCol].max() + pad 

36 

37 # How often to plot the moon and things 

38 step = 20./60./24. 

39 mjds = np.arange(mjd_min, mjd_max+step, step) 

40 sun_alts = [] 

41 moon_alts = [] 

42 moon_azs = [] 

43 sun_azs = [] 

44 

45 doff = ephem.Date(0)-ephem.Date('1858/11/17') 

46 djds = mjds - doff 

47 for djd in djds: 

48 lsstObs.date = djd 

49 moon = ephem.Moon(lsstObs) 

50 moon_alts.append(moon.alt + 0) 

51 moon_azs.append(moon.az + 0) 

52 sun = ephem.Sun(lsstObs) 

53 sun_alts.append(sun.alt + 0) 

54 sun_azs.append(sun.az + 0) 

55 moon_alts = np.array(moon_alts) 

56 moon_azs = np.array(moon_azs) 

57 mjds = np.array(mjds) 

58 sun_alts = np.array(sun_alts) 

59 sun_azs = np.array(sun_azs) 

60 

61 return {'dataSlice': dataSlice, 'moon_alts': moon_alts, 'moon_azs': moon_azs, 'mjds': mjds, 

62 'sun_alts': sun_alts, 'sun_azs': sun_azs}