-
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.
Merge pull request #98 from lsst/tickets/PREOPS-5245
tickets/PREOPS-5245: Add support for reading visits from ConsDB
- Loading branch information
Showing
2 changed files
with
39 additions
and
0 deletions.
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,18 @@ | ||
import numpy as np | ||
import pandas as pd | ||
import rubin_sim.maf | ||
from rubin_scheduler.utils.consdb import load_consdb_visits | ||
|
||
|
||
def read_consdb( | ||
instrument: str = "lsstcomcamsim", | ||
*args, | ||
stackers: list[rubin_sim.maf.stackers.base_stacker.BaseStacker] = [], | ||
**kwargs, | ||
) -> pd.DataFrame: | ||
consdb_visits = load_consdb_visits(instrument, *args, **kwargs) | ||
visit_records: np.recarray = consdb_visits.opsim.to_records() | ||
for stacker in stackers: | ||
visit_records = stacker.run(visit_records) | ||
visits = pd.DataFrame(visit_records) | ||
return visits |
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,21 @@ | ||
import unittest | ||
|
||
import pandas as pd | ||
from rubin_sim import maf | ||
|
||
from schedview.collect.consdb import read_consdb | ||
|
||
|
||
class TestConsdb(unittest.TestCase): | ||
|
||
@unittest.skip("avoid requiring access to consdb for tests.") | ||
def test_consdb_read_consdb(self): | ||
day_obs: str = "2024-06-26" | ||
stackers = [ | ||
maf.stackers.OverheadStacker(), | ||
maf.HourAngleStacker(), | ||
maf.stackers.ObservationStartDatetime64Stacker(), | ||
] | ||
visits: pd.DataFrame = read_consdb("lsstcomcamsim", day_obs, stackers=stackers) | ||
assert "HA" in visits.columns | ||
assert "overhead" in visits.columns |