Skip to content

Commit

Permalink
Merge pull request #47 from lsst/tickets/PREOPS-4518
Browse files Browse the repository at this point in the history
PREOPS-4518: Preserve wind and seeing conditions from a loaded pickle.
  • Loading branch information
alserene authored Nov 8, 2023
2 parents fd39cf9 + 1385421 commit 8b35b18
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
12 changes: 11 additions & 1 deletion schedview/app/scheduler_dashboard/scheduler_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import numpy as np
import panel as pn
import param
import rubin_sim.site_models
from astropy.time import Time
from bokeh.models import ColorBar, LinearColorMapper
from bokeh.models.widgets.tables import BooleanFormatter, HTMLTemplateFormatter
Expand Down Expand Up @@ -568,14 +569,23 @@ def update_conditions(self):
not hasattr(self, "_model_observatory")
or self._model_observatory.nside != self._scheduler.nside
):
# Get weather conditions from pickle.
wind_data = rubin_sim.site_models.ConstantWindData(
wind_speed=self._conditions.wind_speed,
wind_direction=self._conditions.wind_direction,
)
# Set seeing to fiducial site seeing.
seeing_data = rubin_sim.site_models.ConstantSeeingData(0.69)
# Create new MO instance.
self._model_observatory = ModelObservatory(
nside=self._scheduler.nside,
init_load_length=1,
wind_data=wind_data,
seeing_data=seeing_data,
)

self._model_observatory.mjd = self._mjd
self._conditions = self._model_observatory.return_conditions()

self._scheduler.update_conditions(self._conditions)

self._debugging_message = "Finished updating Conditions object."
Expand Down
16 changes: 16 additions & 0 deletions tests/test_scheduler_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import bokeh.io
import bokeh.plotting
import pandas as pd
import rubin_sim.site_models
from astropy.time import Time
from pandas import Timestamp
from panel.widgets import Tabulator
Expand Down Expand Up @@ -131,6 +132,21 @@ def test_compute_survey_maps(self):
self.assertIn("reward", survey_maps)
self.assertIn("g_sky", survey_maps)

def test_site_models(self):
wind_speed = 4
wind_direction = 25
fiducial_seeing = 0.69
wind_data = rubin_sim.site_models.ConstantWindData(
wind_speed=wind_speed,
wind_direction=wind_direction,
)
seeing_data = rubin_sim.site_models.ConstantSeeingData(fiducial_seeing)
self.assertIsInstance(wind_data, rubin_sim.site_models.ConstantWindData)
self.assertIsInstance(seeing_data, rubin_sim.site_models.ConstantSeeingData)
self.assertEqual(wind_data.wind_speed, wind_speed)
self.assertEqual(wind_data.wind_direction, wind_direction)
self.assertEqual(seeing_data.fwhm_500, fiducial_seeing)


if __name__ == "__main__":
unittest.main()

0 comments on commit 8b35b18

Please sign in to comment.