Coverage for python/lsst/sims/featureScheduler/detailers/short_survey.py : 22%

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
1from lsst.sims.featureScheduler.detailers import Base_detailer
2from lsst.sims.utils import _raDec2Hpid, m5_flat_sed
3import lsst.sims.featureScheduler.features as features
4from lsst.sims.featureScheduler.utils import hp_in_lsst_fov
5import numpy as np
6import healpy as hp
7import matplotlib.pylab as plt
9__all__ = ['Short_expt_detailer']
12class Short_expt_detailer(Base_detailer):
13 """Check if the area has been observed with a short exposure time this year. If not, add some short exposures.
15 Parameters
16 ----------
17 exp_time : float (1.)
18 The short exposure time to use.
19 nobs : float (2)
20 The number of observations to try and take per year
22 """
23 def __init__(self, exp_time=1., filtername='r', nside=32, footprint=None, nobs=2,
24 mjd0=59853.5, survey_name='short', read_approx=2.):
25 self.read_approx = read_approx
26 self.exp_time = exp_time
27 self.filtername = filtername
28 self.nside = nside
29 self.footprint = footprint
30 self.nobs = nobs
31 self.survey_name = survey_name
32 self.mjd0 = mjd0
34 self.survey_features = {}
35 # XXX--need a feature that tracks short exposures in the filter
36 self.survey_features['nobs'] = features.N_observations(filtername=filtername, nside=nside,
37 survey_name=self.survey_name)
38 # Need to be able to look up hpids for each observation
39 self.obs2hpid = hp_in_lsst_fov(nside=nside)
41 def __call__(self, observation_list, conditions):
42 out_observations = []
43 # Compute how many observations we should have taken by now
44 n_goal = self.nobs * np.round((conditions.mjd - self.mjd0)/365.25 + 1)
45 time_to_add = 0.
46 for observation in observation_list:
47 out_observations.append(observation)
48 if observation['filter'] == self.filtername:
49 hpids = self.obs2hpid(observation['RA'], observation['dec'])
50 # Crop off anything outside the target footprint
51 hpids = hpids[np.where(self.footprint[hpids] > 0)]
52 # Crop off things where we already have enough observation
53 hpids = hpids[np.where(self.survey_features['nobs'].feature[hpids] < n_goal)]
54 if np.size(hpids) > 0:
55 new_obs = observation.copy()
56 new_obs['exptime'] = self.exp_time
57 new_obs['nexp'] = 1
58 new_obs['note'] = self.survey_name
59 out_observations.append(new_obs)
60 time_to_add += new_obs['exptime'] + self.read_approx
61 # pump up the flush time
62 for observation in observation_list:
63 observation['flush_by_mjd'] += time_to_add/3600./24.
64 return out_observations