diff --git a/.gitmodules b/.gitmodules index 647ff453..e69de29b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "util/sims_featureScheduler_runs3.0"] - path = util/sims_featureScheduler_runs3.0 - url = https://github.com/lsst-sims/sims_featureScheduler_runs3.0.git \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..b83aea56 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,22 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace + - id: check-toml + - repo: https://github.com/psf/black + rev: 23.7.0 + hooks: + - id: black + # It is recommended to specify the latest version of Python + # supported by your project here, or alternatively use + # pre-commit's default_language_version, see + # https://pre-commit.com/#top_level-default_language_version + language_version: python3.11 + - repo: https://github.com/astral-sh/ruff-pre-commit + # Ruff version. + rev: v0.0.278 + hooks: + - id: ruff diff --git a/.vscode/settings.json b/.vscode/settings.json index 51f6e5c7..9fabad95 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -6,4 +6,4 @@ "python.testing.pytestEnabled": true, "python.envFile": "${workspaceFolder}/.env", "python.formatting.provider": "black" -} \ No newline at end of file +} diff --git a/README.md b/README.md index a49a180f..78e387ba 100644 --- a/README.md +++ b/README.md @@ -3,4 +3,3 @@ The `schedview` module provides tools for visualizing Rubin Observatory schedule - A collection of functions, eacho of which creates an independent visualization of same aspect of scheduler behaviour, state, or surve progress. These functions may be used in `jupyter` notebooks or other python applications, or combined into dashboards or other higher level applications. - A handful of dashboard applications that collect relevant visualizations into sets suitable for specific use cases. - diff --git a/notebooks/custom_plot.json b/notebooks/custom_plot.json index f2c768f7..8318533c 100644 --- a/notebooks/custom_plot.json +++ b/notebooks/custom_plot.json @@ -20,4 +20,4 @@ ] } } -] \ No newline at end of file +] diff --git a/pyproject.toml b/pyproject.toml index 82021862..17fd5b2d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta" [project] name = "schedview" description = "Tools for visualization of Rubin Observatory's scheduler status, strategy and progress on LSST." -classifiers = [ +classifiers = [ "Intended Audience :: Science/Research", "Operating System :: OS Independent", "Programming Language :: Python :: 3", diff --git a/schedview/app/prenight/prenight.py b/schedview/app/prenight/prenight.py index a2d82068..95a2400e 100644 --- a/schedview/app/prenight/prenight.py +++ b/schedview/app/prenight/prenight.py @@ -1,31 +1,30 @@ import argparse -import param +import importlib +import json import logging +import os + +import astropy.utils.iers +import bokeh +import hvplot.pandas # noqa: F401 import numpy as np import pandas as pd -import os -import json -import importlib import panel as pn -import bokeh -import hvplot.pandas +import param +import rubin_sim.scheduler.example from astropy.time import Time -import astropy.utils.iers - from rubin_sim.scheduler.model_observatory import ModelObservatory -import rubin_sim.scheduler.example -import schedview.compute.astro +import schedview.collect.footprint import schedview.collect.opsim +import schedview.compute.astro import schedview.compute.scheduler -import schedview.collect.footprint -import schedview.plot.visits -import schedview.plot.visitmap -import schedview.plot.rewards -import schedview.plot.visits +import schedview.param import schedview.plot.nightbf import schedview.plot.nightly -import schedview.param +import schedview.plot.rewards +import schedview.plot.visitmap +import schedview.plot.visits AVAILABLE_TIMEZONES = [ "Chile/Continental", @@ -853,7 +852,9 @@ def make_app( Returns ------- - pn_app : `panel.viewable.Viewable` or `tuple` ['panel.viewable.Viewable', `schedview.prenight.Prenight`] + pn_app : `panel.viewable.Viewable` + or `tuple` + ['panel.viewable.Viewable', `schedview.prenight.Prenight`] The pre-night briefing app. """ prenight = cls() diff --git a/schedview/app/sched_maps/main.py b/schedview/app/sched_maps/main.py index 9b58e34f..8a428264 100644 --- a/schedview/app/sched_maps/main.py +++ b/schedview/app/sched_maps/main.py @@ -1,5 +1,6 @@ -from schedview.app.sched_maps.sched_maps import add_scheduler_map_app import bokeh +from schedview.app.sched_maps.sched_maps import add_scheduler_map_app + doc = bokeh.plotting.curdoc() add_scheduler_map_app(doc) diff --git a/schedview/app/sched_maps/sched_maps.py b/schedview/app/sched_maps/sched_maps.py index 623a00b0..8dbaa3cc 100644 --- a/schedview/app/sched_maps/sched_maps.py +++ b/schedview/app/sched_maps/sched_maps.py @@ -1,24 +1,19 @@ +import bokeh.core.properties +import bokeh.models import bokeh.plotting -from astropy.time import Time - import pandas as pd -import bokeh.models -import bokeh.core.properties - -from uranography.api import ( - ArmillarySphere, - HorizonMap, - Planisphere, - MollweideMap, -) - -from schedview.collect import sample_pickle - -from schedview.plot.scheduler import SchedulerDisplay -from rubin_sim.scheduler.model_observatory import ModelObservatory -from schedview.collect import read_scheduler -from schedview.plot.scheduler import LOGGER, DEFAULT_NSIDE, DEFAULT_MJD import rubin_sim.scheduler.example +from astropy.time import Time +from rubin_sim.scheduler.model_observatory import ModelObservatory +from uranography.api import ArmillarySphere, HorizonMap, MollweideMap, Planisphere + +from schedview.collect import read_scheduler, sample_pickle +from schedview.plot.scheduler import ( + DEFAULT_MJD, + DEFAULT_NSIDE, + LOGGER, + SchedulerDisplay, +) class SchedulerDisplayApp(SchedulerDisplay): diff --git a/schedview/app/sched_maps/templates/index.html b/schedview/app/sched_maps/templates/index.html index d7d8e20e..774ad3b1 100644 --- a/schedview/app/sched_maps/templates/index.html +++ b/schedview/app/sched_maps/templates/index.html @@ -14,4 +14,4 @@ {{ plot_script|indent(8) }} - \ No newline at end of file + diff --git a/schedview/app/start.py b/schedview/app/start.py index 528bbbc0..556d6063 100644 --- a/schedview/app/start.py +++ b/schedview/app/start.py @@ -1,6 +1,7 @@ -import bokeh.command.bootstrap from pathlib import Path +import bokeh.command.bootstrap + def start_app(app_name): """Start a bokeh app. diff --git a/schedview/collect/local.py b/schedview/collect/local.py index 479fb152..d7dcb929 100644 --- a/schedview/collect/local.py +++ b/schedview/collect/local.py @@ -1,5 +1,5 @@ +from .metrics import get_metric_path # noqa F401 from .opsim import read_opsim # noqa F401 from .scheduler_pickle import read_scheduler # noqa F401 from .scheduler_pickle import sample_pickle # noqa F401 -from .metrics import get_metric_path # noqa F401 from .stars import load_bright_stars # noqa F401 diff --git a/schedview/collect/opsim.py b/schedview/collect/opsim.py index abba6f1e..0ac1e043 100644 --- a/schedview/collect/opsim.py +++ b/schedview/collect/opsim.py @@ -1,6 +1,7 @@ +import sqlite3 + import numpy as np import pandas as pd -import sqlite3 from astropy.time import Time diff --git a/schedview/collect/scheduler_pickle.py b/schedview/collect/scheduler_pickle.py index da1d1e70..f33c4b7f 100644 --- a/schedview/collect/scheduler_pickle.py +++ b/schedview/collect/scheduler_pickle.py @@ -1,13 +1,14 @@ -import pickle -import os -import gzip import bz2 -import lzma +import gzip import importlib.resources -from pathlib import Path -from tempfile import TemporaryDirectory +import lzma +import os +import pickle import urllib import urllib.request +from pathlib import Path +from tempfile import TemporaryDirectory + from rubin_sim.scheduler.model_observatory import ModelObservatory __all__ = ["read_scheduler", "sample_pickle"] diff --git a/schedview/collect/stars.py b/schedview/collect/stars.py index a1005e40..d7135b0e 100644 --- a/schedview/collect/stars.py +++ b/schedview/collect/stars.py @@ -1,5 +1,6 @@ -from collections import OrderedDict import os +from collections import OrderedDict + import pandas as pd BSC5_URL = "http://tdc-www.harvard.edu/catalogs/bsc5.dat.gz" diff --git a/schedview/compute/__init__.py b/schedview/compute/__init__.py index 9edd0fbb..07bcd501 100644 --- a/schedview/compute/__init__.py +++ b/schedview/compute/__init__.py @@ -1,18 +1,14 @@ from .astro import convert_evening_date_to_night_of_survey, night_events from .camera import LsstCameraFootprintPerimeter from .scheduler import ( - replay_visits, compute_basis_function_reward_at_time, compute_basis_function_rewards, create_example, - make_unique_survey_name, make_scheduler_summary_df, + make_unique_survey_name, + replay_visits, ) -from .survey import ( - make_survey_reward_df, - compute_maps, -) - +from .survey import compute_maps, make_survey_reward_df __all__ = [ "convert_evening_date_to_night_of_survey", diff --git a/schedview/compute/astro.py b/schedview/compute/astro.py index d2f93584..301f2381 100644 --- a/schedview/compute/astro.py +++ b/schedview/compute/astro.py @@ -1,11 +1,12 @@ -from functools import cache import datetime +from functools import cache + import numpy as np import pandas as pd -from astropy.time import Time import pytz -from rubin_sim.site_models.almanac import Almanac +from astropy.time import Time from rubin_sim.scheduler.model_observatory import ModelObservatory +from rubin_sim.site_models.almanac import Almanac @cache diff --git a/schedview/compute/camera.py b/schedview/compute/camera.py index 7a71affd..243660ea 100644 --- a/schedview/compute/camera.py +++ b/schedview/compute/camera.py @@ -1,7 +1,7 @@ +import astropy.units as u import numpy as np import pandas as pd from astropy.coordinates import SkyCoord -import astropy.units as u class LsstCameraFootprintPerimeter(object): diff --git a/schedview/compute/maf_metrics.py b/schedview/compute/maf_metrics.py index bf7b4fcc..4c347fe5 100644 --- a/schedview/compute/maf_metrics.py +++ b/schedview/compute/maf_metrics.py @@ -1,12 +1,13 @@ from copy import deepcopy from rubin_sim import maf -import schedview -import schedview.compute.astro +from rubin_sim.maf import MetricBundleGroup # noqa F401 # Imported to help sphinx make the link from rubin_sim.scheduler.model_observatory import ModelObservatory # noqa F401 -from rubin_sim.maf import MetricBundleGroup # noqa F401 + +import schedview +import schedview.compute.astro def compute_night_metric_bundle( diff --git a/schedview/compute/scheduler.py b/schedview/compute/scheduler.py index 11fbb640..72861e59 100644 --- a/schedview/compute/scheduler.py +++ b/schedview/compute/scheduler.py @@ -1,17 +1,17 @@ +import copy +import datetime +import lzma import numbers +import pickle + import numpy as np import pandas as pd -import pickle -import lzma -import copy -import datetime -from astropy.timeseries import TimeSeries from astropy.time import Time -from rubin_sim.scheduler.utils import empty_observation -from rubin_sim.scheduler.model_observatory import ModelObservatory -from rubin_sim.scheduler.example import example_scheduler +from astropy.timeseries import TimeSeries from rubin_sim.scheduler import sim_runner -from rubin_sim.scheduler.utils import SchemaConverter +from rubin_sim.scheduler.example import example_scheduler +from rubin_sim.scheduler.model_observatory import ModelObservatory +from rubin_sim.scheduler.utils import SchemaConverter, empty_observation def _make_observation_from_record(record): diff --git a/schedview/compute/survey.py b/schedview/compute/survey.py index f52a614f..754b8831 100644 --- a/schedview/compute/survey.py +++ b/schedview/compute/survey.py @@ -1,9 +1,10 @@ -from copy import deepcopy from collections import OrderedDict -import numpy as np +from copy import deepcopy +from inspect import getmembers + import healpy as hp +import numpy as np import rubin_sim.scheduler.basis_functions -from inspect import getmembers def make_survey_reward_df(survey, conditions, reward_df=None): diff --git a/schedview/data/sample_prenight_custom_hvplots.json b/schedview/data/sample_prenight_custom_hvplots.json index 4b9b177f..e40f3cec 100644 --- a/schedview/data/sample_prenight_custom_hvplots.json +++ b/schedview/data/sample_prenight_custom_hvplots.json @@ -67,4 +67,4 @@ "height": 512 } } -] \ No newline at end of file +] diff --git a/schedview/data/test_prenight_custom_hvplots.json b/schedview/data/test_prenight_custom_hvplots.json index ea32a746..d1bb3699 100644 --- a/schedview/data/test_prenight_custom_hvplots.json +++ b/schedview/data/test_prenight_custom_hvplots.json @@ -23,4 +23,4 @@ "height": 512 } } -] \ No newline at end of file +] diff --git a/schedview/param.py b/schedview/param.py index dc60de22..3197827e 100644 --- a/schedview/param.py +++ b/schedview/param.py @@ -1,7 +1,7 @@ # Subclasses of param.Parameter for use in schedview. -import param import pandas as pd +import param class Series(param.Parameter): diff --git a/schedview/plot/__init__.py b/schedview/plot/__init__.py index c9080f0a..cf706634 100644 --- a/schedview/plot/__init__.py +++ b/schedview/plot/__init__.py @@ -1,16 +1,16 @@ -from .nightbf import plot_rewards, plot_infeasible +from .nightbf import plot_infeasible, plot_rewards from .nightly import plot_airmass_vs_time, plot_alt_vs_time, plot_polar_alt_az -from .rewards import plot_survey_rewards, create_survey_reward_plot +from .rewards import create_survey_reward_plot, plot_survey_rewards from .scheduler import ( - make_logger, - BadSchedulerException, - BadConditionsException, + BadConditionsError, + BadSchedulerError, SchedulerDisplay, SchedulerNotebookDisplay, + make_logger, ) from .survey import map_survey_healpix -from .visitmap import plot_visit_skymaps, plot_visit_planisphere, create_visit_skymaps -from .visits import plot_visits, create_visit_explorer +from .visitmap import create_visit_skymaps, plot_visit_planisphere, plot_visit_skymaps +from .visits import create_visit_explorer, plot_visits __all__ = [ "plot_rewards", @@ -21,8 +21,8 @@ "plot_survey_rewards", "create_survey_reward_plot", "make_logger", - "BadSchedulerException", - "BadConditionsException", + "BadSchedulerError", + "BadConditionsError", "SchedulerDisplay", "SchedulerNotebookDisplay", "map_survey_healpix", diff --git a/schedview/plot/nightbf.py b/schedview/plot/nightbf.py index bbc024fb..6d85947b 100644 --- a/schedview/plot/nightbf.py +++ b/schedview/plot/nightbf.py @@ -3,7 +3,6 @@ import bokeh import numpy as np from astropy.time import Time - from rubin_sim.scheduler.model_observatory import ModelObservatory diff --git a/schedview/plot/nightly.py b/schedview/plot/nightly.py index 2f02027c..2a569035 100644 --- a/schedview/plot/nightly.py +++ b/schedview/plot/nightly.py @@ -3,6 +3,7 @@ import bokeh import colorcet import numpy as np + from .visitmap import BAND_COLORS DEFAULT_EVENT_LABELS = { @@ -157,9 +158,11 @@ def plot_airmass_vs_time( band_colors : `dict` Mapping of filter names to colors. Default is `BAND_COLORS`. event_labels : `dict` - Mapping of almanac events to labels. Default is `DEFAULT_EVENT_LABELS`. + Mapping of almanac events to labels. + Default is `DEFAULT_EVENT_LABELS`. event_colors : `dict` - Mapping of almanac events to colors. Default is `DEFAULT_EVENT_COLORS`. + Mapping of almanac events to colors. + Default is `DEFAULT_EVENT_COLORS`. figure : `bokeh.plotting.Figure` Bokeh figure object to plot on. If None, a new figure will be created. @@ -250,9 +253,11 @@ def plot_alt_vs_time( band_colors : `dict` Mapping of filter names to colors. Default is `BAND_COLORS`. event_labels : `dict` - Mapping of almanac events to labels. Default is `DEFAULT_EVENT_LABELS`. + Mapping of almanac events to labels. + Default is `DEFAULT_EVENT_LABELS`. event_colors : `dict` - Mapping of almanac events to colors. Default is `DEFAULT_EVENT_COLORS`. + Mapping of almanac events to colors. + Default is `DEFAULT_EVENT_COLORS`. figure : `bokeh.plotting.Figure` Bokeh figure object to plot on. If None, a new figure will be created. diff --git a/schedview/plot/rewards.py b/schedview/plot/rewards.py index 3270e2b5..1f8b43b4 100644 --- a/schedview/plot/rewards.py +++ b/schedview/plot/rewards.py @@ -4,14 +4,14 @@ import numpy as np from astropy.time import Time -import schedview.collect.scheduler_pickle -import schedview.collect.opsim -import schedview.compute.scheduler -import schedview.compute.astro - # Imported to help sphinx make the link from rubin_sim.scheduler.model_observatory import ModelObservatory # noqa F401 +import schedview.collect.opsim +import schedview.collect.scheduler_pickle +import schedview.compute.astro +import schedview.compute.scheduler + def plot_survey_rewards(rewards): """Plot survey rewards as a function of time. diff --git a/schedview/plot/scheduler.py b/schedview/plot/scheduler.py index 6723a319..14c17e5d 100644 --- a/schedview/plot/scheduler.py +++ b/schedview/plot/scheduler.py @@ -1,39 +1,35 @@ -import bokeh.plotting -import numpy as np -import healpy as hp -from astropy.time import Time -import logging import collections.abc -from collections import OrderedDict -import warnings import itertools +import logging +import warnings +from collections import OrderedDict -import pandas as pd -import bokeh.models import bokeh.core.properties - -from rubin_sim.scheduler.features.conditions import Conditions -from rubin_sim.scheduler.schedulers.core_scheduler import ( - CoreScheduler as CoreScheduler, -) -from rubin_sim.scheduler.model_observatory import ModelObservatory -import rubin_sim.scheduler.schedulers -import rubin_sim.scheduler.surveys +import bokeh.models +import bokeh.plotting +import healpy as hp +import numpy as np +import pandas as pd import rubin_sim.scheduler.basis_functions import rubin_sim.scheduler.example - +import rubin_sim.scheduler.schedulers +import rubin_sim.scheduler.surveys +from astropy.time import Time +from rubin_sim.scheduler.features.conditions import Conditions +from rubin_sim.scheduler.model_observatory import ModelObservatory +from rubin_sim.scheduler.schedulers.core_scheduler import CoreScheduler as CoreScheduler from uranography.api import ( ArmillarySphere, HorizonMap, - Planisphere, MollweideMap, + Planisphere, make_zscale_linear_cmap, ) from schedview.collect import read_scheduler from schedview.compute.scheduler import ( - make_unique_survey_name, make_scheduler_summary_df, + make_unique_survey_name, ) from schedview.compute.survey import make_survey_reward_df @@ -57,11 +53,11 @@ def make_logger(): LOGGER = make_logger() -class BadSchedulerException(Exception): +class BadSchedulerError(Exception): pass -class BadConditionsException(Exception): +class BadConditionsError(Exception): pass @@ -303,10 +299,10 @@ def load(self, file_name): """ scheduler, conditions = read_scheduler(file_name) if not isinstance(scheduler, CoreScheduler): - raise BadSchedulerException() + raise BadSchedulerError() if not isinstance(conditions, Conditions): - raise BadConditionsException() + raise BadConditionsError() scheduler.update_conditions(conditions) self.scheduler = scheduler diff --git a/schedview/plot/visitmap.py b/schedview/plot/visitmap.py index 9876c537..3d42cd18 100644 --- a/schedview/plot/visitmap.py +++ b/schedview/plot/visitmap.py @@ -1,23 +1,18 @@ -import numpy as np -import healpy as hp import bokeh +import healpy as hp +import numpy as np import pandas as pd from astropy.time import Time -import schedview.collect.scheduler_pickle -from uranography.api import ( - Planisphere, - ArmillarySphere, - split_healpix_by_resolution, -) -from schedview.compute.camera import LsstCameraFootprintPerimeter +# Imported to help sphinx make the link from rubin_sim.scheduler.model_observatory.model_observatory import ModelObservatory +from rubin_sim.scheduler.schedulers import CoreScheduler # noqa F401 +from uranography.api import ArmillarySphere, Planisphere, split_healpix_by_resolution + +import schedview.collect.scheduler_pickle import schedview.compute.astro from schedview.collect.stars import load_bright_stars - -# Imported to help sphinx make the link -from rubin_sim.scheduler.model_observatory import ModelObservatory # noqa F401 -from rubin_sim.scheduler.schedulers import CoreScheduler # noqa F401 +from schedview.compute.camera import LsstCameraFootprintPerimeter BAND_COLORS = dict( u="#56b4e9", g="#008060", r="#ff4000", i="#850000", z="#6600cc", y="#222222" diff --git a/schedview/plot/visits.py b/schedview/plot/visits.py index 239333b3..79178a83 100644 --- a/schedview/plot/visits.py +++ b/schedview/plot/visits.py @@ -1,11 +1,12 @@ -from astropy.time import Time -import schedview.collect.opsim -import schedview.compute.astro import hvplot +from astropy.time import Time # Imported to help sphinx make the link from rubin_sim.scheduler.model_observatory import ModelObservatory # noqa F401 +import schedview.collect.opsim +import schedview.compute.astro + def plot_visits(visits): """Instantiate an explorer to interactively examine a set of visits. diff --git a/tests/test_compute_scheduler.py b/tests/test_compute_scheduler.py index 33c198ef..cd17da36 100644 --- a/tests/test_compute_scheduler.py +++ b/tests/test_compute_scheduler.py @@ -1,14 +1,16 @@ import unittest + import pandas as pd import rubin_sim.scheduler.example +from rubin_sim.scheduler.example import example_scheduler +from rubin_sim.scheduler.features.conditions import Conditions +from rubin_sim.scheduler.model_observatory import ModelObservatory + from schedview.compute.scheduler import ( create_example, - make_unique_survey_name, make_scheduler_summary_df, + make_unique_survey_name, ) -from rubin_sim.scheduler.model_observatory import ModelObservatory -from rubin_sim.scheduler.features.conditions import Conditions -from rubin_sim.scheduler.example import example_scheduler class TestComputeScheduler(unittest.TestCase): diff --git a/tests/test_compute_survey.py b/tests/test_compute_survey.py index e17e5182..893b5543 100644 --- a/tests/test_compute_survey.py +++ b/tests/test_compute_survey.py @@ -1,9 +1,11 @@ import unittest from collections import OrderedDict + import pandas as pd -from schedview.compute.survey import make_survey_reward_df, compute_maps -from rubin_sim.scheduler.model_observatory import ModelObservatory from rubin_sim.scheduler.example import example_scheduler +from rubin_sim.scheduler.model_observatory import ModelObservatory + +from schedview.compute.survey import compute_maps, make_survey_reward_df class TestComputeSurvey(unittest.TestCase): diff --git a/tests/test_nightly.py b/tests/test_nightly.py index c5a4a33f..79fa14e6 100644 --- a/tests/test_nightly.py +++ b/tests/test_nightly.py @@ -1,12 +1,12 @@ +import importlib.resources import unittest -from tempfile import TemporaryDirectory from pathlib import Path -import importlib.resources -import pandas as pd -import bokeh +from tempfile import TemporaryDirectory -from rubin_sim.scheduler.utils import SchemaConverter +import bokeh +import pandas as pd from rubin_sim.scheduler.model_observatory import ModelObservatory +from rubin_sim.scheduler.utils import SchemaConverter import schedview import schedview.plot.nightly diff --git a/tests/test_plot_survey.py b/tests/test_plot_survey.py index 456f9dbf..e8761844 100644 --- a/tests/test_plot_survey.py +++ b/tests/test_plot_survey.py @@ -1,9 +1,11 @@ import unittest + import healpy as hp import numpy as np -from schedview.plot.survey import map_survey_healpix from uranography.api import SphereMap +from schedview.plot.survey import map_survey_healpix + RANDOM_NUMBER_GENERATOR = np.random.default_rng(6563) diff --git a/tests/test_prenight.py b/tests/test_prenight.py index 3595542c..5a80d28d 100644 --- a/tests/test_prenight.py +++ b/tests/test_prenight.py @@ -1,9 +1,10 @@ -import unittest import importlib.resources -from tempfile import TemporaryDirectory +import unittest from pathlib import Path -import bokeh.plotting +from tempfile import TemporaryDirectory + import bokeh.io +import bokeh.plotting from schedview.app.prenight.prenight import prenight_app diff --git a/tests/test_scheduler.py b/tests/test_scheduler.py index 00d82b17..b190afb5 100644 --- a/tests/test_scheduler.py +++ b/tests/test_scheduler.py @@ -1,15 +1,14 @@ import unittest -import healpy as hp + import astropy.utils.iers -from astropy.time import TimeDelta -from schedview.plot.scheduler import ( - SchedulerDisplay, - DEFAULT_MJD, -) -from schedview.collect import sample_pickle +import healpy as hp import rubin_sim.scheduler.example -from rubin_sim.scheduler.model_observatory import ModelObservatory +from astropy.time import TimeDelta from rubin_sim.scheduler.features.conditions import Conditions +from rubin_sim.scheduler.model_observatory import ModelObservatory + +from schedview.collect import sample_pickle +from schedview.plot.scheduler import DEFAULT_MJD, SchedulerDisplay NSIDE = 8 diff --git a/tests/test_scheduler_app.py b/tests/test_scheduler_app.py index 6c30309f..367c24bb 100644 --- a/tests/test_scheduler_app.py +++ b/tests/test_scheduler_app.py @@ -1,8 +1,10 @@ import unittest -from tempfile import TemporaryDirectory from pathlib import Path -import bokeh.plotting +from tempfile import TemporaryDirectory + import bokeh.io +import bokeh.plotting + from schedview.app.sched_maps.sched_maps import SchedulerDisplayApp from schedview.collect import sample_pickle diff --git a/tests/test_scheduler_pickle.py b/tests/test_scheduler_pickle.py index 39c43a83..950b4f9b 100644 --- a/tests/test_scheduler_pickle.py +++ b/tests/test_scheduler_pickle.py @@ -1,11 +1,13 @@ -import unittest -from tempfile import TemporaryDirectory import os.path import pickle -from rubin_sim.scheduler.schedulers.core_scheduler import CoreScheduler +import unittest +from tempfile import TemporaryDirectory + +from rubin_sim.scheduler.example import example_scheduler from rubin_sim.scheduler.features.conditions import Conditions +from rubin_sim.scheduler.schedulers.core_scheduler import CoreScheduler + from schedview.collect.scheduler_pickle import read_scheduler -from rubin_sim.scheduler.example import example_scheduler class TestSchedulerPickle(unittest.TestCase): diff --git a/tests/test_sphere.py b/tests/test_sphere.py index f9f14f23..85a1f86d 100644 --- a/tests/test_sphere.py +++ b/tests/test_sphere.py @@ -1,9 +1,8 @@ import unittest -import numpy as np import healpy as hp +import numpy as np from astropy.coordinates import SkyCoord - from numpy.random import default_rng from schedview import sphere diff --git a/tests/test_stars.py b/tests/test_stars.py index db1c8b8d..5b1ea82b 100644 --- a/tests/test_stars.py +++ b/tests/test_stars.py @@ -1,4 +1,5 @@ import unittest + from schedview.collect.stars import load_bright_stars diff --git a/util/baseline_test_data/README.md b/util/baseline_test_data/README.md deleted file mode 100644 index eeba5acc..00000000 --- a/util/baseline_test_data/README.md +++ /dev/null @@ -1,14 +0,0 @@ -To make a new pickle of test data based on the baseline, begin by updating -the submodule with the simulation driver. In the `$SCHEDVIEW_DIR/utils` -directory, run: -``` -git submodule update sims_featureScheduler_runs3.0 -``` - -Then, run `make_baseline_test_data.py` from the -`$SCHEDVIEW_DIR/utils/baseline_test_data` directory: -``` -python make_baseline_test_data.py -``` - -This will create the test data file, by default `baseline.pickle.gz` \ No newline at end of file diff --git a/util/baseline_test_data/ddf_grid.npz b/util/baseline_test_data/ddf_grid.npz deleted file mode 120000 index d5b03ab6..00000000 --- a/util/baseline_test_data/ddf_grid.npz +++ /dev/null @@ -1 +0,0 @@ -../sims_featureScheduler_runs3.0/draft2_updated/ddf_grid.npz \ No newline at end of file diff --git a/util/baseline_test_data/draft2_updated_uzy.py b/util/baseline_test_data/draft2_updated_uzy.py deleted file mode 120000 index 1950439b..00000000 --- a/util/baseline_test_data/draft2_updated_uzy.py +++ /dev/null @@ -1 +0,0 @@ -../sims_featureScheduler_runs3.0/draft2_updated/draft2_updated_uzy.py \ No newline at end of file diff --git a/util/baseline_test_data/gen_long_gaps.py b/util/baseline_test_data/gen_long_gaps.py deleted file mode 120000 index e24d5579..00000000 --- a/util/baseline_test_data/gen_long_gaps.py +++ /dev/null @@ -1 +0,0 @@ -../sims_featureScheduler_runs3.0/draft2_updated/gen_long_gaps.py \ No newline at end of file diff --git a/util/baseline_test_data/make_baseline_test_data.py b/util/baseline_test_data/make_baseline_test_data.py deleted file mode 100755 index 6f47bf2d..00000000 --- a/util/baseline_test_data/make_baseline_test_data.py +++ /dev/null @@ -1,55 +0,0 @@ -import gzip -import argparse -import logging -import pickle -from draft2_updated_uzy import main - -SAVED_FILE_NAME = "baseline.pickle.gz" - - -def make_baseline_test_data(): - parser = argparse.ArgumentParser() - parser.add_argument("--verbose", dest="verbose", action="store_true") - parser.set_defaults(verbose=False) - parser.add_argument("--survey_length", type=float, default=4) - parser.add_argument("--outDir", type=str, default="") - parser.add_argument( - "--maxDither", type=float, default=0.7, help="Dither size for DDFs (deg)" - ) - parser.add_argument( - "--moon_illum_limit", - type=float, - default=40.0, - help="illumination limit to remove u-band", - ) - parser.add_argument("--nexp", type=int, default=2) - parser.add_argument("--rolling_nslice", type=int, default=2) - parser.add_argument("--rolling_strength", type=float, default=0.9) - parser.add_argument("--dbroot", type=str) - parser.add_argument("--gsw", type=float, default=3.0, help="good seeing weight") - parser.add_argument("--ddf_season_frac", type=float, default=0.2) - parser.add_argument( - "--agg_level", - type=str, - default="1.5", - help="Version of aggregation level map - either 1.5 or 2.0", - ) - parser.add_argument("--nights_off", type=int, default=6) - parser.add_argument("--nights_delayed", type=int, default=-1) - parser.add_argument("--neo_night_pattern", type=int, default=4) - parser.add_argument("--neo_filters", type=str, default="riz") - parser.add_argument("--neo_repeat", type=int, default=4) - - args = parser.parse_args() - - observatory, scheduler, observations = main(args) - conditions = observatory.return_conditions() - saved_file_contents = [scheduler, conditions] - - with gzip.open(SAVED_FILE_NAME, "wb") as pickle_file: - pickle.dump(saved_file_contents, pickle_file) - - -if __name__ == "__main__": - logging.basicConfig(level=logging.DEBUG) - make_baseline_test_data() diff --git a/util/baseline_test_data/make_ddf_survey.py b/util/baseline_test_data/make_ddf_survey.py deleted file mode 120000 index 042c3602..00000000 --- a/util/baseline_test_data/make_ddf_survey.py +++ /dev/null @@ -1 +0,0 @@ -../sims_featureScheduler_runs3.0/draft2_updated/make_ddf_survey.py \ No newline at end of file diff --git a/util/sample_data/README.md b/util/sample_data/README.md index ca681b35..89f950ef 100644 --- a/util/sample_data/README.md +++ b/util/sample_data/README.md @@ -13,4 +13,3 @@ There is a `--help` option to describe optional parameters. The primary use for it is to generated update sample data for use in `${SCHEDVIEW_DIR}/schedview/data`. - diff --git a/util/sample_data/make_sample_test_data.py b/util/sample_data/make_sample_test_data.py index dcd547a7..64ac2996 100644 --- a/util/sample_data/make_sample_test_data.py +++ b/util/sample_data/make_sample_test_data.py @@ -1,12 +1,12 @@ -import warnings -import numpy as np +import argparse import lzma import pickle -import argparse +import warnings +import numpy as np from astropy.time import Time -from rubin_sim.scheduler.example import example_scheduler from rubin_sim.scheduler import sim_runner +from rubin_sim.scheduler.example import example_scheduler from rubin_sim.scheduler.model_observatory import ModelObservatory from rubin_sim.scheduler.utils import SchemaConverter @@ -18,11 +18,6 @@ module="astropy.time", message="Numerical value without unit or explicit format passed to TimeDelta, assuming days", ) -warnings.filterwarnings( - "ignore", - module="pandas", - message="In a future version of pandas, a length 1 tuple will be returned when iterating over a groupby with a grouper equal to a list of length 1. Don't supply a list with a single grouper to avoid this warning.", -) warnings.filterwarnings( "ignore", module="healpy", @@ -89,13 +84,18 @@ def make_sample_test_data(): observatory = ModelObservatory() - # Set `evening_mjd` to the integer calendar MJD of the local calendar day on which sunset falls on the night of interest. + # Set `evening_mjd` to the integer calendar MJD of the local calendar day + # on which sunset falls on the night of interest. evening_mjd = Time(evening_iso8601).mjd - # If we just use this day as the start and make the simulation duration 1 day, the begin and end of the simulation will probably begin in the middle on one night and end in the middle of the next. - # Instead, find the sunset and sunrise of the night we want using the almanac, and use these to determine our start time and duration. + # If we just use this day as the start and make the simulation duration 1 + # day, the begin and end of the simulation will probably begin in the + # middle on one night and end in the middle of the next. + # Instead, find the sunset and sunrise of the night we want using the + # almanac, and use these to determine our start time and duration. - # If the date represents the local calendar date at sunset, we need to shift by the longitude in units of days + # If the date represents the local calendar date at sunset, we need to + # shift by the longitude in units of days this_night = ( np.floor( observatory.almanac.sunsets["sunset"] + observatory.site.longitude / 360 diff --git a/util/sims_featureScheduler_runs3.0 b/util/sims_featureScheduler_runs3.0 deleted file mode 160000 index e72696c6..00000000 --- a/util/sims_featureScheduler_runs3.0 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e72696c6a2e2af66590519c3d08e4b3bb590807e