From 7bf8ee61fdc12cad539a3fb8b1693267c7270173 Mon Sep 17 00:00:00 2001 From: Eric Neilsen Date: Wed, 10 Dec 2025 08:27:59 -0800 Subject: [PATCH] Switch from science verification to survey visits table summary --- schedview/compute/visits.py | 17 +++++++---------- schedview/plot/__init__.py | 2 +- schedview/plot/overhead.py | 12 ++++++------ ..._summary.py => test_survey_visit_summary.py} | 6 +++--- 4 files changed, 17 insertions(+), 20 deletions(-) rename tests/{test_sv_summary.py => test_survey_visit_summary.py} (78%) diff --git a/schedview/compute/visits.py b/schedview/compute/visits.py index 3611b842..dd55c878 100644 --- a/schedview/compute/visits.py +++ b/schedview/compute/visits.py @@ -150,7 +150,7 @@ def compute_overhead_summary(visits, sun_n12_setting, sun_n12_rising): return summary -def compute_sv_summary(visits, sun_n12_setting, sunrise, time_before_sunrise=2): +def compute_survey_visit_summary(visits, sun_n12_setting, sun_n12_rising): """Create a dictionary of science validation survey summary stats. Parameters @@ -159,24 +159,21 @@ def compute_sv_summary(visits, sun_n12_setting, sunrise, time_before_sunrise=2): The table of visits. Assumes all SV visits. `sun_n12_setting`: `float` The MJD of evening twilight. - `sunrise`: `float` - The MJD of sunrise. - `time_before_sunrise`: `float` - Time before sunrise that SV survey stops. Default 2 (hours). + `sun_n12_rising`: `float` + The MJD of morning twilight. Returns ------- `summary` : `dict` A dictionary of summary statistics """ - - time_available = (sunrise - sun_n12_setting) * 24 - time_before_sunrise + n12_night_time = (sun_n12_rising - sun_n12_setting) * 24 initial_pairs = np.sum([("pair" in note) & (", a" in note) for note in visits["scheduler_note"]]) final_pairs = np.sum([("pair" in note) & (", b" in note) for note in visits["scheduler_note"]]) # Could do a check to make sure all the visits are for the SV - n_sv_visits = np.size(visits["scheduler_note"]) + n_survey_visits = np.size(visits["scheduler_note"]) u_note = np.unique(visits["scheduler_note"]) ddf_names = np.unique([note.split(":")[1].split(",")[0] for note in u_note if "DD:" in note]) @@ -192,8 +189,8 @@ def compute_sv_summary(visits, sun_n12_setting, sunrise, time_before_sunrise=2): too_names = "-" summary = { - "time_avail": time_available, - "n_sv_visits": n_sv_visits, + "n12_night_time": n12_night_time, + "n_survey_visits": n_survey_visits, "n_pairs_started": initial_pairs, "n_pairs_finished": final_pairs, "ddfs_observed": ddf_names, diff --git a/schedview/plot/__init__.py b/schedview/plot/__init__.py index a03ab3e6..99cb0de4 100644 --- a/schedview/plot/__init__.py +++ b/schedview/plot/__init__.py @@ -45,7 +45,7 @@ from .overhead import ( create_overhead_histogram, create_overhead_summary_table, - create_sv_summary_table, + create_survey_visit_summary_table, plot_overhead_vs_slew_distance, ) from .rewards import ( diff --git a/schedview/plot/overhead.py b/schedview/plot/overhead.py index da304362..b9a42b7d 100644 --- a/schedview/plot/overhead.py +++ b/schedview/plot/overhead.py @@ -48,14 +48,14 @@ def create_table(summary_dict, stat_name, stat_str_template, html=True): return result -def create_sv_summary_table(sv_summary, html=True): +def create_survey_visit_summary_table(sv_summary, html=True): """Make a formatted table from an sv summary dictionary Parameters ---------- `sv_summary`: `dict` A dictionary of summary values, as computed by - `schedview.compute.visits.compute_sv_summary` + `schedview.compute.visits.compute_survey_visit_summary` `html`: `bool` Format the table with html? Defaults to True @@ -66,16 +66,16 @@ def create_sv_summary_table(sv_summary, html=True): """ stat_name = { - "time_avail": "Time available for SV visits", - "n_sv_visits": "Number of sv visits in night", + "n12_night_time": "Time between 12 degree evening and morning twilights", + "n_survey_visits": "Number of survey visits in night", "n_pairs_started": "Number of pairs started", "n_pairs_finished": "Number of pairs finished", "ddfs_observed": "DDFs Observed", "too_observed": "ToOs Observed", } stat_str_template = { - "time_avail": "{:5.2f} hours", - "n_sv_visits": "{}", + "n12_night_time": "{:5.2f} hours", + "n_survey_visits": "{}", "n_pairs_started": "{}", "n_pairs_finished": "{}", "ddfs_observed": "{}", diff --git a/tests/test_sv_summary.py b/tests/test_survey_visit_summary.py similarity index 78% rename from tests/test_sv_summary.py rename to tests/test_survey_visit_summary.py index 45dd35ff..c53ba785 100644 --- a/tests/test_sv_summary.py +++ b/tests/test_survey_visit_summary.py @@ -9,7 +9,7 @@ import schedview.plot -class TestSvSummary(unittest.TestCase): +class TestSurveyVisitSummary(unittest.TestCase): @classmethod def setUpClass(cls): @@ -21,8 +21,8 @@ def setUpClass(cls): cls.visits = schedview.compute.visits.add_overhead(cls.visits) def test_sv_summary(self): - sv_summary = schedview.compute.visits.compute_sv_summary( + sv_summary = schedview.compute.visits.compute_survey_visit_summary( self.visits, self.start_time.mjd, self.end_time.mjd ) - summary = schedview.plot.overhead.create_sv_summary_table(sv_summary) + summary = schedview.plot.overhead.create_survey_visit_summary_table(sv_summary) self.assertIsInstance(summary, str)