Coverage for python/lsst/sims/featureScheduler/basis_functions/feasibility_funcs.py : 25%

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
'Not_twilight_basis_function', 'Force_delay_basis_function', 'Hour_Angle_limit_basis_function', 'Moon_down_basis_function', 'Fraction_of_obs_basis_function', 'Clouded_out_basis_function', 'Rising_more_basis_function']
"""Check that the filter(s) needed are loaded
Parameters ---------- filternames : str or list of str The filternames that need to be mounted to execute. """ super(Filter_loaded_basis_function, self).__init__() if type(filternames) is not list: filternames = [filternames] self.filternames = filternames
for filtername in self.filternames: result = filtername in conditions.mounted_filters if result is False: return result return result
"""Make sure there is enough time before twilight. Useful if you want to check before starting a long sequence of observations.
Parameters ---------- time_needed : float (30.) The time needed to run a survey (mintues). alt_limit : int (18) The sun altitude limit to use. Must be 12 or 18 """ super(Time_to_twilight_basis_function, self).__init__() self.time_needed = time_needed/60./24. # To days self.alt_limit = str(alt_limit)
available_time = getattr(conditions, 'sun_n' + self.alt_limit + '_rising') - conditions.mjd result = available_time > self.time_needed return result
""" # Should be -18 or -12 """ self.sun_alt_limit = str(sun_alt_limit).replace('-', 'n') super(Not_twilight_basis_function, self).__init__()
result = True if conditions.mjd < getattr(conditions, 'sun_'+self.sun_alt_limit+'_setting'): result = False if conditions.mjd > getattr(conditions, 'sun_'+self.sun_alt_limit+'_rising'): result = False return result
"""Keep a survey from executing to rapidly.
Parameters ---------- days_delay : float (2) The number of days to force a gap on. """ super(Force_delay_basis_function, self).__init__() self.days_delay = days_delay self.survey_name = survey_name self.survey_features['last_obs_self'] = features.Last_observation(survey_name=self.survey_name)
result = True if conditions.mjd - self.survey_features['last_obs_self'].feature['mjd'] < self.days_delay: result = False return result
"""Only execute a survey in limited hour angle ranges. Useful for limiting Deep Drilling Fields.
Parameters ---------- RA : float (0.) RA of the target (degrees). ha_limits : list of lists limits for what hour angles are acceptable (hours). e.g., to give 4 hour window around RA=0, ha_limits=[[22,24], [0,2]] """ super(Hour_Angle_limit_basis_function, self).__init__() self.ra_hours = RA/360.*24. self.HA_limits = np.array(ha_limits)
target_HA = (conditions.lmst - self.ra_hours) % 24 # Are we in any of the possible windows result = False for limit in self.HA_limits: lres = limit[0] <= target_HA < limit[1] result = result or lres
return result
"""Demand the moon is down """ result = True if conditions.moonAlt > 0: result = False return result
"""Limit the fraction of all observations that can be labled a certain survey name. Useful for keeping DDFs from exceeding a given fraction of the total survey.
Parameters ---------- frac_total : float The fraction of total observations that can be of this survey survey_name : str The name of the survey """ super(Fraction_of_obs_basis_function, self).__init__() self.survey_name = survey_name self.frac_total = frac_total self.survey_features['Ntot'] = features.N_obs_survey() self.survey_features['N_survey'] = features.N_obs_survey(note=self.survey_name)
# If nothing has been observed, fine to go result = True if self.survey_features['Ntot'].feature == 0: return result ratio = self.survey_features['N_survey'].feature / self.survey_features['Ntot'].feature if ratio > self.frac_total: result = False return result
super(Clouded_out_basis_function, self).__init__() self.cloud_limit = cloud_limit
result = True if conditions.bulk_cloud > self.cloud_limit: result = False return result
"""Say a spot is not available if it will rise substatially before twilight.
Parameters ---------- RA : float The RA of the point in the sky (degrees) pad : float When to start observations if there's plenty of time before twilight (minutes) """ super(Rising_more_basis_function, self).__init__() self.RA_hours = RA * 24 / 360. self.pad = pad/60. # To hours
result = True hour_angle = conditions.lmst - self.RA_hours # If it's rising, and twilight is well beyond when it crosses the meridian time_to_twi = (conditions.sun_n18_rising - conditions.mjd)*24. if (hour_angle < -self.pad) & (np.abs(hour_angle) < (time_to_twi - self.pad)): result = False return result
## XXX--TODO: Can include checks to see if downtime is coming, clouds are coming, moon rising, or surveys in a higher tier # Have observations they want to execute soon. |