Coverage for python/lsst/sims/featureScheduler/surveys/too_surveys.py : 19%

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
""" A target of opportunity class. Every time a new ToO comes in, it will spawn a new sub-survey.
Parameters ---------- example_ToO_survey : lsst.sims.featureScheduler.surveys.ToO_survey object A survey object that will be coppied and have a new target map set for each incoming ToO. """
self.example_ToO_survey = example_ToO_survey self.surveys = [] self.highest_reward = -np.inf # XXX--TODO: ugh, I think I want to take out the sequence stuff perhaps self.sequence = False
if len(self.surveys) > 0: for survey in self.surveys: survey.add_observation(observation, indx=indx)
"""Create a new survey object for a ToO we haven't seen before.
Parameters ---------- too : lsst.sims.featureScheduler.utils.TargetoO object """ new_survey = copy.deepcopy(self.example_ToO_survey) new_survey.set_id(too.id) new_survey.set_target_map(too.footprint)
return new_survey
"""There is a current ToO in the conditions. """
running_ids = [survey.too_id for survey in self.surveys] current_ids = [too.id for too in conditions.targets_of_opportunity]
# delete any ToO surveys that are no longer relevant self.surveys = [survey for survey in self.surveys if survey.too_id in current_ids]
# Spawn new surveys that are needed new_surveys = [] for too in conditions.targets_of_opportunity: if too.id not in running_ids: new_surveys.append(self._spawn_new_survey(too)) self.surveys.extend(new_surveys)
# Catch if a new ToO has happened if conditions.targets_of_opportunity is not None: self._check_survey_list(conditions)
if len(self.surveys) > 0: rewards = [np.nanmax(survey.calc_reward_function(conditions)) for survey in self.surveys] self.reward = np.nanmax(rewards) self.highest_reward = np.min(np.where(rewards == self.reward)) else: self.reward = -np.inf self.highest_reward = None return self.reward
if self.reward > -np.inf: result = self.surveys[self.highest_reward].generate_observations(conditions) return result
"""Survey class to catch incoming target of opportunity anouncements and try to observe them.
The idea is that we can dynamically update the target footprint basis function, and add new features as more ToOs come in.
Parameters ---------- too_id : int (None) A unique integer ID for the ToO getting observed """ filtername1='r', filtername2=None, slew_approx=7.5, filter_change_approx=140., read_approx=2., exptime=30., nexp=2, ideal_pair_time=22., min_pair_time=15., search_radius=30., alt_max=85., az_range=180., flush_time=30., smoothing_kernel=None, nside=None, dither=True, seed=42, ignore_obs=None, survey_note='ToO', detailers=None, camera='LSST', too_id=None): super(ToO_survey, self).__init__(basis_functions=basis_functions, basis_weights=basis_weights, filtername1=filtername1, filtername2=filtername2, slew_approx=slew_approx, filter_change_approx=filter_change_approx, read_approx=read_approx, exptime=exptime, nexp=nexp, ideal_pair_time=ideal_pair_time, min_pair_time=min_pair_time, search_radius=search_radius, alt_max=alt_max, az_range=az_range, flush_time=flush_time, smoothing_kernel=smoothing_kernel, nside=nside, dither=dither, seed=seed, ignore_obs=ignore_obs, survey_note=survey_note, detailers=detailers, camera=camera) # Include the ToO id in the note self.survey_note_base = self.survey_note self.set_id(too_id)
"""Set the id """ self.too_id = newid self.survey_note = self.survey_note_base + ', ' + str(newid)
""" Expect one of the basis functions to be Footprint_nvis_basis_function """ for basis_func in self.basis_functions: if hasattr(basis_func, 'footprint'): basis_func.footprint = newmap
# Always spin the tesselation before generating a new block. if self.dither: self._spin_fields() result = super(ToO_survey, self).generate_observations_rough(conditions) return result |