-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tools for examining the Rubin Observatory scheduler and progress
- Loading branch information
Showing
34 changed files
with
4,986 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Copyright 2022 Fermi Research Alliance, LLC. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,86 @@ | ||
# schedview | ||
Tools for monitoring the Rubin Observatory scheduler and related LSST survey progress and strategy data. | ||
Tools for visualizing Rubin Observatory scheduler behaviour and LSST survey status | ||
|
||
## Development state | ||
|
||
The current code is in a early stage of development. The architecture will | ||
be documented by [RTN-037](https://rtn-037.lsst.io/), currently little more than | ||
an outline. | ||
|
||
## Applications | ||
|
||
There are presently two different applications in this project: | ||
|
||
- `metric_maps`, a tool for visualizing metric output of MAF that takes the form | ||
of a sky map. | ||
- `sched_maps`, a tool for examing some elements of the state of objects used by | ||
the scheduler, particularly those that take the form of a sky map, although some | ||
indications of other elements are also present. | ||
|
||
The project contains example data for each. At present, to use the example data, | ||
different versions of dependencies are required, so the installation instructions | ||
are slightly different in each case. (The reason for this is that the pickles | ||
containing the sample objects to be viewed with `sched_maps` were created with | ||
an old version of `rubin_sim`, and this older version needs to be installed for | ||
these to be loaded.) | ||
|
||
## Installation | ||
|
||
First, get the code by cloning the github project: | ||
|
||
$ git clone [email protected]:ehneilsen/schedview.git | ||
|
||
Go to the development directory, and download and decompress a data file used | ||
by the automated tests. | ||
|
||
$ cd schedview | ||
$ wget -O schedview/data/bsc5.dat.gz http://tdc-www.harvard.edu/catalogs/bsc5.dat.gz | ||
$ gunzip schedview/data/bsc5.dat.gz | ||
|
||
Create a `conda` environment with the appropriate dependencies, and activate it. | ||
If you are running the `metric_maps` application, use the `conda` environment | ||
file that includes a recent version of `survey_sim`: | ||
|
||
$ # ONLY IF RUNNING metric_maps | ||
$ conda env create -f environment.yaml | ||
$ conda activate schedview | ||
|
||
If you are running `sched_maps`, get the one with the older version: | ||
|
||
$ # ONLY IF RUNNING sched_maps | ||
$ conda env create -f environment_080a2.yaml | ||
$ conda activate schedview080a2 | ||
|
||
Install the (development) `schedview` in your new environment: | ||
|
||
$ pip install -e . | ||
|
||
Run the tests: | ||
|
||
$ pytest | ||
|
||
## Running `metric_maps` | ||
|
||
Activate the environment, and start the `bokeh` app. If `SCHEDVIEW_DIR` is the | ||
directory into which you cloned the `schedview` github repository, then: | ||
|
||
$ conda activate schedview | ||
$ bokeh serve ${SCHEDVIEW_DIR}/schedview/app/metric_maps.py | ||
|
||
The app will then give you the URL at which you can find the app. The data | ||
displayed with the above instructions will be the sample metric map in the | ||
project itself. | ||
|
||
If you want to use a different data file, you can set the `METRIC_FNAME` | ||
to its path before running the `bokeh` app. This is only a very short term | ||
solution, and will be replaced soon. | ||
|
||
## Running `sched_maps` | ||
|
||
Activate the environment, and start the `bokeh` app. If `SCHEDVIEW_DIR` is the | ||
directory into which you cloned the `schedview` github repository, then: | ||
|
||
$ conda activate schedview080a2 | ||
$ bokeh serve ${SCHEDVIEW_DIR}/schedview/app/sched_maps.py | ||
|
||
The app will then give you the URL at which you can find the app. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: schedview | ||
channels: | ||
- conda-forge | ||
dependencies: | ||
- rubin-sim | ||
- bokeh | ||
- pytest-flake8 | ||
- pytest-black | ||
- selenium | ||
- firefox | ||
- geckodriver | ||
- build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
[build-system] | ||
requires = [ "setuptools", "setuptools_scm" ] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[project] | ||
name = "schedview" | ||
description = "Tools for visualization of Rubin Observatory's scheduler status, strategy and progress on LSST." | ||
classifiers = [ | ||
"Intended Audience :: Science/Research", | ||
"Operating System :: OS Independent", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3.10", | ||
"Topic :: Scientific/Engineering :: Astronomy", | ||
] | ||
dynamic = [ "version" ] | ||
|
||
[tool.setuptools.dynamic] | ||
version = { attr = "setuptools_scm.get_version" } | ||
|
||
[tool.setuptools.packages.find] | ||
where = [ "" ] | ||
|
||
[tool.setuptools_scm] | ||
write_to = "schedview/version.py" | ||
write_to_template = """ | ||
# Generated by setuptools_scm | ||
__all__ = ["__version__"] | ||
__version__ = "{version}" | ||
""" | ||
|
||
[tool.pytest.ini_options] | ||
addopts = "--flake8 --black --ignore-glob=*/version.py" | ||
flake8-ignore = ["E133", "E203", "E226", "E228", "N802", "N803", "N806", "N812", "N813", "N815", "N816", "W503", "**/*/__init__.py ALL", "**/*/version.py ALL"] | ||
flake8-max-line-length = 110 | ||
flake8-max-doc-length = 79 | ||
testpaths = "." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .sphere import * |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import bokeh.plotting | ||
|
||
from rubin_sim import maf | ||
|
||
from schedview.plot.SphereMap import ArmillarySphere, Planisphere, MollweideMap | ||
from schedview.collect.stars import load_bright_stars | ||
from schedview.collect import get_metric_path | ||
|
||
|
||
def make_metric_figure(metric_values_fname=None, nside=8, mag_limit_slider=True): | ||
"""Create a figure showing multiple projections of a set of a MAF metric. | ||
Parameters | ||
---------- | ||
metric_values_fname : `str`, optional | ||
Name of file from which to load metric values, as saved by MAF | ||
in a saved metric bundle. If it is None, the look for the | ||
file name in the ``METRIC_FNAME`` environment varable. By default None | ||
nside : `int`, optional | ||
Healpix nside to use for display, by default 8 | ||
mag_limit_slider : `bool`, optional | ||
Show the mag limit slider for stars?, by default True | ||
Returns | ||
------- | ||
fig : `bokeh.models.layouts.LayoutDOM` | ||
A bokeh figure that can be displayed in a notebook (e.g. with | ||
``bokeh.io.show``) or used to create a bokeh app. | ||
Notes | ||
----- | ||
If ``mag_limit_slider`` is ``True``, it creates a magnitude limit | ||
slider for the stars. This is implemented as a python callback, and | ||
so is only operational in full bokeh app, not standalone output. | ||
""" | ||
|
||
if metric_values_fname is None: | ||
metric_values_fname = get_metric_path() | ||
|
||
healpy_values = maf.MetricBundle.load(metric_values_fname).metricValues | ||
|
||
star_data = load_bright_stars().loc[:, ["name", "ra", "decl", "Vmag"]] | ||
star_data["glyph_size"] = 15 - (15.0 / 3.5) * star_data["Vmag"] | ||
star_data.query("glyph_size>0", inplace=True) | ||
|
||
arm = ArmillarySphere() | ||
hp_ds, cmap, _ = arm.add_healpix(healpy_values, nside=nside) | ||
hz = arm.add_horizon() | ||
zd70 = arm.add_horizon(zd=70, line_kwargs={"color": "red", "line_width": 2}) | ||
star_ds = arm.add_stars( | ||
star_data, mag_limit_slider=mag_limit_slider, star_kwargs={"color": "black"} | ||
) | ||
arm.decorate() | ||
|
||
pla = Planisphere() | ||
pla.add_healpix(hp_ds, cmap=cmap, nside=nside) | ||
pla.add_horizon(data_source=hz) | ||
pla.add_horizon( | ||
zd=60, data_source=zd70, line_kwargs={"color": "red", "line_width": 2} | ||
) | ||
pla.add_stars( | ||
star_data, | ||
data_source=star_ds, | ||
mag_limit_slider=False, | ||
star_kwargs={"color": "black"}, | ||
) | ||
pla.decorate() | ||
|
||
mol_plot = bokeh.plotting.figure(plot_width=512, plot_height=256, match_aspect=True) | ||
mol = MollweideMap(plot=mol_plot) | ||
mol.add_healpix(hp_ds, cmap=cmap, nside=nside) | ||
mol.add_horizon(data_source=hz) | ||
mol.add_horizon( | ||
zd=70, data_source=zd70, line_kwargs={"color": "red", "line_width": 2} | ||
) | ||
mol.add_stars( | ||
star_data, | ||
data_source=star_ds, | ||
mag_limit_slider=False, | ||
star_kwargs={"color": "black"}, | ||
) | ||
mol.decorate() | ||
|
||
figure = bokeh.layouts.row( | ||
bokeh.layouts.column(mol.plot, *arm.sliders.values()), arm.plot, pla.plot | ||
) | ||
|
||
return figure | ||
|
||
|
||
def add_metric_app(doc): | ||
"""Add a metric figure to a bokeh document | ||
Parameters | ||
---------- | ||
doc : `bokeh.document.document.Document` | ||
The bokeh document to which to add the figure. | ||
""" | ||
figure = make_metric_figure() | ||
doc.add_root(figure) | ||
|
||
|
||
if __name__.startswith("bokeh_app_"): | ||
doc = bokeh.plotting.curdoc() | ||
add_metric_app(doc) |
Oops, something went wrong.