From 56f9eb5799ef847817e8423fd964129e96ced123 Mon Sep 17 00:00:00 2001 From: Eric Neilsen Date: Fri, 6 Oct 2023 16:14:28 -0500 Subject: [PATCH] add instructions for generating rewards data for prenight --- docs/usage.rst | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/docs/usage.rst b/docs/usage.rst index 77a80e82..6719234a 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -53,3 +53,31 @@ You can also supply an initial set of data files to show on startup: > --scheduler /sdf/data/rubin/user/neilsen/devel/schedview/schedview/data/sample_scheduler.pickle.xz \ > --rewards /sdf/data/rubin/user/neilsen/devel/schedview/schedview/data/sample_rewards.h5 \ > --port 8080 + +The (optional) rewards data, used in the "Rewards plot" tab, can be generated +by adding an extra option to ``sim_runner`` when running the simulation that +creates the opsim database being examined. +For example, to return the data when running ``sim_runner``: + +:: + + >>> from rubin_sim.scheduler import sim_runner + >>> observatory, scheduler, observations, reward_df, obs_rewards = sim_runner( + ... observatory, + ... scheduler, + ... mjd_start=mjd_start, + ... survey_length=night_duration, + ... record_rewards=True, + ... ) + +The returned ``reward_df`` and ``obs_rewards`` data can then be saved to an `h5` +file that can then be loaded by ``prenight``: + +:: + + >>> rewards_fname = "my_rewards.h5" + >>> reward_df.to_hdf(rewards_fname, "reward_df") + >>> obs_rewards.to_hdf(rewards_fname, "obs_rewards") + +To be valid, the rewards data *must* be generated by the same execution of +``sim_runner`` that generates the opsim database being examined. \ No newline at end of file