Features

class rubin_scheduler.scheduler.features.BaseFeature(**kwargs)[source]

Bases: ABC

The base class for features. This defines the standard API: a Feature should include a self.feature attribute, which could be a float, bool, or healpix size numpy array, or numpy masked array, and a __call__ method which returns self.feature.

class rubin_scheduler.scheduler.features.BaseSurveyFeature(**kwargs)[source]

Bases: BaseFeature

Track information relevant to the progress of a survey, using self.feature to hold this information.

Features can track a single piece of information, or keep a map across the sky, or any other piece of information.

Information in self.feature is updated via add_observation or add_observation_array.

abstract add_observation(observation, indx=None, **kwargs)[source]

Update self.feature based on information in observation. Observations should be ordered in monotonically increasing time.

Parameters:
  • observation (np.array, (1,N)) – Array of observation information, containing mjd for the time. See rubin_scheduler.scheduler.utils.ObservationArray.

  • indx (list-like of [int]) – The healpixel indices that the observation overlaps. See rubin_scheduler.utils.HpInLsstFov.

abstract add_observations_array(observations_array, observations_hpid)[source]

Update self.feature based on information in observations_array and observations_hpid.

This is a method to more rapidly restore the feature to its expected state, by using an array of all previous observations (observations_array) instead looping over the individual observations, as in self.add_observation. The observations array allows rapid calculation of acceptable observations, without considering factors such as which healpix is relevant.

The observations_hpid is a reorganized version of the observations_array, where the array representing each observation is extended to include hpid and recorded multiple times (for each healpixel). The observations_hpid allows rapid calculation of feature values which depend on hpid.

Links between observations_array and observations_hpid can be made using ID.

class rubin_scheduler.scheduler.features.Conditions(nside=32, site='LSST', exptime=30.0, mjd=None)[source]

Bases: object

Holds telemetry information, keeping calculated values in sync for self.mjd (such as ra/dec mappings to alt/az).

Incoming values have setters to keep values in sync. Healpix maps are set to the expected (self.nside) resolution.

Unless otherwise noted, all values are assumed to be valid at the time given by self.mjd.

Parameters:
  • nside (int, optional) – The healpixel nside to set the resolution of attributes. Default of None will use rubin_scheduler.scheduler.utils.set_default_nside.

  • site (str ('LSST')) – A site name used to create a sims.utils.Site object. For looking up observatory parameters like latitude and longitude.

  • exptime (float, optional) – The exposure time (seconds) to assume when computing the 5-sigma limiting depth maps stored in Conditions. These maps are used by basis functions, but are not used to calculate expected observation m5 values (such as when exposure time varies). Default 30 seconds.

  • mjd (float, optional) – The current MJD. Default of None is fine on init - will be updated by telemetry stream.

future_alt_az(mjd)[source]

Compute the altitude and azimuth for a future time.

Returns:

  • altitude (np.array) – The altutude of each healpix at MJD (radians)

  • azimuth (: np.array) – The azimuth of each healpix at MJD (radians)

set_attrs(**kwargs)[source]

Convience function for setting lots of attributes at once. See __init__ docstring for full list of potential attributes.

set_auxtel_info(mjd, slewtime, sun_n18_setting, sun_n18_rising, moon_alt, moon_az, tel_alt_limits, tel_az_limits, sky_alt_limits, sky_az_limits, wind_speed, wind_direction, **kwargs)[source]

Method to set all the information we expect will be required by a standard auxtel scheduler. Extra attributes can be set via **kwargs.

Parameters:
  • mjd (float) – Modified Julian Date (days).

  • slewtime (np.ndarray, (N,)) – Healpix showing the slewtime to each healpixel center (seconds)

  • moon_alt (float) – The altitude of the Moon (radians)

  • moon_az (float) – The Azimuth of the moon (radians)

  • wind_speed (float) – Wind speed (m/s).

  • wind_direction (float) – Direction from which the wind originates. A direction of 0.0 degrees means the wind originates from the north and 90.0 degrees from the east (radians).

  • sun_n18_setting (float) – The MJD when the sun is at -18 degrees altitude and setting during the current night. From interpolation.

  • sun_n18_rising (float) – The MJD when the sun is at -18 degrees altitude and rising during the current night. From interpolation.

  • sky_az_limits (list [[float, float]]) – A list of lists giving valid azimuth ranges. e.g., [0, 2*np.pi] would mean all azimuth values are valid, while [[0, np.pi/2], [3*np.pi/2, 2*np.pi]] would mean anywhere in the south is invalid. Radians.

  • sky_alt_limits (list [[float, float]]) – A list of lists giving valid altitude ranges. Radians.

  • tel_az_limits (list [float, float]) – A simple two-element list giving the valid azimuth ranges for the telescope movement. Radians.

  • tel_alt_limits (list [float, float]) – A simple two-element list giving the valid altitude ranges for the telescope movement. Radians

set_maintel_info(mjd, slewtime, current_filter, mounted_filters, night, skybrightness, fwhm_eff, moon_alt, moon_az, moon_ra, moon_dec, moon_phase, sun_alt, sun_az, sun_ra, sun_dec, tel_ra, tel_dec, tel_alt, tel_az, wind_speed, wind_direction, sun_n12_setting, sun_n12_rising, sun_n18_setting, sun_n18_rising, moonrise, moonset, planet_positions, tel_alt_limits, tel_az_limits, sky_alt_limits, sky_az_limits, **kwargs)[source]

Method to set all the information we expect will be required by a standard maintel scheduler. Extra attributes can be set via **kwargs.

mjdfloat

Modified Julian Date (days).

slewtimenp.ndarray, (N,)

Healpix showing the slewtime to each healpixel center (seconds)

current_filterstr

The name of the current filter. (expect one of u, g, r, i, z, y).

mounted_filterslist [str]

The filters that are currently mounted and thus available (expect 5 of u, g, r, i, z, y for LSSTCam).

nightint

The current night number (days). Probably starts at 1.

skybrightnessdict {str: `np.ndarray, (N,)}

Dictionary keyed by filter name. Values are healpix arrays with the sky brightness at each healpix center (mag/acsec^2)

fwhm_effdict {str: `np.ndarray, (N,)}

Dictionary keyed by filtername. Values are the effective seeing FWHM at each healpix center (arcseconds)

moon_altfloat

The altitude of the Moon (radians)

moon_azfloat

The Azimuth of the moon (radians)

moon_rafloat

RA of the moon (radians)

moon_decfloat

Declination of the moon (radians)

moon_phasefloat

The Phase of the moon. (percent, 0=new moon, 100=full moon)

sun_altfloat

The altitude of the sun (radians).

sun_azfloat

The Azimuth of the sun (radians).

sun_rafloat

The RA of the sun (radians).

sun_decfloat

The Dec of the sun (radians).

tel_rafloat

The current telescope RA pointing (radians).

tel_decfloat

The current telescope Declination (radians).

tel_altfloat

The current telescope altitude (radians).

tel_azfloat

The current telescope azimuth (radians).

wind_speedfloat

Wind speed (m/s).

wind_directionfloat

Direction from which the wind originates. A direction of 0.0 degrees means the wind originates from the north and 90.0 degrees from the east (radians).

sun_n12_settingfloat

The MJD of when the sun is at -12 degrees altitude and setting during the current night. From interpolation.

sun_n18_settingfloat

The MJD when the sun is at -18 degrees altitude and setting during the current night. From interpolation.

sun_n18_risingfloat

The MJD when the sun is at -18 degrees altitude and rising during the current night. From interpolation.

sun_n12_risingfloat

The MJD when the sun is at -12 degrees altitude and rising during the current night. From interpolation.

moonrisefloat

The MJD of moonrise during the current night. From interpolation.

moonsetfloat

The MJD of moon set during the current night. From interpolation.

moon_phase_sunsetfloat

The phase of the moon (0-100 illuminated) at sunset. Useful for setting which filters should be loaded.

targets_of_opportunitylist [rubin_scheduler.scheduler.targetoO]

targetoO objects.

planet_positionsdict {str: float}

Dictionary of planet name and coordinate e.g., ‘venus_RA’, ‘mars_dec’

sky_az_limitslist [[float, float]]

A list of lists giving valid azimuth ranges. e.g., [0, 2*np.pi] would mean all azimuth values are valid, while [[0, np.pi/2], [3*np.pi/2, 2*np.pi]] would mean anywhere in the south is invalid. Radians.

sky_alt_limitslist [[float, float]]

A list of lists giving valid altitude ranges. Radians.

tel_az_limitslist [float, float]

A simple two-element list giving the valid azimuth ranges for the telescope movement. Radians.

tel_alt_limitslist [float, float]

A simple two-element list giving the valid altitude ranges for the telescope movement. Radians

class rubin_scheduler.scheduler.features.LastNObsTimes(filtername=None, n_obs=3, nside=32)[source]

Bases: BaseSurveyFeature

Record the last three observations for each healpixel.

Parameters:
  • filtername (str or None) – Match visits in this filtername.

  • n_obs (int) – The number of prior observations to track.

  • nside (int) – The nside of the healpix map.

add_observation(observation, indx=None)[source]

Update self.feature based on information in observation. Observations should be ordered in monotonically increasing time.

Parameters:
  • observation (np.array, (1,N)) – Array of observation information, containing mjd for the time. See rubin_scheduler.scheduler.utils.ObservationArray.

  • indx (list-like of [int]) – The healpixel indices that the observation overlaps. See rubin_scheduler.utils.HpInLsstFov.

add_observations_array(observations_array, observations_hpid)[source]

Update self.feature based on information in observations_array and observations_hpid.

This is a method to more rapidly restore the feature to its expected state, by using an array of all previous observations (observations_array) instead looping over the individual observations, as in self.add_observation. The observations array allows rapid calculation of acceptable observations, without considering factors such as which healpix is relevant.

The observations_hpid is a reorganized version of the observations_array, where the array representing each observation is extended to include hpid and recorded multiple times (for each healpixel). The observations_hpid allows rapid calculation of feature values which depend on hpid.

Links between observations_array and observations_hpid can be made using ID.

class rubin_scheduler.scheduler.features.LastObservation(scheduler_note=None, filtername=None, survey_name=None)[source]

Bases: BaseSurveyFeature

Track the (entire) last observation.

All visits, no healpix dependency.

Parameters:
  • scheduler_note (str or None, optional) – The scheduler_note to match. Scheduler_note values which match this OR which contain this value as a subset of their string will match.

  • filtername (str or None, optional) – The required filter to match.

  • survey_name (str or None, optional) – Backwards compatible shim for scheduler_note. Deprecated.

add_observation(observation, indx=None)[source]

Update self.feature based on information in observation. Observations should be ordered in monotonically increasing time.

Parameters:
  • observation (np.array, (1,N)) – Array of observation information, containing mjd for the time. See rubin_scheduler.scheduler.utils.ObservationArray.

  • indx (list-like of [int]) – The healpixel indices that the observation overlaps. See rubin_scheduler.utils.HpInLsstFov.

add_observations_array(observations_array, observations_hpid)[source]

Update self.feature based on information in observations_array and observations_hpid.

This is a method to more rapidly restore the feature to its expected state, by using an array of all previous observations (observations_array) instead looping over the individual observations, as in self.add_observation. The observations array allows rapid calculation of acceptable observations, without considering factors such as which healpix is relevant.

The observations_hpid is a reorganized version of the observations_array, where the array representing each observation is extended to include hpid and recorded multiple times (for each healpixel). The observations_hpid allows rapid calculation of feature values which depend on hpid.

Links between observations_array and observations_hpid can be made using ID.

class rubin_scheduler.scheduler.features.LastObservationMjd(scheduler_note=None, filtername=None, note=None)[source]

Bases: BaseSurveyFeature

Track the MJD of the last observation.

All visits, no healpix dependency.

Parameters:
  • scheduler_note (str or None, optional) – The scheduler_note to match. Scheduler_note values which match this OR which contain this value as a subset of their string will match.

  • filtername (str or None, optional) – The required filter to match.

Notes

Very similar to LastObservation, but only tracks the MJD of the last matching visit.

add_observation(observation, indx=None)[source]

Update self.feature based on information in observation. Observations should be ordered in monotonically increasing time.

Parameters:
  • observation (np.array, (1,N)) – Array of observation information, containing mjd for the time. See rubin_scheduler.scheduler.utils.ObservationArray.

  • indx (list-like of [int]) – The healpixel indices that the observation overlaps. See rubin_scheduler.utils.HpInLsstFov.

add_observations_array(observations_array, observations_hpid)[source]

Update self.feature based on information in observations_array and observations_hpid.

This is a method to more rapidly restore the feature to its expected state, by using an array of all previous observations (observations_array) instead looping over the individual observations, as in self.add_observation. The observations array allows rapid calculation of acceptable observations, without considering factors such as which healpix is relevant.

The observations_hpid is a reorganized version of the observations_array, where the array representing each observation is extended to include hpid and recorded multiple times (for each healpixel). The observations_hpid allows rapid calculation of feature values which depend on hpid.

Links between observations_array and observations_hpid can be made using ID.

class rubin_scheduler.scheduler.features.LastObserved(filtername='r', nside=32, fill=nan)[source]

Bases: BaseSurveyFeature

Track the MJD when a pixel was last observed. Assumes observations are added in chronological order.

Calculated per healpix.

Parameters:
  • filtername (str or None) – Track visits in a particular filter or any filter (None).

  • nside (int or None) – Nside for the healpix map, default of None uses the scheduler default.

  • fill (float) – Fill value to use where no observations have been found.

add_observation(observation, indx=None)[source]

Update self.feature based on information in observation. Observations should be ordered in monotonically increasing time.

Parameters:
  • observation (np.array, (1,N)) – Array of observation information, containing mjd for the time. See rubin_scheduler.scheduler.utils.ObservationArray.

  • indx (list-like of [int]) – The healpixel indices that the observation overlaps. See rubin_scheduler.utils.HpInLsstFov.

add_observations_array(observations_array, observations_hpid)[source]

Update self.feature based on information in observations_array and observations_hpid.

This is a method to more rapidly restore the feature to its expected state, by using an array of all previous observations (observations_array) instead looping over the individual observations, as in self.add_observation. The observations array allows rapid calculation of acceptable observations, without considering factors such as which healpix is relevant.

The observations_hpid is a reorganized version of the observations_array, where the array representing each observation is extended to include hpid and recorded multiple times (for each healpixel). The observations_hpid allows rapid calculation of feature values which depend on hpid.

Links between observations_array and observations_hpid can be made using ID.

class rubin_scheduler.scheduler.features.NObsCount(scheduler_note=None, filtername=None, note=None)[source]

Bases: BaseSurveyFeature

Count the number of observations, whole sky (not per pixel).

Because this feature will belong to a survey, it would count all observations that are counted for that survey.

Parameters:
  • scheduler_note (str or None) – Count observations that match str in their scheduler_note field. Note can be a substring of scheduler_note, and will still match.

  • filtername (str or None) – Optionally also (or independently) specify a filter to match.

  • note (str or None) – Backwards compatible shim for scheduler_note.

add_observation(observation, indx=None)[source]

Update self.feature based on information in observation. Observations should be ordered in monotonically increasing time.

Parameters:
  • observation (np.array, (1,N)) – Array of observation information, containing mjd for the time. See rubin_scheduler.scheduler.utils.ObservationArray.

  • indx (list-like of [int]) – The healpixel indices that the observation overlaps. See rubin_scheduler.utils.HpInLsstFov.

add_observations_array(observations_array, observations_hpid)[source]

Update self.feature based on information in observations_array and observations_hpid.

This is a method to more rapidly restore the feature to its expected state, by using an array of all previous observations (observations_array) instead looping over the individual observations, as in self.add_observation. The observations array allows rapid calculation of acceptable observations, without considering factors such as which healpix is relevant.

The observations_hpid is a reorganized version of the observations_array, where the array representing each observation is extended to include hpid and recorded multiple times (for each healpixel). The observations_hpid allows rapid calculation of feature values which depend on hpid.

Links between observations_array and observations_hpid can be made using ID.

class rubin_scheduler.scheduler.features.NObsNight(filtername='r', nside=32)[source]

Bases: BaseSurveyFeature

Track how many times a healpixel has been observed in a night.

Parameters:
  • filtername (str or None) – Filter to track. None tracks observations in any filter.

  • nside (int or None) – Scale of the healpix map. Default of None uses the scheduler default nside.

add_observation(observation, indx=None)[source]

Update self.feature based on information in observation. Observations should be ordered in monotonically increasing time.

Parameters:
  • observation (np.array, (1,N)) – Array of observation information, containing mjd for the time. See rubin_scheduler.scheduler.utils.ObservationArray.

  • indx (list-like of [int]) – The healpixel indices that the observation overlaps. See rubin_scheduler.utils.HpInLsstFov.

add_observations_array(observations_array, observations_hpid)[source]

Update self.feature based on information in observations_array and observations_hpid.

This is a method to more rapidly restore the feature to its expected state, by using an array of all previous observations (observations_array) instead looping over the individual observations, as in self.add_observation. The observations array allows rapid calculation of acceptable observations, without considering factors such as which healpix is relevant.

The observations_hpid is a reorganized version of the observations_array, where the array representing each observation is extended to include hpid and recorded multiple times (for each healpixel). The observations_hpid allows rapid calculation of feature values which depend on hpid.

Links between observations_array and observations_hpid can be made using ID.

class rubin_scheduler.scheduler.features.NObservations(filtername=None, nside=32, scheduler_note=None, survey_name=None)[source]

Bases: BaseSurveyFeature

Track the number of observations that have been made at each healpix.

Parameters:
  • filtername (str or list [str] or None) – String or list that has all the filters that can count. Default None counts all filters.

  • nside (int) – The nside of the healpixel map to use. Default None uses scheduler default.

  • scheduler_note (str or None, optional) – The scheduler_note to match. Scheduler_note values which match this OR which contain this value as a subset of their string will match.

  • survey_name (str or None) – The scheduler_note value to match. Deprecated in favor of scheduler_note, but provided for backward compatibility. Will be removed in the future.

add_observation(observation, indx=None)[source]

Update self.feature based on information in observation. Observations should be ordered in monotonically increasing time.

Parameters:
  • observation (np.array, (1,N)) – Array of observation information, containing mjd for the time. See rubin_scheduler.scheduler.utils.ObservationArray.

  • indx (list-like of [int]) – The healpixel indices that the observation overlaps. See rubin_scheduler.utils.HpInLsstFov.

add_observations_array(observations_array, observations_hpid)[source]

Update self.feature based on information in observations_array and observations_hpid.

This is a method to more rapidly restore the feature to its expected state, by using an array of all previous observations (observations_array) instead looping over the individual observations, as in self.add_observation. The observations array allows rapid calculation of acceptable observations, without considering factors such as which healpix is relevant.

The observations_hpid is a reorganized version of the observations_array, where the array representing each observation is extended to include hpid and recorded multiple times (for each healpixel). The observations_hpid allows rapid calculation of feature values which depend on hpid.

Links between observations_array and observations_hpid can be made using ID.

class rubin_scheduler.scheduler.features.NObservationsCurrentSeason(filtername=None, nside=32, seeing_fwhm_max=None, m5_penalty_max=None, mjd_start=60796.0)[source]

Bases: BaseSurveyFeature

Count the observations at each healpix, taken in the most recent season, that meet filter, seeing and m5 criteria.

Useful for ensuring that “good quality” observations are acquired in each season at each point in the survey footprint.

Parameters:
  • filtername (str, optional) – If None (default) count observations in any filter. Otherwise, only count observations in the specified filter.

  • nside (int, optional) – If None (default), use default nside for scheduler. Otherwise, set nside for the map to nside.

  • seeing_fwhm_max (float, optional) – If None (default), count observations up to any seeing value. Otherwise, only count observations with better seeing (FWHMeff) than seeing_fwhm_max. In arcseconds.

  • m5_penalty_max (float, optional) – If None (default), count observations with any m5 value. Otherwise, only count observations within this value of the dark sky map at this pixel. Only relevant if filtername is not None.

  • mjd_start (float, optional) – If None, uses default survey_start_mjd for the start of the survey. This defines the starting year for counting seasons, so should be the start of the survey.

add_observation(observation, indx)[source]

Update self.feature based on information in observation. Observations should be ordered in monotonically increasing time.

Parameters:
  • observation (np.array, (1,N)) – Array of observation information, containing mjd for the time. See rubin_scheduler.scheduler.utils.ObservationArray.

  • indx (list-like of [int]) – The healpixel indices that the observation overlaps. See rubin_scheduler.utils.HpInLsstFov.

add_observations_array(observations_array, observations_hpid)[source]

Update self.feature based on information in observations_array and observations_hpid.

This is a method to more rapidly restore the feature to its expected state, by using an array of all previous observations (observations_array) instead looping over the individual observations, as in self.add_observation. The observations array allows rapid calculation of acceptable observations, without considering factors such as which healpix is relevant.

The observations_hpid is a reorganized version of the observations_array, where the array representing each observation is extended to include hpid and recorded multiple times (for each healpixel). The observations_hpid allows rapid calculation of feature values which depend on hpid.

Links between observations_array and observations_hpid can be made using ID.

season_update(observation=None, conditions=None)[source]

Update the season_map to the current time.

This assumes time increases monotonically in the conditions or observations objects passed as arguments. Using the ‘mjd’ from the conditions, where parts of the sky have changed season (increasing in the self.season_map + 1) the self.feature is cleared, in order to restart counting observations in the new season.

Parameters:
  • observation (np.array, (1,N)) – Array of observation information, containing mjd for the time. See rubin_scheduler.scheduler.utils.ObservationArray.

  • conditions (rubin_scheduler.scheduler.Conditions, optional) – A conditions object, containing mjd.

Notes

One of observations or conditions must be passed, but either are options so this can be used with add_observation. Most of the time, the updates will come from conditions.

class rubin_scheduler.scheduler.features.NoteInNight(notes=[None])[source]

Bases: BaseSurveyFeature

Count appearances of any of scheduler_notes in observation scheduler_note in the current night; note must match one of scheduler_notes exactly.

Useful for keeping track of how many times a survey or other subset of visits has executed in a given night.

Parameters:

notes (list [str], optional) – List of strings to match against observation scheduler_note values. The scheduler_note must match one of the items in notes exactly. Default of [None] will match any note.

add_observation(observation, indx=None)[source]

Update self.feature based on information in observation. Observations should be ordered in monotonically increasing time.

Parameters:
  • observation (np.array, (1,N)) – Array of observation information, containing mjd for the time. See rubin_scheduler.scheduler.utils.ObservationArray.

  • indx (list-like of [int]) – The healpixel indices that the observation overlaps. See rubin_scheduler.utils.HpInLsstFov.

add_observations_array(observations_array, observations_hpid)[source]

Update self.feature based on information in observations_array and observations_hpid.

This is a method to more rapidly restore the feature to its expected state, by using an array of all previous observations (observations_array) instead looping over the individual observations, as in self.add_observation. The observations array allows rapid calculation of acceptable observations, without considering factors such as which healpix is relevant.

The observations_hpid is a reorganized version of the observations_array, where the array representing each observation is extended to include hpid and recorded multiple times (for each healpixel). The observations_hpid allows rapid calculation of feature values which depend on hpid.

Links between observations_array and observations_hpid can be made using ID.

class rubin_scheduler.scheduler.features.PairInNight(filtername='r', nside=32, gap_min=25.0, gap_max=45.0)[source]

Bases: BaseSurveyFeature

Track how many pairs have been observed within a night at a given healpix.

Parameters:
  • gap_min (float (25.)) – The minimum time gap to consider a successful pair in minutes

  • gap_max (float (45.)) – The maximum time gap to consider a successful pair (minutes)

add_observation(observation, indx=None)[source]

Update self.feature based on information in observation. Observations should be ordered in monotonically increasing time.

Parameters:
  • observation (np.array, (1,N)) – Array of observation information, containing mjd for the time. See rubin_scheduler.scheduler.utils.ObservationArray.

  • indx (list-like of [int]) – The healpixel indices that the observation overlaps. See rubin_scheduler.utils.HpInLsstFov.

add_observations_array(observations_array, observations_hpid)[source]

Update self.feature based on information in observations_array and observations_hpid.

This is a method to more rapidly restore the feature to its expected state, by using an array of all previous observations (observations_array) instead looping over the individual observations, as in self.add_observation. The observations array allows rapid calculation of acceptable observations, without considering factors such as which healpix is relevant.

The observations_hpid is a reorganized version of the observations_array, where the array representing each observation is extended to include hpid and recorded multiple times (for each healpixel). The observations_hpid allows rapid calculation of feature values which depend on hpid.

Links between observations_array and observations_hpid can be made using ID.