API¶
Applications¶
Collect¶
- schedview.collect.find_file_resources(base_resource_uri, file_filter=None)[source]¶
Find matching files in a resource.
- Parameters:
base_resource_uri (
str
) – The uri of the resource to searchfile_filter (
str
orre.Pattern
, optional) – Regex to filter out files from the list before it is returned.
- Returns:
files – The list of matching files available at the resource.
- Return type:
list
ofstr
- schedview.collect.get_from_logdb_with_retries(channel, params)[source]¶
Retrieve log messages, with retries.
- Parameters:
channel (
str
) – The channel from which to retrieve log messages.params (
dict
) – Parameters passed to the REST URI.
- Returns:
result – The log messages.
- Return type:
list[dict]
- schedview.collect.get_metric_path()[source]¶
Get the path to a file with numpy metrics
- Returns:
metric_path – The path to the file containing the MAF metric
- Return type:
str
- schedview.collect.get_night_narrative(day_obs, telescope, night_only=True, user_params=None)[source]¶
Get the log messages for a given dayobs.
- Parameters:
day_obs (
DayObs
|str
|int
) – The night of observation.telescope (
str`
) – The telescope for which to get the night report.night_only (
bool
optional) – Include only messages between sunset and sunrise, by default True.user_params (
dict
| None, optional) – Extra parameters for the narrativelog query
- Returns:
messages – A list of dictionaries with log messages.
- Return type:
list[dict]
- schedview.collect.get_night_report(day_obs, telescope, user_params=None)[source]¶
Get the night report data for a night of observing.
- Parameters:
day_obs (
DayObs
|str
|int
) – The night of observation.telescope (
str`
) – The telescope for which to get the night report.user_params (
dict
| None, optional) – Extra parameters for the night report query
- Returns:
night_reports – A list of dictionaries with every version of the night report for the requested night.
- Return type:
list[dict]
- schedview.collect.load_bright_stars(fname=None)[source]¶
Read the Yale Bright Star Catalog into a pandas.DataFrame.
- Parameters:
fname (
str
, optional) – Name of file from which to load the catalog, by default None- Returns:
bright_stars – The catalog of bright stars.
- Return type:
pandas.DataFrame
- async schedview.collect.query_efd_topic_for_night(topic, day_obs, sal_indexes=(1, 2, 3), fields=['*'], db_name='efd')[source]¶
Query and EFD topic for all entries on a night.
- Parameters:
topic (
str
) – The topic to queryday_obs (
DayObs
orstr
orint
) – The date of the start of the night requested.sal_indexes (
tuple[int, ...]
, optional) – Which SAL indexes to query, by default (1, 2, 3). Can be guessed by instrument withSAL_INDEX_GUESSES[instrument]
fields (
list[str]
orNone
, optional) – Fields to query from the topic, by default [‘*’].db_name (
str
, optional) – Which EFD db_name to query:efd
orobsenv
, by defaultefd
.
- Returns:
result – The result of the query
- Return type:
pd.DataFrame
- schedview.collect.read_ddf_visits(opsim_uri, start_time=None, end_time=None, dbcols=None, **kwargs)[source]¶
Read DDF visits from an opsim database.
- Parameters:
opsim_uri (
str
) – The uri from which to load visitsstart_time (
str
,astropy.time.Time
) – The start time for visits to be loadedend_time (
str
,astropy.time.Time
) – The end time for visits ot be loadeddbcols (
Note
oclist
[str
]) – Columns required from the database. Defaults to None, which uses all columns in the database.stackers (
list
[rubin_sim.maf.stackers
], optional) – Stackers to be used to generate additional columns.
- Returns:
visits – The visits and their parameters.
- Return type:
pandas.DataFrame
- schedview.collect.read_multiple_opsims(archive_uri, sim_date, day_obs_mjd)[source]¶
Read results of multiple simulations for a time period from an archive.
- Parameters:
archive_uri (
str
) – The URI of the sim archive.sim_date (
str
) – The date on which the simulations to be run.day_obs_mjd (
int
) – The day_obs MJD of the first night for which to load visits.
- Returns:
visits – Data on the visits.
- Return type:
pandas.DataFrame
- schedview.collect.read_opsim(opsim_uri, start_time=None, end_time=None, constraint=None, dbcols=None, **kwargs)[source]¶
Read visits from an opsim database.
- Parameters:
opsim_uri (
str
) – The uri from which to load visitsstart_time (
str
,astropy.time.Time
) – The start time for visits to be loadedend_time (
str
,astropy.time.Time
) – The end time for visits ot be loadedconstraint (
str
, None) – Query for which visits to load.dbcols (
None
orlist
[str
]) – Columns required from the database. Defaults to None, which queries all columns known to rubin_scheduler.**kwargs – Passed to
maf.get_sim_data
, ifrubin_sim
is available.
- Returns:
visits – The visits and their parameters.
- Return type:
pandas.DataFrame
- schedview.collect.read_rewards(rewards_uri, start_time='2000-01-01', end_time='2100-01-01')[source]¶
Read rewards from an rewards table recorded by the scheduler.
- Parameters:
opsim_uri (
str
) – The uri from which to rewards.start_time (
str
,astropy.time.Time
) – The start time for rewards to be loaded.end_time (
str
,astropy.time.Time
) – The end time for rewards ot be loaded.
- Returns:
rewards_df, obs_rewards – The rewards and obs rewards data frames.
- Return type:
tuple
[pandas.DataFrame
]
- schedview.collect.read_scheduler(file_name_or_url=None)[source]¶
Read an instance of a scheduler object from a pickle.
- Parameters:
file_name (
str
) – The name or URL of the pickle file from which to load the scheduler.- Returns:
scheduler (
rubin_scheduler.scheduler.schedulers.CoreScheduler
) – An instance of a rubin_scheduler scheduler object.conditions (
rubin_scheduler.scheduler.features.Conditions
) – An instance of a rubin_scheduler conditions object.
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
ornp.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', 'filter', 'visitExposureTime'))[source]¶
Compute statistics on time differencse in visits matched across sims.
- Parameters:
visits (
pd.DataFrame
) – _description_sim_identifier_reference_value (
int
orstr
, 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 invisits
whose values need to match to be matched across simulations, by default (“fieldRA”, “fieldDec”, “filter”, “visitExposureTime”)
- Returns:
matched_visit_delta_stats – Statistics for each matched field. The index is a
pandas.MultiIndex
with levels matching those specified byvisit_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', 'filter', '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 insim_identifier_column
andvisit_spec_columns
(below). ThisDataFrame
should include visits from all simulations to be compared, with a column that identifies which simulation each visits was from (sepecified bysim_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”, “filter”, “visitExposureTime”)
- Returns:
visit_counts – A table in which columns listed in the
visit_spec_columns
constitute levels of thepd.MultiIndex
, and each unique value of the column listed insim_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
,) – orastropy.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
,) – orastropy.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_timescheduler_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
ofint
) – 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 dtypedatetime64[ns, UTC]
indexed by simulation id, such thatstart_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 apandas.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).
Plot¶
- schedview.plot.area_timeline_for_tier(rewards_df, tier, day_obs_mjd, show=True, **figure_kwargs)[source]¶
Plot the feasible area timeline for basis funcs in a specified tier.
- Parameters:
rewards_df (
pandas.DataFrame
) – The table of rewards data.tier (
int
) – The tier index, corresponding to the index ofrubin_scheduler.scheduler.schedulers.CoreScheduler.survey_lists
.day_obs_mjd (
int
) – The MJD of the day_obs of the night to plot.show (
bool
) – Actually show the plot? Defaults toTrue
.**figure_kwargs – Keyword arguments passed to
bokeh.plotting.figure
.
- Returns:
`plot` – The plot that can be shown or saved.
- Return type:
bokeh.models.layouts.LayoutDOM
- schedview.plot.create_cadence_plot(nightly_totals, start_dayobs_mjd, end_dayobs_mjd, targets=None, cmap=None, user_plot_kwargs={})[source]¶
“Create a cadence plot for a set of targets.
- Parameters:
nightly_totals (
pandas.DataFrame
) – A DataFrame indexed by"targe_name"
(str
) and"day_obs_iso8601"
(str
in YYYY-MM-DD format), filter names as column names (float
), with total effective exposure times.start_dayobs_mjd (
float
) – The dayobs MJD of the first night in the plot.end_dayobs_mjd (
float
) – The dayobs MJD of the last night in the plot.targets (
list
(str
), optional) – The list of targets for which to make plots. Defaults to the targets included in thenightly_totals
DataFrame.cmap (
bokeh.core.property.vectorization.Field
or `None`(optional)) – Thebokeh
color map as generated bybokeh.transform.factor_cmap
. Defaults to return ofschedview.plot.make_plot_band_cmap()
.user_plot_kwargs (
dict
) – Extra arguments to pass tobokeh.plotting.figure.vbar_stack
. Defaults to{}
.
- Returns:
full_cadence_figure – The bokeh plot with cadence plots for all targets.
- Return type:
bokeh.models.layouts.LayoutDOM
- schedview.plot.create_hpix_visit_map_grid(hpix_maps, visits, conditions, **kwargs)[source]¶
Create a grid of healpix maps with visits overplotted.
Notes
Additional keyword args are passed to map_visits_over_hpix.
- Parameters:
map_hpix (
numpy.array
) – An array of healpix valuesvisits (
pd.DataFrame
) – The table of visits to plot, with columns matching the opsim database definitions.conditions (
rubin_scheduler.scheduler.features.Conditions
) – An instance of a rubin_scheduler conditions object.
- Returns:
plot – The plot with the map
- Return type:
bokeh.models.plots.Plot
- schedview.plot.create_overhead_histogram(visits, bins=array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]), plot=None, **kwargs)[source]¶
Create a histogram of visit overhead times.
Paramaters¶
visits
pandas.DataFrame
The table of visits, with overhead data (see add_overhead)
bins
numpy.ndarray
Bin locations for the histogram.
plot
bokeh.models.plots.Plot
or NoneThe figure on which to plot the histogram. None creates a new figure. Defaults to None.
- returns:
`plot` – The figure with the histogram.
- rtype:
bokeh.models.plots.Plot
- schedview.plot.create_overhead_summary_table(overhead_summary, html=True)[source]¶
Make a formatted table from an overhead summary dictionary
- Parameters:
overhead_summary (
dict
) – A dictionary of summary values, as computed byschedview.compute.visits.compute_overhead_summary
html (
bool
) – Format the table with html? Defaults to True
- Returns:
`summary` – Formatted summary.
- Return type:
str
- schedview.plot.create_survey_reward_plot(scheduler, night_date, additional_visits=None, observatory=None, timezone='Chile/Continental')[source]¶
Build a plot of rewards by survey for a time period.
- Parameters:
scheduler (
rubin_scheduler.scheduler.schedulers.Core_scheduler
orstr
) – The scheduler with the surveys to evaluate, or the name of a file from which such a scheduler should be loaded.night_date (
astropy.time.Time
) – A time during the night to plot.additional_visits (
pandas.DataFrame
orstr
, optional) – Visits to add to the scheduler before reward evaluation, by default Noneobservatory (
ModelObservatory
, optional) – Provides the location of the observatory, used to compute night start and end times. By default Nonetimezone (
str
, optional) – Timezone for horizontal axis, by default “Chile/Continental”
- Returns:
figure (
bokeh.plotting.figure
) – The figure itself.data (
dict
) – The arguments used to produce the figure usingplot_survey_rewards
.
- schedview.plot.create_visit_explorer(visits, night_date, observatory=None, timezone='Chile/Continental')[source]¶
Create an explorer to interactively examine a set of visits.
- Parameters:
visits (
str
orpandas.DataFrame
) – One row per visit, as created byschedview.collect.read_opsim
, or the name of a file from which such visits should be loaded.night_date (
datetime.date
) – The calendar date in the evening local time.observatory (
ModelObservatory
, optional) – Provides the location of the observatory, used to compute night start and end times. By default None.timezone (
str
, optional) – _description_, by default “Chile/Continental”
- Returns:
figure (
hvplot.ui.hvDataFrameExplorer
) – The figure itself.data (
dict
) – The arguments used to produce the figure usingplot_visits
.
- schedview.plot.create_visit_skymaps(visits, night_date, nside=32, observatory=None, timezone='Chile/Continental', planisphere_only=False)[source]¶
Create a map of visits on the sky.
- Parameters:
visits (
pandas.DataFrame
orstr
) –If a
pandas.DataFrame
, it needs at least the following columns:"fieldRA"
The visit R.A. in degrees (
float
)."fieldDec"
The visit declination in degrees (
float
)."observationStartMJD"
The visit start MJD (
float
)."filter"
The visit filter (
str
)
If a string, the file name of the opsim database from which the visits should be loaded.
night_date (
datetime.date
) – The calendar date of the evening of the night for which to plot the visits.nside (
int
, optional) – The healpix nside to use for the map.observatory (
ModelObservatory
, optional) – Provides the location of the observatory, used to compute night start and end times. By default None.timezone (
str
, optional) – by default “Chile/Continental”planisphere_only (
bool
) – by default False
- Returns:
figure (
bokeh.models.layouts.LayoutDOM
) – The figure itself.data (
dict
) – The arguments used to produce the figure usingplot_visit_skymaps
.
- schedview.plot.create_visit_table(visits, visible_column_names=['observationId', 'observationStartMJD', 'fieldRA', 'fieldDec', 'filter'], show=True, **data_table_kwargs)[source]¶
Create an interactive table of visits.
- Parameters:
visits (
pd.DataFrame
orbokeh.models.ColumnarDataSource
) – The visits to include in the tablevisible_column_names (
list[str]
) – The columns to display, by default [‘observationId’, ‘observationStartMJD’, ‘fieldRA’, ‘fieldDec’, ‘filter’]show (
bool
) – Show the plot?, by default Truedata_table_kwargs (
Optional
[Any
])
- Returns:
element – The bokeh UI element with the table.
- Return type:
bokeh.models.ui.ui_element.UIElement
- schedview.plot.generate_sim_indicators(sim_labels)[source]¶
Generate a tuple of simulation indicators for bokeh.
- Parameters:
sim_labels (
list
[str
]) – A list of simulation labels.- Returns:
sim_indicators – A named tuple with:
color_mapper
The bokeh color mapper to map sim labels to colors.
color_dict
A python dictionary representing the same mapping as
color_mapper
, above.marker_mapper
The bokeh mapper to map sim labels to bokeh markers.
hatch_dict
A python dict to map sim labels to bokeh hatch styles.
- Return type:
SimIndicators
- schedview.plot.make_band_cmap(field_name='band')[source]¶
Make a bokeh cmap transform for bands
- Parameters:
field_name (
str
) – Name of field with the band value.- Returns:
cmap – The bokeh color map.
- Return type:
bokeh.core.property.vectorization.Field
- schedview.plot.map_survey_healpix(mjd, hpix_data, map_key, nside, map_class=<class 'uranography.horizon.HorizonMap'>, map_kwargs=None, cmap=None, cmap_scale='full', conditions=None, survey=None)[source]¶
Map a healpix map of a survey at a given MJD.
- Parameters:
mjd (
float
) – The MJD at which to map the survey.hpix_data (
dict
) – A dictionary of healpix maps. The map withmap_key
will be mapped to pixel color, and others will be shown in the hover tool.map_key (
str
) – The key in hpix_data corresponding to the healpix map to display.nside (
int
) – The nside at which to show the healpix maps.map_class (
class
, optional) – The class of map to use. Defaults to uranography.HorizonMap.map_kwargs (
dict
, optional) – Keyword arguments to pass to map_class.cmap (
bokeh.models.mappers.ColorMapper
, optional) – A color mapper to use for the map. Defaults to a linear cmap with the “Inferno256” palette.cmap_scale (
str
, optional) – The scale to use for the cmap. Defaults to “full”, which uses the full range of values in the healpix map. Alternatively, “zscale” can be used to use a zscale cmap.conditions (
rubin_scheduler.scheduler.features.Conditions
, optional) – Default is None. The observing conditions at which to map the survey, used to determine telescope pointing. If None, do not mark telescope pointing.survey (
rubin_scheduler.scheduler.surveys.BaseSurvey
, optional) – Default is None. The survey with fields to mark on the map. If None or an unsuitable survey type, do not mark survey fields.
- Returns:
sky_map – The map of the sky.
- Return type:
uranography.SphereMap
- schedview.plot.map_visits_over_hpix(visits, conditions, map_hpix, plot=None, scale_limits=None, palette=['#f0f0f0', '#eff0f0', '#efeff0', '#eeeff0', '#edeef0', '#eceef0', '#ebedf0', '#ebedf0', '#eaecf0', '#e9ecf0', '#e8ebef', '#e8ebef', '#e7eaef', '#e6eaef', '#e5e9ef', '#e5e9ef', '#e4e9ef', '#e3e8ef', '#e2e8ef', '#e2e7ef', '#e1e7ef', '#e0e6ef', '#dfe6ef', '#dfe5ef', '#dee5ee', '#dde4ee', '#dce4ee', '#dbe3ee', '#dbe3ee', '#dae2ee', '#d9e2ee', '#d8e1ee', '#d8e1ee', '#d7e0ee', '#d6e0ee', '#d5e0ee', '#d5dfed', '#d4dfed', '#d3deed', '#d2deed', '#d2dded', '#d1dded', '#d0dced', '#cfdced', '#cedbed', '#cedbed', '#cddaed', '#ccdaec', '#cbd9ec', '#cbd9ec', '#cad9ec', '#c9d8ec', '#c8d8ec', '#c8d7ec', '#c7d7ec', '#c6d6ec', '#c5d6eb', '#c5d5eb', '#c4d5eb', '#c3d4eb', '#c2d4eb', '#c1d3eb', '#c1d3eb', '#c0d2eb', '#bfd2eb', '#bed2ea', '#bed1ea', '#bdd1ea', '#bcd0ea', '#bbd0ea', '#bbcfea', '#bacfea', '#b9ceea', '#b8cee9', '#b8cde9', '#b7cde9', '#b6cce9', '#b5cce9', '#b5cbe9', '#b4cbe8', '#b3cbe8', '#b2cae8', '#b2cae8', '#b1c9e8', '#b0c9e8', '#afc8e8', '#afc8e7', '#aec7e7', '#adc7e7', '#acc6e7', '#acc6e7', '#abc5e6', '#aac5e6', '#a9c5e6', '#a9c4e6', '#a8c4e6', '#a7c3e5', '#a6c3e5', '#a6c2e5', '#a5c2e5', '#a4c1e5', '#a4c1e4', '#a3c0e4', '#a2c0e4', '#a1bfe4', '#a1bfe3', '#a0bee3', '#9fbee3', '#9fbee3', '#9ebde2', '#9dbde2', '#9dbce2', '#9cbce1', '#9bbbe1', '#9bbbe1', '#9abae0', '#9abae0', '#99b9e0', '#98b9df', '#98b8df', '#97b8df', '#97b7de', '#96b7de', '#95b7de', '#95b6dd', '#94b6dd', '#94b5dc', '#93b5dc', '#92b4dc', '#92b4db', '#91b3db', '#91b3da', '#90b2da', '#8fb2da', '#8fb1d9', '#8eb1d9', '#8eb0d9', '#8db0d8', '#8dafd8', '#8cafd7', '#8bafd7', '#8baed6', '#8aaed6', '#8aadd6', '#89add5', '#89acd5', '#88acd4', '#88abd4', '#87abd4', '#87aad3', '#86aad3', '#86a9d2', '#85a9d2', '#84a8d1', '#84a8d1', '#83a7d0', '#83a7d0', '#82a7cf', '#82a6cf', '#81a6cf', '#81a5ce', '#80a5ce', '#80a4cd', '#7fa4cd', '#7fa3cc', '#7ea3cc', '#7ea2cb', '#7da2cb', '#7da1ca', '#7ca1ca', '#7ca0c9', '#7ca0c9', '#7ba0c8', '#7b9fc8', '#7a9fc7', '#799ec7', '#799ec7', '#789dc6', '#789dc6', '#779cc5', '#779cc5', '#769bc4', '#769bc4', '#759ac4', '#749ac3', '#749ac3', '#7399c3', '#7399c2', '#7298c2', '#7198c2', '#7197c1', '#7097c1', '#7096c1', '#6f96c0', '#6e95c0', '#6e95c0', '#6d95bf', '#6c94bf', '#6c94bf', '#6b93be', '#6a93be', '#6a92be', '#6992bd', '#6891bd', '#6791bd', '#6791bd', '#6690bc', '#6590bc', '#658fbc', '#648fbb', '#638ebb', '#628ebb', '#628dbb', '#618dba', '#608dba', '#5f8cba', '#5f8cba', '#5e8bb9', '#5d8bb9', '#5c8ab9', '#5b8ab9', '#5b8ab8', '#5a89b8', '#5989b8', '#5888b8', '#5788b7', '#5787b7', '#5687b7', '#5586b7', '#5486b7', '#5386b6', '#5285b6', '#5185b6', '#5084b6', '#5084b5', '#4f83b5', '#4e83b5', '#4d83b5', '#4c82b5', '#4b82b4', '#4a81b4', '#4981b4', '#4880b4', '#4780b4', '#4680b3', '#457fb3', '#447fb3', '#437eb3', '#427eb3', '#417eb2', '#407db2', '#3f7db2', '#3e7cb2', '#3c7cb2', '#3b7bb2', '#3a7bb1'], map_class=<class 'uranography.planisphere.Planisphere'>, prerender_hpix=True)[source]¶
Plot visit locations over a healpix map.
- Parameters:
visits (
pd.DataFrame
) – The table of visits to plot, with columns matching the opsim database definitions.conditions (
rubin_scheduler.scheduler.features.Conditions
) – An instance of a rubin_scheduler conditions object.map_hpix (
numpy.array
) – An array of healpix valuesplot (
bokeh.models.plots.Plot
orNone
) – The bokeh plot on which to make the plot. None creates a new plot. None by default.scale_limits (
list
offloat
orNone
) – The scale limits for the healpix values. If None, use zscale to set the scale.palette (
str
) – The bokeh palette to use for the healpix map.map_class (
class
, optional) – The class of map to use. Defaults to uranography.Planisphere.prerender_hpix (
bool
, optional) – Pre-render the healpix map? Defaults to True
- Returns:
plot – The plot with the map
- Return type:
bokeh.models.plots.Plot
- schedview.plot.overplot_kernel_density_estimates(visits, column, x_points, bandwidth, colors=None, hatches=None, kernel='epanechnikov', fig=None)[source]¶
Overplot density estimates of distributions from different sims.
Paramaters¶
- visits
pandas.DataFrame
The visits.
- column
str
The column in the visits table of which to estimate the distribution.
- x_points
np.ndarray
An array of points at which to compute the density estimates.
- bandwith
float
The kernel bandwidth.
- colors
dict
A mapping from sim label to bokeh color.
- hatches
dict
A mapping from sim label to bokeh hatch pattern.
- kernel
str
The kernel to use. See the sklearn.neighbors.KernelDensity documentation for the options and what they mean.
- fig:
bokeh.plotting.figure
or None The figure on which to plot. None creates a new figure.
- returns:
fig – The figure with the plot.
- rtype:
bokeh.plotting.figure
- param visits:
- type visits:
DataFrame
- param column:
- type column:
str
- param x_points:
- type x_points:
ndarray
- param bandwidth:
- type bandwidth:
float
- param colors:
- type colors:
dict
|None
, default:None
- param hatches:
- type hatches:
dict
|None
, default:None
- param kernel:
- type kernel:
Literal
['gaussian'
,'tophat'
,'epanechnikov'
,'exponential'
,'linear'
,'cosine'
], default:'epanechnikov'
- param fig:
- type fig:
figure
|None
, default:None
- visits
- schedview.plot.plot_airmass_vs_time(visits, almanac_events, band_colors={'g': '#008060', 'i': '#850000', 'r': '#ff4000', 'u': '#56b4e9', 'y': '#222222', 'z': '#6600cc'}, event_labels={'moonrise': 'moonrise', 'moonset': 'moonset', 'night_middle': None, 'sun_n12_rising': 'sun alt=-12°', 'sun_n12_setting': 'sun alt=-12°', 'sun_n18_rising': 'sun alt=-18°', 'sun_n18_setting': 'sun alt=-18°', 'sunrise': 'sunrise', 'sunset': 'sunset'}, event_colors={'moonrise': 'green', 'moonset': 'green', 'night_middle': None, 'sun_n12_rising': 'blue', 'sun_n12_setting': 'blue', 'sun_n18_rising': 'lightblue', 'sun_n18_setting': 'lightblue', 'sunrise': 'darkblue', 'sunset': 'darkblue'}, figure=None)[source]¶
Plot airmass vs. time for a set of visits
- Parameters:
visits (
pandas.DataFrame
orbokeh.models.ColumnDataSource
) – Dataframe or ColumnDataSource containing visit information.almanac_events (
pandas.DataFrame
) – Dataframe containing almanac events.band_colors (
dict
) – Mapping of filter names to colors. Default isBAND_COLORS
.event_labels (
dict
) – Mapping of almanac events to labels. Default isDEFAULT_EVENT_LABELS
.event_colors (
dict
) – Mapping of almanac events to colors. Default isDEFAULT_EVENT_COLORS
.figure (
bokeh.plotting.Figure
) – Bokeh figure object to plot on. If None, a new figure will be created.
- Returns:
fig – Bokeh figure object
- Return type:
bokeh.plotting.Figure
- schedview.plot.plot_alt_vs_time(visits, almanac_events, band_shapes={'g': 'diamond', 'i': 'star', 'r': 'square', 'u': 'triangle', 'y': 'circle', 'z': 'hex'}, event_labels={'moonrise': 'moonrise', 'moonset': 'moonset', 'night_middle': None, 'sun_n12_rising': 'sun alt=-12°', 'sun_n12_setting': 'sun alt=-12°', 'sun_n18_rising': 'sun alt=-18°', 'sun_n18_setting': 'sun alt=-18°', 'sunrise': 'sunrise', 'sunset': 'sunset'}, event_colors={'moonrise': 'green', 'moonset': 'green', 'night_middle': None, 'sun_n12_rising': 'blue', 'sun_n12_setting': 'blue', 'sun_n18_rising': 'lightblue', 'sun_n18_setting': 'lightblue', 'sunrise': 'darkblue', 'sunset': 'darkblue'}, figure=None, note_column=None)[source]¶
Plot airmass vs. time for a set of visits
- Parameters:
visits (
pandas.DataFrame
orbokeh.models.ColumnDataSource
) – Dataframe or ColumnDataSource containing visit information.almanac_events (
pandas.DataFrame
) – Dataframe containing almanac events.band_colors (
dict
) – Mapping of filter names to colors. Default isBAND_COLORS
.event_labels (
dict
) – Mapping of almanac events to labels. Default isDEFAULT_EVENT_LABELS
.event_colors (
dict
) – Mapping of almanac events to colors. Default isDEFAULT_EVENT_COLORS
.figure (
bokeh.plotting.Figure
) – Bokeh figure object to plot on. If None, a new figure will be created.note_column (
str
or None) – The column to use as the note to map to color. Defaults to None, which defaultsscheduler_note
if it is present in the visit datasource, otherwisenote
.
- Returns:
fig – Bokeh figure object
- Return type:
bokeh.plotting.Figure
- schedview.plot.plot_infeasible(reward_df, tier_label, night, observatory=None, surveys=None, plot_kwargs={})[source]¶
Create a plot showing infeasible basis functions.
- Parameters:
reward_df (
pandas.DataFrame
) – The rewards by survey, as recorded by thescheduler
instance when running the simulation.tier_label (
str
) – The label for the tier to plot.night (
astropy.time.Time
) – The night to plot.observatory (
ModelObservatory
) – The model observatory to use.surveys (
list
[str
], optional) – A list of the survey names to plot. Default to all surveys in the tier.plot_kwards (
dict
) – A dictionary of keyword parameters passed tobokeh.plotting.figure
.
- Returns:
app – The figure itself.
- Return type:
bokeh.plotting.figure
- schedview.plot.plot_overhead_vs_slew_distance(visits, plot=None, **kwargs)[source]¶
Plot visit overhead times.
Paramaters¶
visits
pandas.DataFrame
The table of visits, with overhead data (see add_overhead)
bins
numpy.ndarray
Bin locations for the histogram.
plot
bokeh.models.plots.Plot
or NoneThe figure on which to plot the histogram. None creates a new figure. Defaults to None.
- returns:
`plot` – The figure with the histogram.
- rtype:
bokeh.models.plots.Plot
- schedview.plot.plot_polar_alt_az(visits, band_shapes={'g': 'diamond', 'i': 'star', 'r': 'square', 'u': 'triangle', 'y': 'circle', 'z': 'hex'}, figure=None, legend=True, note_column=None)[source]¶
Plot airmass vs. time for a set of visits
- Parameters:
visits (
pandas.DataFrame
orbokeh.models.ColumnDataSource
) – Dataframe or ColumnDataSource containing visit information.almanac_events (
pandas.DataFrame
) – Dataframe containing almanac events.band_colors (
dict
) – Mapping of filter names to colors. Default isBAND_COLORS
.figure (
bokeh.plotting.Figure
) – Bokeh figure object to plot on. If None, a new figure will be created.legend (
bool
) – Generate a legend. Default is True.
- Returns:
fig – Bokeh figure object
- Return type:
bokeh.plotting.Figure
- schedview.plot.plot_rewards(reward_df, tier_label, night, observatory=None, obs_rewards=None, surveys=None, basis_function='Total', plot_kwargs={})[source]¶
Create the plot showing reward values by survey.
- Parameters:
reward_df (
pandas.DataFrame
) – The rewards by survey, as recorded by thescheduler
instance when running the simulation.tier_label (
str
) – The label for the tier to plot.night (
astropy.time.Time
) – The night to plot.observatory (
ModelObservatory
) – The model observatory to use.obs_rewards (
pandas.DataFrame
) – The mapping between scheduler calls and simulated observations, as recorded by thescheduler
instance.surveys (
list
[str
], optional) – A list of the survey names to plot. Default to all surveys in the tier.basis_funtions (
list
[str
], optional) – A list of names of basis function to plot. Defaults to all basis functions in the tier.plot_kwards (
dict
) – A dictionary of keyword parameters passed tobokeh.plotting.figure
.
- Returns:
app – The figure itself.
- Return type:
bokeh.plotting.figure
- schedview.plot.plot_survey_rewards(rewards)[source]¶
Plot survey rewards as a function of time.
- Parameters:
rewards (
pandas.DataFrame
) –Data with at least these columns:
"survey_name"
The name of the survey (
str
)."time"
The sample time for the reward (
datetime64[ns]
)."reward"
The reward (
float
).
- Returns:
reward_plot – The figure.
- Return type:
bokeh.plotting.figure
- schedview.plot.plot_visit_param_vs_time(visits, column_name, plot=None, show_column_selector=False, hovertool=True, **kwargs)[source]¶
Plot a column in the visit table vs. time.
- Parameters:
visits (
DataFrame
) – One row per visit, as created byschedview.collect.opsim.read_opsim
.column_name (
str
) – The name of the column to plot against time.plot (
figure
|None
, default:None
) – The figure on which to plot the visits. None creates a new figure. Defaults to None.show_column_selector (
bool
, default:False
) – Include a drop-down to select which column to plot? Defaults to False.visits
column_name
plot
show_column_selector
hovertool (
bool
, default:True
)
- Returns:
`plot` – The figure with the plot.
- Return type:
bokeh.models.plots.Plot
- schedview.plot.plot_visit_skymaps(visits, footprint, conditions, hatch=False, fade_scale=0.001388888888888889, camera_perimeter='LSST', nside_low=8, show_stars=False, map_classes=[<class 'uranography.armillary.ArmillarySphere'>, <class 'uranography.planisphere.Planisphere'>])[source]¶
Plot visits on a map of the sky.
- Parameters:
visits (
pandas.DataFrame
) –One row per visit, with at least the following columns:
"fieldRA"
The visit R.A. in degrees (
float
)."fieldDec"
The visit declination in degrees (
float
)."observationStartMJD"
The visit start MJD (
float
)."filter"
The visit filter (
str
)
footprint (
numpy.array
) – A healpix map of the footprint.conditions (
rubin_scheduler.scheduler.features.conditions.Conditions
) – The conditions for the night, which determines the start and end times covered by the map.hatch (
bool
) – Use hatches instead of filling visit polygons. (SLOW!)fade_scale (
float
) – Time (in days) over which visit outlines fade.camera_perimeter (
str
orobject
) – An function that returns the perimeter of the camera footprint, or “LSST” for the LSST camera footprint. Defaults to “LSST”.nside_low (
int
) – The healpix nside to try to use for low resolution sections of the healpix map.show_stars (
bool
) – Show stars? (Defaults to False)
- Returns:
fig – A bokeh element that can be displayed, or incorporated into a larger element.
- Return type:
bokeh.models.layouts.LayoutDOM
- schedview.plot.plot_visits(visits)[source]¶
Instantiate an explorer to interactively examine a set of visits.
- Parameters:
visits (
pandas.DataFrame
) – One row per visit, as created byschedview.collect.read_opsim
- Returns:
figure – The figure itself.
- Return type:
hvplot.ui.hvDataFrameExplorer
- schedview.plot.reward_timeline_for_surveys(rewards_df, day_obs_mjd, show=True, **figure_kwargs)[source]¶
Plot the reward timeline for all surveys.
- Parameters:
rewards_df (
pandas.DataFrame
) – The table of rewards data.day_obs_mjd (
int
) – The MJD of the day_obs of the night to plot.show (
bool
) – Actually show the plot? Defaults toTrue
.**figure_kwargs – Keyword arguments passed to
bokeh.plotting.figure
.
- Returns:
`plot` – The plot that can be shown or saved.
- Return type:
bokeh.models.layouts.LayoutDOM
- schedview.plot.reward_timeline_for_tier(rewards_df, tier, day_obs_mjd, show=True, **figure_kwargs)[source]¶
Plot the reward timeline for basis functions in a specified tier.
- Parameters:
rewards_df (
pandas.DataFrame
) – The table of rewards data.tier (
int
) – The tier index, corresponding to the index ofrubin_scheduler.scheduler.schedulers.CoreScheduler.survey_lists
.day_obs_mjd (
int
) – The MJD of the day_obs of the night to plot.show (
bool
) – Actually show the plot? Defaults toTrue
.**figure_kwargs – Keyword arguments passed to
bokeh.plotting.figure
.
- Returns:
`plot` – The plot that can be shown or saved.
- Return type:
bokeh.models.layouts.LayoutDOM
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
] ordict
[‘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 radiansdecl (
float
) – declination as a float in radianssep (
float
) – separation in radiansbearing (
float
) – bearing (east of north) in radiansdegrees (
bool
) – arguments and returnes are in degrees (False for radians).
- Returns:
ra (
float
) – R.A. Right Ascensiondecl (
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 rotationuy (
float
) – y coordinate of a point on the axis of rotationuz (
float
) – z coordinate of a point on the axis of rotationangle (
float
) – Magnitude of the rotation.x0 (
float
) – Input x coordinatey0 (
float
) – Input y coordinatez0 (
float
) – Input z coordinate
- Returns:
ux (
float
) – Output x coordinateuy (
float
) – Output y coordinateuz (
float
) – Output z coordinate