Skip to content

Commit 4672ac8

Browse files
committed
Tools for examining the Rubin Observatory scheduler and progress
1 parent 56e64ff commit 4672ac8

34 files changed

+4986
-1
lines changed

COPYRIGHT

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Copyright 2022 Fermi Research Alliance, LLC.

README.md

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,86 @@
11
# schedview
2-
Tools for monitoring the Rubin Observatory scheduler and related LSST survey progress and strategy data.
2+
Tools for visualizing Rubin Observatory scheduler behaviour and LSST survey status
3+
4+
## Development state
5+
6+
The current code is in a early stage of development. The architecture will
7+
be documented by [RTN-037](https://rtn-037.lsst.io/), currently little more than
8+
an outline.
9+
10+
## Applications
11+
12+
There are presently two different applications in this project:
13+
14+
- `metric_maps`, a tool for visualizing metric output of MAF that takes the form
15+
of a sky map.
16+
- `sched_maps`, a tool for examing some elements of the state of objects used by
17+
the scheduler, particularly those that take the form of a sky map, although some
18+
indications of other elements are also present.
19+
20+
The project contains example data for each. At present, to use the example data,
21+
different versions of dependencies are required, so the installation instructions
22+
are slightly different in each case. (The reason for this is that the pickles
23+
containing the sample objects to be viewed with `sched_maps` were created with
24+
an old version of `rubin_sim`, and this older version needs to be installed for
25+
these to be loaded.)
26+
27+
## Installation
28+
29+
First, get the code by cloning the github project:
30+
31+
$ git clone [email protected]:ehneilsen/schedview.git
32+
33+
Go to the development directory, and download and decompress a data file used
34+
by the automated tests.
35+
36+
$ cd schedview
37+
$ wget -O schedview/data/bsc5.dat.gz http://tdc-www.harvard.edu/catalogs/bsc5.dat.gz
38+
$ gunzip schedview/data/bsc5.dat.gz
39+
40+
Create a `conda` environment with the appropriate dependencies, and activate it.
41+
If you are running the `metric_maps` application, use the `conda` environment
42+
file that includes a recent version of `survey_sim`:
43+
44+
$ # ONLY IF RUNNING metric_maps
45+
$ conda env create -f environment.yaml
46+
$ conda activate schedview
47+
48+
If you are running `sched_maps`, get the one with the older version:
49+
50+
$ # ONLY IF RUNNING sched_maps
51+
$ conda env create -f environment_080a2.yaml
52+
$ conda activate schedview080a2
53+
54+
Install the (development) `schedview` in your new environment:
55+
56+
$ pip install -e .
57+
58+
Run the tests:
59+
60+
$ pytest
61+
62+
## Running `metric_maps`
63+
64+
Activate the environment, and start the `bokeh` app. If `SCHEDVIEW_DIR` is the
65+
directory into which you cloned the `schedview` github repository, then:
66+
67+
$ conda activate schedview
68+
$ bokeh serve ${SCHEDVIEW_DIR}/schedview/app/metric_maps.py
69+
70+
The app will then give you the URL at which you can find the app. The data
71+
displayed with the above instructions will be the sample metric map in the
72+
project itself.
73+
74+
If you want to use a different data file, you can set the `METRIC_FNAME`
75+
to its path before running the `bokeh` app. This is only a very short term
76+
solution, and will be replaced soon.
77+
78+
## Running `sched_maps`
79+
80+
Activate the environment, and start the `bokeh` app. If `SCHEDVIEW_DIR` is the
81+
directory into which you cloned the `schedview` github repository, then:
82+
83+
$ conda activate schedview080a2
84+
$ bokeh serve ${SCHEDVIEW_DIR}/schedview/app/sched_maps.py
85+
86+
The app will then give you the URL at which you can find the app.

environment.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: schedview
2+
channels:
3+
- conda-forge
4+
dependencies:
5+
- rubin-sim
6+
- bokeh
7+
- pytest-flake8
8+
- pytest-black
9+
- selenium
10+
- firefox
11+
- geckodriver
12+
- build

pyproject.toml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
[build-system]
2+
requires = [ "setuptools", "setuptools_scm" ]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "schedview"
7+
description = "Tools for visualization of Rubin Observatory's scheduler status, strategy and progress on LSST."
8+
classifiers = [
9+
"Intended Audience :: Science/Research",
10+
"Operating System :: OS Independent",
11+
"Programming Language :: Python :: 3",
12+
"Programming Language :: Python :: 3.10",
13+
"Topic :: Scientific/Engineering :: Astronomy",
14+
]
15+
dynamic = [ "version" ]
16+
17+
[tool.setuptools.dynamic]
18+
version = { attr = "setuptools_scm.get_version" }
19+
20+
[tool.setuptools.packages.find]
21+
where = [ "" ]
22+
23+
[tool.setuptools_scm]
24+
write_to = "schedview/version.py"
25+
write_to_template = """
26+
# Generated by setuptools_scm
27+
__all__ = ["__version__"]
28+
__version__ = "{version}"
29+
"""
30+
31+
[tool.pytest.ini_options]
32+
addopts = "--flake8 --black --ignore-glob=*/version.py"
33+
flake8-ignore = ["E133", "E203", "E226", "E228", "N802", "N803", "N806", "N812", "N813", "N815", "N816", "W503", "**/*/__init__.py ALL", "**/*/version.py ALL"]
34+
flake8-max-line-length = 110
35+
flake8-max-doc-length = 79
36+
testpaths = "."

schedview/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .sphere import *

schedview/app/__init__.py

Whitespace-only changes.

schedview/app/metric_maps.py

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
import bokeh.plotting
2+
3+
from rubin_sim import maf
4+
5+
from schedview.plot.SphereMap import ArmillarySphere, Planisphere, MollweideMap
6+
from schedview.collect.stars import load_bright_stars
7+
from schedview.collect import get_metric_path
8+
9+
10+
def make_metric_figure(metric_values_fname=None, nside=8, mag_limit_slider=True):
11+
"""Create a figure showing multiple projections of a set of a MAF metric.
12+
13+
Parameters
14+
----------
15+
metric_values_fname : `str`, optional
16+
Name of file from which to load metric values, as saved by MAF
17+
in a saved metric bundle. If it is None, the look for the
18+
file name in the ``METRIC_FNAME`` environment varable. By default None
19+
nside : `int`, optional
20+
Healpix nside to use for display, by default 8
21+
mag_limit_slider : `bool`, optional
22+
Show the mag limit slider for stars?, by default True
23+
24+
Returns
25+
-------
26+
fig : `bokeh.models.layouts.LayoutDOM`
27+
A bokeh figure that can be displayed in a notebook (e.g. with
28+
``bokeh.io.show``) or used to create a bokeh app.
29+
30+
Notes
31+
-----
32+
If ``mag_limit_slider`` is ``True``, it creates a magnitude limit
33+
slider for the stars. This is implemented as a python callback, and
34+
so is only operational in full bokeh app, not standalone output.
35+
"""
36+
37+
if metric_values_fname is None:
38+
metric_values_fname = get_metric_path()
39+
40+
healpy_values = maf.MetricBundle.load(metric_values_fname).metricValues
41+
42+
star_data = load_bright_stars().loc[:, ["name", "ra", "decl", "Vmag"]]
43+
star_data["glyph_size"] = 15 - (15.0 / 3.5) * star_data["Vmag"]
44+
star_data.query("glyph_size>0", inplace=True)
45+
46+
arm = ArmillarySphere()
47+
hp_ds, cmap, _ = arm.add_healpix(healpy_values, nside=nside)
48+
hz = arm.add_horizon()
49+
zd70 = arm.add_horizon(zd=70, line_kwargs={"color": "red", "line_width": 2})
50+
star_ds = arm.add_stars(
51+
star_data, mag_limit_slider=mag_limit_slider, star_kwargs={"color": "black"}
52+
)
53+
arm.decorate()
54+
55+
pla = Planisphere()
56+
pla.add_healpix(hp_ds, cmap=cmap, nside=nside)
57+
pla.add_horizon(data_source=hz)
58+
pla.add_horizon(
59+
zd=60, data_source=zd70, line_kwargs={"color": "red", "line_width": 2}
60+
)
61+
pla.add_stars(
62+
star_data,
63+
data_source=star_ds,
64+
mag_limit_slider=False,
65+
star_kwargs={"color": "black"},
66+
)
67+
pla.decorate()
68+
69+
mol_plot = bokeh.plotting.figure(plot_width=512, plot_height=256, match_aspect=True)
70+
mol = MollweideMap(plot=mol_plot)
71+
mol.add_healpix(hp_ds, cmap=cmap, nside=nside)
72+
mol.add_horizon(data_source=hz)
73+
mol.add_horizon(
74+
zd=70, data_source=zd70, line_kwargs={"color": "red", "line_width": 2}
75+
)
76+
mol.add_stars(
77+
star_data,
78+
data_source=star_ds,
79+
mag_limit_slider=False,
80+
star_kwargs={"color": "black"},
81+
)
82+
mol.decorate()
83+
84+
figure = bokeh.layouts.row(
85+
bokeh.layouts.column(mol.plot, *arm.sliders.values()), arm.plot, pla.plot
86+
)
87+
88+
return figure
89+
90+
91+
def add_metric_app(doc):
92+
"""Add a metric figure to a bokeh document
93+
94+
Parameters
95+
----------
96+
doc : `bokeh.document.document.Document`
97+
The bokeh document to which to add the figure.
98+
"""
99+
figure = make_metric_figure()
100+
doc.add_root(figure)
101+
102+
103+
if __name__.startswith("bokeh_app_"):
104+
doc = bokeh.plotting.curdoc()
105+
add_metric_app(doc)

0 commit comments

Comments
 (0)