Skip to content

Commit

Permalink
modelobservatory can run all the way to sunrise and set
Browse files Browse the repository at this point in the history
  • Loading branch information
yoachim committed Dec 14, 2023
1 parent e2b429c commit 300d280
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions rubin_scheduler/scheduler/model_observatory/model_observatory.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ def __init__(
downtimes=None,
no_sky=False,
wind_data=None,
starting_time_key="sun_n12_setting",
ending_time_key="sun_n12_rising",
):
"""
Parameters
Expand Down Expand Up @@ -106,6 +108,14 @@ def __init__(
object with a __call__ method that takes the time and returns a
tuple with the wind speed (m/s) and originating direction (radians
east of north)
starting_time_key : str
What key in the almanac to use to determine the start of observing on a night.
Default "sun_n12_setting", e.g., sun at -12 degrees and setting. Other
options are "sun_n18_setting" and "sunset"
ending_time_key : str
What key in the almanac to use to signify it is time to skip to the next night.
Default "sun_n12_rising", e.g., sun at -12 degrees and rising. Other
options are "sun_n18_rising" and "sunrise"
"""

if nside is None:
Expand All @@ -120,6 +130,8 @@ def __init__(
self.alt_min = np.radians(alt_min)
self.lax_dome = lax_dome
self.mjd_start = survey_start_mjd() if mjd_start is None else mjd_start
self.starting_time_key = starting_time_key
self.ending_time_key = ending_time_key

Check warning on line 134 in rubin_scheduler/scheduler/model_observatory/model_observatory.py

View check run for this annotation

Codecov / codecov/patch

rubin_scheduler/scheduler/model_observatory/model_observatory.py#L133-L134

Added lines #L133 - L134 were not covered by tests

self.sim__to_o = sim_to_o

Expand Down Expand Up @@ -486,18 +498,18 @@ def check_mjd(self, mjd, cloud_skip=20.0):
while clouds > self.cloud_limit:
new_mjd = new_mjd + cloud_skip / 60.0 / 24.0
clouds = self.cloud_data(Time(new_mjd, format="mjd"))
alm_indx = np.searchsorted(self.almanac.sunsets["sunset"], mjd) - 1
alm_indx = np.searchsorted(self.almanac.sunsets["sunset"], mjd, side="right") - 1

Check warning on line 501 in rubin_scheduler/scheduler/model_observatory/model_observatory.py

View check run for this annotation

Codecov / codecov/patch

rubin_scheduler/scheduler/model_observatory/model_observatory.py#L501

Added line #L501 was not covered by tests
# at the end of the night, advance to the next setting twilight
if mjd > self.almanac.sunsets["sun_n12_rising"][alm_indx]:
if mjd > self.almanac.sunsets[self.ending_time_key][alm_indx]:

Check warning on line 503 in rubin_scheduler/scheduler/model_observatory/model_observatory.py

View check run for this annotation

Codecov / codecov/patch

rubin_scheduler/scheduler/model_observatory/model_observatory.py#L503

Added line #L503 was not covered by tests
passed = False
new_mjd = self.almanac.sunsets["sun_n12_setting"][alm_indx + 1]
if mjd < self.almanac.sunsets["sun_n12_setting"][alm_indx]:
new_mjd = self.almanac.sunsets[self.starting_time_key][alm_indx + 1]
if mjd < self.almanac.sunsets[self.starting_time_key][alm_indx]:

Check warning on line 506 in rubin_scheduler/scheduler/model_observatory/model_observatory.py

View check run for this annotation

Codecov / codecov/patch

rubin_scheduler/scheduler/model_observatory/model_observatory.py#L505-L506

Added lines #L505 - L506 were not covered by tests
passed = False
new_mjd = self.almanac.sunsets["sun_n12_setting"][alm_indx + 1]
new_mjd = self.almanac.sunsets[self.starting_time_key][alm_indx + 1]

Check warning on line 508 in rubin_scheduler/scheduler/model_observatory/model_observatory.py

View check run for this annotation

Codecov / codecov/patch

rubin_scheduler/scheduler/model_observatory/model_observatory.py#L508

Added line #L508 was not covered by tests
# We're in a down night, advance to next night
if not self.check_up(mjd):
passed = False
new_mjd = self.almanac.sunsets["sun_n12_setting"][alm_indx + 1]
new_mjd = self.almanac.sunsets[self.starting_time_key][alm_indx + 1]

Check warning on line 512 in rubin_scheduler/scheduler/model_observatory/model_observatory.py

View check run for this annotation

Codecov / codecov/patch

rubin_scheduler/scheduler/model_observatory/model_observatory.py#L512

Added line #L512 was not covered by tests
# recursive call to make sure we skip far enough ahead
if not passed:
while not passed:
Expand Down

0 comments on commit 300d280

Please sign in to comment.