Skip to content

Commit

Permalink
replace deprecated survey_start_mjd() with SURVEY_START_MJD
Browse files Browse the repository at this point in the history
  • Loading branch information
ehneilsen committed Dec 10, 2024
1 parent 4326cb4 commit 68815ce
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions schedview/plot/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
from rubin_scheduler.scheduler.features.conditions import Conditions
from rubin_scheduler.scheduler.model_observatory import ModelObservatory
from rubin_scheduler.scheduler.schedulers.core_scheduler import CoreScheduler as CoreScheduler
from rubin_scheduler.utils import survey_start_mjd
from rubin_scheduler.utils import SURVEY_START_MJD
from uranography.api import ArmillarySphere, HorizonMap, MollweideMap, Planisphere, make_zscale_linear_cmap

from schedview.collect import read_scheduler
from schedview.compute.scheduler import make_scheduler_summary_df, make_unique_survey_name
from schedview.compute.survey import make_survey_reward_df

DEFAULT_MJD = survey_start_mjd() + 0.2
DEFAULT_MJD = SURVEY_START_MJD + 0.2
DEFAULT_NSIDE = 32


Expand Down
6 changes: 3 additions & 3 deletions tests/test_compute_maf.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import unittest

import numpy as np
from rubin_scheduler.utils import survey_start_mjd
from rubin_scheduler.utils import SURVEY_START_MJD
from rubin_sim.data import get_baseline

from schedview.collect import read_opsim
Expand All @@ -19,7 +19,7 @@ class TestComputeMAF(unittest.TestCase):
@unittest.skipUnless("maf" in locals(), "No maf installation")
def test_compute_metric_by_visit(self):
visits = read_opsim(get_baseline())
mjd_start = survey_start_mjd()
mjd_start = SURVEY_START_MJD
constraint = f"observationStartMjd BETWEEN {mjd_start + 0.5} AND {mjd_start+1.5}"
metric = maf.TeffMetric()
values = compute_metric_by_visit(visits, metric, constraint=constraint)
Expand All @@ -30,7 +30,7 @@ def test_compute_metric_by_visit(self):
@unittest.skipUnless("maf" in locals(), "No maf installation")
def test_compute_hpix_metric_in_bands(self):
visits = read_opsim(get_baseline())
mjd_start = survey_start_mjd()
mjd_start = SURVEY_START_MJD
constraint = f"observationStartMjd BETWEEN {mjd_start+0.5} AND {mjd_start+1.5}"
metric = maf.TeffMetric()
values = compute_hpix_metric_in_bands(visits, metric, constraint=constraint)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_compute_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
from rubin_scheduler.scheduler.example import example_scheduler
from rubin_scheduler.scheduler.features.conditions import Conditions
from rubin_scheduler.scheduler.model_observatory import ModelObservatory
from rubin_scheduler.utils import survey_start_mjd
from rubin_scheduler.utils import SURVEY_START_MJD

from schedview.compute.scheduler import create_example, make_scheduler_summary_df, make_unique_survey_name

MJD_START = survey_start_mjd()
MJD_START = SURVEY_START_MJD
TEST_MJD = MJD_START + 0.2


Expand Down
4 changes: 2 additions & 2 deletions tests/test_compute_survey.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import pandas as pd
from rubin_scheduler.scheduler.example import example_scheduler
from rubin_scheduler.scheduler.model_observatory import ModelObservatory
from rubin_scheduler.utils import survey_start_mjd
from rubin_scheduler.utils import SURVEY_START_MJD

from schedview.compute.survey import compute_maps, make_survey_reward_df

MJD_START = survey_start_mjd()
MJD_START = SURVEY_START_MJD
TEST_MJD = MJD_START + 0.2


Expand Down
4 changes: 2 additions & 2 deletions tests/test_compute_visits.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import numpy as np
from astropy.time import Time
from rubin_scheduler.utils import survey_start_mjd
from rubin_scheduler.utils import SURVEY_START_MJD
from rubin_sim.data import get_baseline

import schedview.collect
Expand All @@ -18,7 +18,7 @@ class TestComputeVisits(unittest.TestCase):

def setUp(self):
self.visit_db_fname = get_baseline()
start_mjd = survey_start_mjd()
start_mjd = SURVEY_START_MJD
start_time = Time(start_mjd, format="mjd")
end_time = Time(start_mjd + 1, format="mjd")
self.visits = schedview.collect.read_opsim(self.visit_db_fname, start_time, end_time)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_overhead.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import bokeh
from astropy.time import Time
from rubin_scheduler.utils import survey_start_mjd
from rubin_scheduler.utils import SURVEY_START_MJD
from rubin_sim.data import get_baseline

import schedview.collect
Expand All @@ -15,7 +15,7 @@ class TestOverhead(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.visit_db_fname = get_baseline()
start_mjd = survey_start_mjd()
start_mjd = SURVEY_START_MJD
cls.start_time = Time(start_mjd + 0.5, format="mjd")
cls.end_time = Time(start_mjd + 1.5, format="mjd")
cls.visits = schedview.collect.read_opsim(cls.visit_db_fname, cls.start_time, cls.end_time)
Expand Down
8 changes: 4 additions & 4 deletions tests/test_plot_survey.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
import numpy as np
from astropy.time import Time
from rubin_scheduler.scheduler.model_observatory import ModelObservatory
from rubin_scheduler.utils import survey_start_mjd
from rubin_scheduler.utils import SURVEY_START_MJD
from rubin_sim.data import get_baseline
from uranography.api import SphereMap

import schedview.collect
from schedview.plot.survey import create_hpix_visit_map_grid, map_survey_healpix, map_visits_over_hpix

RANDOM_NUMBER_GENERATOR = np.random.default_rng(6563)
TEST_MJD = survey_start_mjd() + 0.2
TEST_MJD = SURVEY_START_MJD + 0.2


class TestMapSurvey(unittest.TestCase):
Expand All @@ -29,7 +29,7 @@ def test_create_hpix_visit_map_grid(self):
npix = hp.nside2npix(nside)
hpix_maps = {b: RANDOM_NUMBER_GENERATOR.random(npix) for b in "ugrizy"}

start_mjd = survey_start_mjd()
start_mjd = SURVEY_START_MJD
visits = schedview.collect.read_opsim(
get_baseline(), Time(start_mjd + 0.5, format="mjd"), Time(start_mjd + 1.5, format="mjd")
)
Expand All @@ -45,7 +45,7 @@ def test_create_hpix_visit_map_no_raster(self):
npix = hp.nside2npix(nside)
hpix_map = RANDOM_NUMBER_GENERATOR.random(npix)

start_mjd = survey_start_mjd()
start_mjd = SURVEY_START_MJD
visits = schedview.collect.read_opsim(
get_baseline(), Time(start_mjd + 0.5, format="mjd"), Time(start_mjd + 1.5, format="mjd")
)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_plot_visits.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import bokeh
import bokeh.models
from astropy.time import Time
from rubin_scheduler.utils import survey_start_mjd
from rubin_scheduler.utils import SURVEY_START_MJD
from rubin_sim.data import get_baseline

import schedview.collect
Expand All @@ -14,7 +14,7 @@ class TestPlotVisits(TestCase):

def setUp(self):
self.visit_db_fname = get_baseline()
start_mjd = survey_start_mjd()
start_mjd = SURVEY_START_MJD
self.start_time = Time(start_mjd + 0.5, format="mjd")
self.end_time = Time(start_mjd + 1.5, format="mjd")
self.visits = schedview.collect.read_opsim(self.visit_db_fname, self.start_time, self.end_time)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_scheduler_pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
from rubin_scheduler.scheduler.example import example_scheduler
from rubin_scheduler.scheduler.features.conditions import Conditions
from rubin_scheduler.scheduler.schedulers.core_scheduler import CoreScheduler
from rubin_scheduler.utils import survey_start_mjd
from rubin_scheduler.utils import SURVEY_START_MJD

from schedview.collect.scheduler_pickle import read_scheduler

MJD_START = survey_start_mjd()
MJD_START = SURVEY_START_MJD


class TestSchedulerPickle(unittest.TestCase):
Expand Down
4 changes: 2 additions & 2 deletions util/sample_data/make_sample_test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
from rubin_scheduler.scheduler.example import example_scheduler
from rubin_scheduler.scheduler.model_observatory import ModelObservatory
from rubin_scheduler.scheduler.utils import SchemaConverter
from rubin_scheduler.utils import survey_start_mjd
from rubin_scheduler.utils import SURVEY_START_MJD

DEFAULT_DATE = Time(survey_start_mjd(), format="mjd").iso[:10]
DEFAULT_DATE = Time(SURVEY_START_MJD, format="mjd").iso[:10]

# Several dependencies throw prodigious instances of (benign) warnings.
# Suppress them to avoid poluting the executed notebook.
Expand Down

0 comments on commit 68815ce

Please sign in to comment.