Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ruff.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ jobs:
- uses: psf/black@stable
with:
options: "--check --verbose"
version: "~= 26.1"
version: "~= 26.1"
12 changes: 1 addition & 11 deletions schedview/plot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"plot_obs_vs_sim_time",
"plot_polar_alt_az",
"plot_survey_rewards",
"create_survey_reward_plot",
"reward_timeline_for_tier",
"area_timeline_for_tier",
"reward_timeline_for_surveys",
Expand All @@ -23,7 +22,6 @@
"create_hpix_visit_map_grid",
"plot_visits",
"plot_visit_param_vs_time",
"create_visit_explorer",
"create_overhead_summary_table",
"create_overhead_histogram",
"plot_overhead_vs_slew_distance",
Expand Down Expand Up @@ -56,21 +54,13 @@
from .progress import make_metric_line_plots
from .rewards import (
area_timeline_for_tier,
create_survey_reward_plot,
plot_survey_rewards,
reward_timeline_for_surveys,
reward_timeline_for_tier,
)
from .scheduler import (
BadConditionsError,
BadSchedulerError,
SchedulerDisplay,
SchedulerNotebookDisplay,
make_logger,
)
from .sim_archive import make_html_table_of_sim_archive_metadata
from .survey import create_hpix_visit_map_grid, map_survey_healpix, map_visits_over_hpix
from .timeline import make_timeline_scatterplots
from .util import mpl_fig_to_html
from .visitmap import create_visit_skymaps, plot_visit_planisphere, plot_visit_skymaps
from .visits import create_visit_explorer, create_visit_table, plot_visit_param_vs_time, plot_visits
from .visits import create_visit_table, plot_visit_param_vs_time, plot_visits
71 changes: 0 additions & 71 deletions schedview/plot/rewards.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import warnings
from collections.abc import Callable

import bokeh
Expand All @@ -11,18 +10,12 @@
import holoviews as hv
import numpy as np
import pandas as pd
from astropy.time import Time

# Imported to help sphinx make the link
from rubin_scheduler.scheduler.model_observatory import ModelObservatory # noqa F401

import schedview.compute.astro
import schedview.compute.scheduler
from schedview.collect import read_opsim, read_scheduler

__all__ = [
"plot_survey_rewards",
"create_survey_reward_plot",
"reward_timeline_for_tier",
"area_timeline_for_tier",
"reward_timeline_for_surveys",
Expand Down Expand Up @@ -58,70 +51,6 @@ def plot_survey_rewards(rewards):
return reward_plot


def create_survey_reward_plot(
scheduler,
night_date,
additional_visits=None,
observatory=None,
timezone="Chile/Continental",
):
"""Build a plot of rewards by survey for a time period.

Parameters
----------
scheduler : `rubin_scheduler.scheduler.schedulers.Core_scheduler` or `str`
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` or `str`, optional
Visits to add to the scheduler before reward evaluation,
by default None
observatory : `ModelObservatory`, optional
Provides the location of the observatory, used to compute
night start and end times.
By default None
timezone : `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 using
`plot_survey_rewards`.
"""

site = None if observatory is None else observatory.location

# Collect
if isinstance(scheduler, str):
scheduler, conditions = read_scheduler(scheduler)
scheduler.update_conditions(conditions)

if isinstance(additional_visits, str):
night_events = schedview.compute.astro.night_events(
night_date=night_date, site=site, timezone=timezone
)
start_time = Time(night_events.loc["sunset", "UTC"])
end_time = Time(night_events.loc["sunrise", "UTC"])
additional_visits = read_opsim(additional_visits, Time(start_time).iso, Time(end_time).iso)

# Compute
if additional_visits is not None:
schedview.compute.scheduler.replay_visits(scheduler, additional_visits)

with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=FutureWarning)
rewards = schedview.compute.scheduler.compute_basis_function_rewards(scheduler)

# Plot
data = {"rewards": rewards}
reward_plot = hv.render(plot_survey_rewards(**data))
return reward_plot, data


def make_timeline_bars(
df,
factor_column,
Expand Down
7 changes: 6 additions & 1 deletion schedview/plot/visitmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import schedview.compute.astro
from schedview import band_column
from schedview.collect import load_bright_stars, read_opsim
from schedview.compute.camera import LsstCameraFootprintPerimeter
from schedview.compute.footprint import find_healpix_area_polygons
from schedview.plot import PLOT_BAND_COLORS
Expand Down Expand Up @@ -254,6 +253,9 @@ def plot_visit_skymaps(
)

if show_stars:
# Import here to avoid schedview.collect dependency unless necessary.
from schedview.collect.stars import load_bright_stars

star_data = load_bright_stars().loc[:, ["name", "ra", "decl", "Vmag"]]
star_data["glyph_size"] = 15 - (15.0 / 3.5) * star_data["Vmag"]
star_data.query("glyph_size>0", inplace=True)
Expand Down Expand Up @@ -359,6 +361,9 @@ def create_visit_skymaps(
end_time = Time(night_events.loc["sunrise", "UTC"])

if isinstance(visits, str):
# Import here to avoid collect dependency unless necessary
from schedview.collect.opsim import read_opsim

visits = read_opsim(visits)

if start_time is not None:
Expand Down
44 changes: 0 additions & 44 deletions schedview/plot/visits.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@
import hvplot
import numpy as np
import pandas as pd
from astropy.time import Time

# Imported to help sphinx make the link
from rubin_scheduler.scheduler.model_observatory import ModelObservatory # noqa F401

import schedview.compute.astro
from schedview import band_column
from schedview.collect import read_opsim

from .colors import make_band_cmap

Expand Down Expand Up @@ -122,47 +119,6 @@ def plot_visits(visits):
return visit_explorer


def create_visit_explorer(visits, night_date, observatory=None, timezone="Chile/Continental"):
"""Create an explorer to interactively examine a set of visits.

Parameters
----------
visits : `str` or `pandas.DataFrame`
One row per visit, as created by `schedview.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 using
`plot_visits`.
"""
site = None if observatory is None else observatory.location
night_events = schedview.compute.astro.night_events(night_date=night_date, site=site, timezone=timezone)
start_time = Time(night_events.loc["sunset", "UTC"])
end_time = Time(night_events.loc["sunrise", "UTC"])

# Collect
if isinstance(visits, str):
visits = read_opsim(visits, Time(start_time).iso, Time(end_time).iso)

# Plot
data = {"visits": visits}
visit_explorer = plot_visits(visits)

return visit_explorer, data


def plot_visit_param_vs_time(
visits: pd.DataFrame,
column_name: str | Iterable[str],
Expand Down
Loading