Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tickets/PREOPS-5528: Move schedview DDF to use new opsim schema #104

Merged
merged 4 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ For example, to return the data when running ``sim_runner``:
>>> observatory, scheduler, observations, reward_df, obs_rewards = sim_runner(
... observatory,
... scheduler,
... mjd_start=mjd_start,
... survey_length=night_duration,
... sim_start_mjd=mjd_start,
... sim_duration=night_duration,
... record_rewards=True,
... )

Expand Down
6 changes: 3 additions & 3 deletions notebooks/make_test_schedulers.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"mjd_start = survey_start_mjd()\n",
"model_observatory = ModelObservatory(mjd_start=mjd_start)\n",
"nside = model_observatory.nside\n",
"survey_length = (4*u.hour).to(u.day).value"
"sim_duration = (4*u.hour).to(u.day).value"
]
},
{
Expand Down Expand Up @@ -349,8 +349,8 @@
"observatory, scheduler, observations, reward_df, obs_rewards = sim_runner(\n",
" model_observatory,\n",
" scheduler,\n",
" mjd_start=mjd_start,\n",
" survey_length=survey_length,\n",
" sim_start_mjd=mjd_start,\n",
" sim_duration=sim_duration,\n",
" record_rewards=True,\n",
")\n",
"conditions = scheduler.conditions"
Expand Down
18 changes: 9 additions & 9 deletions notebooks/prenight.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,11 @@
" == evening_mjd\n",
")\n",
"\n",
"mjd_start = observatory.almanac.sunsets[this_night][\"sun_n12_setting\"][0]\n",
"mjd_end = observatory.almanac.sunsets[this_night][\"sunrise\"][0]\n",
"sim_start_mjd = observatory.almanac.sunsets[this_night][\"sun_n12_setting\"][0]\n",
"sim_end_mjd = observatory.almanac.sunsets[this_night][\"sunrise\"][0]\n",
"\n",
"night_duration = mjd_end - mjd_start\n",
"time_start = Time(mjd_start, format=\"mjd\")\n",
"night_duration = sim_start_mjd - sim_end_mjd\n",
"time_start = Time(sim_start_mjd, format=\"mjd\")\n",
"time_start.iso, night_duration"
]
},
Expand All @@ -319,7 +319,7 @@
},
"outputs": [],
"source": [
"observatory = ModelObservatory(mjd_start=mjd_start)"
"observatory = ModelObservatory(mjd_start=sim_start_mjd)"
]
},
{
Expand All @@ -331,7 +331,7 @@
},
"outputs": [],
"source": [
"scheduler = example_scheduler(mjd_start=mjd_start)"
"scheduler = example_scheduler(mjd_start=sim_start_mjd)"
]
},
{
Expand Down Expand Up @@ -369,15 +369,15 @@
"source": [
"if not keep_rewards:\n",
" observatory, scheduler, observations = sim_runner(\n",
" observatory, scheduler, mjd_start=mjd_start, survey_length=night_duration\n",
" observatory, scheduler, sim_start_mjd=sim_start_mjd, sim_duration=night_duration\n",
" )\n",
"else:\n",
" scheduler.keep_rewards = True\n",
" observatory, scheduler, observations, reward_df, obs_rewards = sim_runner(\n",
" observatory,\n",
" scheduler,\n",
" mjd_start=mjd_start,\n",
" survey_length=night_duration,\n",
" sim_start_mjd=sim_start_mjd,\n",
" sim_duration=night_duration,\n",
" record_rewards=True,\n",
" )"
]
Expand Down
6 changes: 3 additions & 3 deletions notebooks/prenight_rewardplot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,15 @@
},
"outputs": [],
"source": [
"survey_length = 1.0 # days\n",
"sim_duration = 1.0 # days\n",
"scheduler = example_scheduler()\n",
"scheduler.keep_rewards = True\n",
"observatory = ModelObservatory(mjd_start=mjd_start)\n",
"observatory, scheduler, observations, reward_df, obs_rewards = sim_runner(\n",
" observatory,\n",
" scheduler,\n",
" mjd_start=mjd_start,\n",
" survey_length=survey_length,\n",
" sim_start_mjd=mjd_start,\n",
" sim_duration=sim_duration,\n",
" record_rewards=True,\n",
" filename=\"rewards.db\",\n",
")"
Expand Down
14 changes: 7 additions & 7 deletions notebooks/sim_archive.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,8 @@
" evening_date=evening_iso8601, longitude=observatory.location.lon\n",
")\n",
"\n",
"mjd_start = night_sunset_info[\"sun_n12_setting\"]\n",
"night_duration = night_sunset_info[\"sunrise\"] - mjd_start"
"sim_start_mjd= night_sunset_info[\"sun_n12_setting\"]\n",
"night_duration = night_sunset_info[\"sunrise\"] - sim_start_mjd"
]
},
{
Expand All @@ -307,7 +307,7 @@
},
"outputs": [],
"source": [
"observatory = ModelObservatory(mjd_start=mjd_start)"
"observatory = ModelObservatory(mjd_start=sim_start_mjd)"
]
},
{
Expand All @@ -319,7 +319,7 @@
},
"outputs": [],
"source": [
"scheduler = example_scheduler(mjd_start=mjd_start)\n",
"scheduler = example_scheduler(mjd_start=sim_start_mjd)\n",
"scheduler.keep_rewards = True"
]
},
Expand Down Expand Up @@ -478,8 +478,8 @@
" label=f\"Notebook test on {exec_start_time.iso}\",\n",
" notebook=notebook_fname,\n",
" tags=[\"notebook\", \"devel\"],\n",
" mjd_start=mjd_start,\n",
" survey_length=night_duration,\n",
" sim_start_mjd=sim_start_mjd,\n",
" sim_duration=night_duration,\n",
")"
]
},
Expand Down Expand Up @@ -518,7 +518,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.6"
"version": "3.11.8"
}
},
"nbformat": 4,
Expand Down
8 changes: 4 additions & 4 deletions schedview/compute/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ def create_example(
observatory, scheduler, observations, reward_df, obs_rewards = sim_runner(
observatory,
scheduler,
mjd_start=survey_start.mjd,
survey_length=sim_duration,
sim_start_mjd=survey_start.mjd,
sim_duration=sim_duration,
record_rewards=True,
)
reward_df.to_hdf(rewards_fname, "reward_df")
Expand All @@ -258,8 +258,8 @@ def create_example(
observatory, scheduler, observations = sim_runner(
observatory,
scheduler,
mjd_start=survey_start.mjd,
survey_length=sim_duration,
sim_start_mjd=survey_start.mjd,
sim_duration=sim_duration,
)

if opsim_db_fname is not None:
Expand Down
Binary file modified schedview/data/sample_opsim.db
Binary file not shown.
Binary file modified schedview/data/sample_rewards.h5
Binary file not shown.
Binary file modified schedview/data/sample_scheduler.pickle.xz
Binary file not shown.
5 changes: 3 additions & 2 deletions schedview/plot/cadence.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ def create_cadence_plot(
Parameters
----------
nightly_totals : `pandas.DataFrame`
A DataFrame indexed by ``"target"`` (`str`) and ``"day_obs_iso8601"``
A DataFrame indexed by ``"targe_name"`` (`str`) and
``"day_obs_iso8601"``
(`str` in YYYY-MM-DD format), filter names as column names (`float`),
with total effective exposure times.
start_dayobs_mjd : `float`
Expand All @@ -37,7 +38,7 @@ def create_cadence_plot(
The bokeh plot with cadence plots for all targets.
"""
if targets is None:
targets = tuple(nightly_totals.index.get_level_values("target").unique())
targets = tuple(nightly_totals.index.get_level_values("target_name").unique())

date_factors = [Time(mjd, format="mjd").iso[:10] for mjd in np.arange(start_dayobs_mjd, end_dayobs_mjd)]
band_factors = cmap.transform.factors
Expand Down
14 changes: 7 additions & 7 deletions util/sample_data/make_sample_test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,24 +107,24 @@ def make_sample_test_data():
np.floor(observatory.almanac.sunsets["sunset"] + observatory.site.longitude / 360) == evening_mjd
)

mjd_start = observatory.almanac.sunsets[this_night]["sun_n12_setting"][0]
mjd_end = observatory.almanac.sunsets[this_night]["sunrise"][0]
sim_start_mjd = observatory.almanac.sunsets[this_night]["sun_n12_setting"][0]
sim_end_mjd = observatory.almanac.sunsets[this_night]["sunrise"][0]

if args.duration is not None:
duration = args.duration / 24.0
else:
duration = mjd_end - mjd_start
duration = sim_end_mjd - sim_start_mjd

observatory = ModelObservatory(mjd_start=mjd_start)
observatory = ModelObservatory(mjd_start=sim_start_mjd)

scheduler = example_scheduler(mjd_start=mjd_start)
scheduler = example_scheduler(mjd_start=sim_start_mjd)
scheduler.keep_rewards = True

observatory, scheduler, observations, reward_df, obs_rewards = sim_runner(
observatory,
scheduler,
mjd_start=mjd_start,
survey_length=duration,
sim_start_mjd=sim_start_mjd,
sim_duration=duration,
record_rewards=True,
)

Expand Down
Loading