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
17 changes: 7 additions & 10 deletions schedview/compute/visits.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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])
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion schedview/plot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
12 changes: 6 additions & 6 deletions schedview/plot/overhead.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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": "{}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import schedview.plot


class TestSvSummary(unittest.TestCase):
class TestSurveyVisitSummary(unittest.TestCase):

@classmethod
def setUpClass(cls):
Expand All @@ -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)
Loading