API

Applications

Collect

Compute

class schedview.compute.LsstCameraFootprintPerimeter[source]

Bases: object

Compute vertices surrounding the LSST camera footprint.

__call__(ra, decl, rotation=0)[source]

Compute vertices for a single pair of equatorial coordinates

Parameters:
  • ra (np.ndarray) – The R.A. of pointings (in degrees)

  • decl (np.ndarray) – The declination of pointings (in degrees)

  • rotation (float or np.ndarray) – The camera rotation(s) (in degrees)

Returns:

  • ra (np.ndarray) – An array of the R.A. of the vertices of the polygon surrounding the camera footprints (degrees).

  • decl (np.ndarray) – An array of the declinations of the vertices of the polygon surrounding the camera footprints (degrees).

single_eq_vertices(ra, decl, rotation=0)[source]

Compute vertices for a single pair of equatorial coordinates

Parameters:
  • ra (float) – The R.A. (in degrees)

  • decl (float) – The declination (in degrees)

  • rotation (float) – The camera rotation (in degrees)

Returns:

  • ra (np.ndarray) – An array of the R.A. of the vertices of the polygon surrounding the camera footprint (degrees).

  • decl (np.ndarray) – An array of the declinations of the vertices of the polygon surrounding the camera footprint (degrees).

schedview.compute.compute_hpix_metric_in_bands(visits, metric, constraint='', nside=32)[source]

Compute a MAF metric by visit.

Parameters:
  • visits (pandas.DataFrame) – The DataFrame of visits (with column names matching those of opsim database).

  • metric (rubin_sim.maf.metrics.BaseMetric) – The metric to compute.

  • constraint (str) – The SQL query to filter visits to be used.

  • nside (int) – The healpix nside of the healpix arrays to return.

Returns:

metric_values – A dictionary of healpix arrays, where the keys are the filters with visits in the input visit DataFrame.

Return type:

dict

schedview.compute.compute_maps(survey, conditions, nside=None)[source]

Compute healpix maps associated with a survey under given conditions.

Parameters:
  • survey (rubin_scheduler.scheduler.surveys.BaseSurvey) – The survey to summarize.

  • conditions (rubin_scheduler.scheduler.features.Conditions) – The conditions to use for the summary.

  • nside (int, optional) – The nside to use for the returned healpix maps. If not provided, the nside from the conditions will be used.

Returns:

survey_maps – An ordered dictionary of healpix maps associated with the survey.

Return type:

collections.OrderedDict

schedview.compute.compute_matched_visit_delta_statistics(visits, sim_identifier_reference_value=1, sim_identifier_column='sim_index', visit_spec_columns=('fieldRA', 'fieldDec', 'band', 'visitExposureTime'))[source]

Compute statistics on time differencse in visits matched across sims.

Parameters:
  • visits (pd.DataFrame) – _description_

  • sim_identifier_reference_value (int or str, optional) – Value of sim_identifier_column for the reference simulation times, by default 1.

  • sim_identifier_column (str, optional) – Column that in visits that identifies simulations, by default “sim_index”.

  • visit_spec_columns (tuple[str, ...], optional) – Columns in visits whose values need to match to be matched across simulations, by default (“fieldRA”, “fieldDec”, “band”, “visitExposureTime”)

Returns:

matched_visit_delta_stats – Statistics for each matched field. The index is a pandas.MultiIndex with levels matching those specified by visit_spec_columns, and there are columns for these statistics: count, mean, std, min, 25%, 50%, 75%, max.

Return type:

pd.DataFrame

schedview.compute.compute_metric_by_visit(visits, metric, constraint='')[source]

Compute a MAF metric by visit.

Parameters:
  • visits (pandas.DataFrame) – The DataFrame of visits (with column names matching those of opsim database).

  • metric (rubin_sim.maf.metrics.BaseMetric) – The metric to compute.

  • constraint (str) – The SQL query to filter visits to be used.

Returns:

values – The metric values.

Return type:

pandas.Series

schedview.compute.compute_sun_moon_positions(observatory)[source]

Create a DataFrame of sun and moon positions with one row per body, one column per coordinate, at the time set for the observatory.

Parameters:

observatory (ModelObservatory) – The model observatory.

Returns:

body_positions – The table of body positions.

Return type:

pandas.DataFrame

schedview.compute.convert_evening_date_to_night_of_survey(night_date, timezone='Chile/Continental')[source]

Convert a calendar date in the evening to the night of survey.

Parameters:
  • night_date (datetime.date) – The calendar date in the evening local time.

  • timezone (str) – The string designating the time zone. Defaults to ‘Chile/Continental’

Returns:

night_of_survey – The night of survey, starting from 0.

Return type:

int

schedview.compute.count_visits_by_sim(visits, sim_identifier_column='sim_index', visit_spec_columns=('fieldRA', 'fieldDec', 'band', 'visitExposureTime'))[source]

Count the numbers of visits on each field in each simulation.

Parameters:
  • visits (pd.DataFrame) – A table that must include both the columns listed in sim_identifier_column and visit_spec_columns (below). This DataFrame should include visits from all simulations to be compared, with a column that identifies which simulation each visits was from (sepecified by sim_identifier_column).

  • sim_identifier_column (str, optional) – A column that uniquely identifies visits, by default “sim_index”

  • visit_spec_columns (tuple`[`str], optional) – Columns that, together, uniquely identify a field that can be visited, by default (“fieldRA”, “fieldDec”, “band”, “visitExposureTime”)

Returns:

visit_counts – A table in which columns listed in the visit_spec_columns constitute levels of the pd.MultiIndex, and each unique value of the column listed in sim_identifier_column has a column named after it. The values are the numbers of visits in the corresponding combination of visit parameters in identified simulation.

Return type:

pd.DataFrame

schedview.compute.create_example(current_time=None, survey_start='2025-01-01T16:00:00Z', nside=None, simulate=True, scheduler_pickle_fname=None, opsim_db_fname=None, rewards_fname=None)[source]

Create an example scheduler and observatory.

Parameters:
  • current_time (float, str, datetime.datetime, pandas.Timestamp,) – or astropy.time.Time The time to initialize the observatory and conditions to. Floats are interpreted as MJD. Strings are interpreted as UTC. If None, use the current time. Defaults no None.

  • survey_start (float, str, datetime.datetime, pandas.Timestamp,) – or astropy.time.Time The survey start time.

  • nside (int) – The nside to use for the scheduler and observatory. If None, use the default nside for the example scheduler.

  • simulate (bool) – Run a sample simulation from survey_start to current_time

  • scheduler_pickle_fname (str) – The filename to save the scheduler to.

  • opsim_db_fname (str) – The filename to save the opsim database to.

  • rewards_fname (str) – The filename to save the rewards to.

Returns:

  • scheduler (rubin_scheduler.scheduler.schedulers.CoreScheduler) – The scheduler instance.

  • observatory (rubin_scheduler.models.ModelObservatory) – The observatory instance.

  • conditions (rubin_scheduler.scheduler.features.Conditions) – The conditions at the current time.

  • observations (pd.DataFrame) – The observations from the simulation.

schedview.compute.make_scheduler_summary_df(scheduler, conditions, reward_df=None)[source]

Summarize the reward from each scheduler

Parameters:
  • scheduler (rubin_scheduler.scheduler.schedulers.CoreScheduler) – The scheduler instance.

  • conditions (rubin_scheduler.scheduler.features.conditions.Conditions) – The conditions for which to summarize the reward.

  • reward_df (pandas.DataFrame) – The table with rewards for each survey. If None, calculate it.

Returns:

survey_df – A table showing the reword for each feasible survey, and the basis functions that result in it being infeasible for the rest.

Return type:

pandas.DataFrame

schedview.compute.make_survey_reward_df(survey, conditions, reward_df=None)[source]

Make a dataframe summarizing the rewards for a survey.

Parameters:
  • survey (rubin_scheduler.scheduler.surveys.BaseSurvey) – The survey to summarize.

  • conditions (rubin_scheduler.scheduler.features.Conditions) – The conditions to use for the summary.

  • reward_df (pandas.DataFrame, optional) – A dataframe with the columns “basis_function”, “basis_function_class”, “feasible”, “max_basis_reward”, “basis_area”, “basis_weight”, “max_accum_reward”, and “accum_area”. If not provided, this dataframe will be computed from the survey.

Returns:

reward_df – A dataframe with the columns “basis_function”, “basis_function_class”, “feasible”, “max_basis_reward”, “basis_area”, “basis_weight”, “max_accum_reward”, “accum_area”, and “doc_url”.

Return type:

pandas.DataFrame

schedview.compute.make_unique_survey_name(scheduler, survey_index=None)[source]

Make a unique survey name for a given survey index.

Parameters:
  • scheduler (rubin_scheduler.scheduler.schedulers.CoreScheduler) – The scheduler instance.

  • survey_index (list of int) – The index of the survey to name. If None, use the current survey.

Returns:

survey_name – A unique name for the survey.

Return type:

str

schedview.compute.match_visits_across_sims(start_times, sim_indexes=(1, 2), max_match_dist=inf)[source]

Match corresponding visits across two opsim simulations.

Parameters:
  • start_times (pd.Series) – A series of dtype datetime64[ns, UTC] indexed by simulation id, such that start_times.loc[1].iloc[3] is the start time of the fourth visit to a field in simulation 1.

  • sim_indexes (tuple`[`int], optional) – The simulations to compare, by default (1, 2)

  • max_match_dist (float, optional) – The maximum time difference to allow for a match, in seconds, by default np.inf

Returns:

best_match – A data frame with one row for each matched visits, columns named for each simulation index with the start times for the matched visits, and a column named delta with the time difference in seconds.

Return type:

pd.DataFrame

schedview.compute.night_events(night_date=None, site=None, timezone='Chile/Continental')[source]

Creata a pandas.DataFrame with astronomical events.

Parameters:
  • night_date (datetime.date) – The calendar date in the evening local time.

  • site (astropy.coordinates.earth.EarthLocation) – The observatory location. Defaults to Rubin observatory.

  • timezone (str) – The timezone name. Defaults to ‘Chile/Continental’

Returns:

events – A DataFrame of night events.

Return type:

pandas.DataFrame

schedview.compute.often_repeated_fields(visits, min_counts=4)[source]

Find often repeated fields in a table of visits.

Parameters:
  • visits (pandas.DataFrame) –

    The visits as a DataFrame with the following columns:

    fieldRA

    R.A. in degrees.

    fieldDec

    Declination in degrees.

    filter

    The filter.

    sim_index

    An int identifying which simulation a visit came from.

    start_date

    The starting datetime64[ns, UTC] for the visit.

    label

    The str label for the simulation.

  • min_counts (int) – The minimum visits in a single simulation a field must have to be considererd “often visited”.

Returns:

  • often_repeated_fields (pandas.DataFrame) – The table of repeated field parameters, with the following columns:

    fieldRA

    R.A. in degrees.

    fieldDec

    Declination in degrees.

    filter

    The filter.

  • often_repeated_field_stats (pandas.DataFrame) – Statistics on the repetitions of each field. The index is a pandas.MultiIndex with the following levels:

    fieldRA

    R.A. in degrees.

    fieldDec

    Declination in degrees.

    filter

    The filter.

    sim_index

    An int identifying which simulation a visit came from.

    The columns are:

    count

    The (int) number of visits in the simulation on the field.

    first_time

    The datetime64[ns, UTC] start time of the first visit to the field in the simulation.

    last_time

    The datetime64[ns, UTC] start time of the last visit to the field in the simulation.

    label

    The str label for the simulation.

Notes

This created table is intended to provide overviews of sets of visits to specific fields for which the specific pointing and filter combinations are of particular interest (e.g. DDF fields).

schedview.compute.replay_visits(scheduler, visits)[source]

Update a scheduler instances with a set of visits.

Parameters:
  • scheduler (rubin_scheduler.scheduler.CoreScheduler) – An instance of the scheduler to update

  • visits (pandas.DataFrame) – A table of visits to add.

Plot

Utilities

class schedview.param.DataFrame(default=None, columns=None, allow_empty=True, allow_None=False, *, doc=None, label=None, precedence=None, instantiate=False, constant=False, readonly=False, pickle_default_value=True, per_instance=True, allow_refs=False, nested_refs=False)[source]

Bases: Parameter

A pandas.DataFrame parameter.

Parameters:
  • columns (list [str] or dict [‘str’, ‘type’]) – The columns of the DataFrame. If a dictionary, the keys are the column names and the values. If a list, it contains the column names. If None, any set of columns is accepted.

  • allow_empty (bool) – Whether to allow a DataFrame with no rows.

class schedview.param.Series(default=None, allow_None=False, *, doc=None, label=None, precedence=None, instantiate=False, constant=False, readonly=False, pickle_default_value=True, per_instance=True, allow_refs=False, nested_refs=False)[source]

Bases: Parameter

A pandas.Series parameter.

schedview.sphere.offset_sep_bear(ra, decl, sep, bearing, degrees=False)[source]

Calculate coordinates after an offset by a separation.

Parameters:
  • ra (float) – R.A. as a float in radians

  • decl (float) – declination as a float in radians

  • sep (float) – separation in radians

  • bearing (float) – bearing (east of north) in radians

  • degrees (bool) – arguments and returnes are in degrees (False for radians).

Returns:

  • ra (float) – R.A. Right Ascension

  • decl (float) – declination

schedview.sphere.rotate_cart(ux, uy, uz, angle, x0, y0, z0)[source]

Rotate coordinates on a unit sphere around an axis

Parameters:
  • ux (float) – x coordinate of a point on the axis of rotation

  • uy (float) – y coordinate of a point on the axis of rotation

  • uz (float) – z coordinate of a point on the axis of rotation

  • angle (float) – Magnitude of the rotation.

  • x0 (float) – Input x coordinate

  • y0 (float) – Input y coordinate

  • z0 (float) – Input z coordinate

Returns:

  • ux (float) – Output x coordinate

  • uy (float) – Output y coordinate

  • uz (float) – Output z coordinate