diff --git a/notebooks/make_test_schedulers.ipynb b/notebooks/make_test_schedulers.ipynb new file mode 100644 index 00000000..fa05db47 --- /dev/null +++ b/notebooks/make_test_schedulers.ipynb @@ -0,0 +1,1992 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "5bd48342-698f-4fa6-bf5a-951034d41f3f", + "metadata": { + "execution": { + "iopub.execute_input": "2023-10-18T17:42:18.128209Z", + "iopub.status.busy": "2023-10-18T17:42:18.127911Z", + "iopub.status.idle": "2023-10-18T17:42:18.130573Z", + "shell.execute_reply": "2023-10-18T17:42:18.130150Z", + "shell.execute_reply.started": "2023-10-18T17:42:18.128195Z" + }, + "tags": [] + }, + "source": [ + "# Create scheduler pickles for testing `schedview`" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "20b7a7e4-a1dd-4703-8830-d64e6c9a7341", + "metadata": { + "execution": { + "iopub.execute_input": "2023-10-27T19:43:30.551765Z", + "iopub.status.busy": "2023-10-27T19:43:30.551649Z", + "iopub.status.idle": "2023-10-27T19:43:30.553836Z", + "shell.execute_reply": "2023-10-27T19:43:30.553496Z", + "shell.execute_reply.started": "2023-10-27T19:43:30.551752Z" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "from collections import namedtuple\n", + "import lzma\n", + "import pickle\n", + "from pathlib import Path\n", + "import warnings" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "b89b4ab2-8751-4518-a7dc-db9cb732ac2a", + "metadata": { + "execution": { + "iopub.execute_input": "2023-10-27T19:43:30.570022Z", + "iopub.status.busy": "2023-10-27T19:43:30.569904Z", + "iopub.status.idle": "2023-10-27T19:43:32.522677Z", + "shell.execute_reply": "2023-10-27T19:43:32.522159Z", + "shell.execute_reply.started": "2023-10-27T19:43:30.570010Z" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "import numpy as np\n", + "import pandas as pd\n", + "import healpy as hp\n", + "import rubin_sim\n", + "from astropy.time import Time\n", + "import astropy.units as u\n", + "import astropy.coordinates\n", + "from rubin_sim.scheduler.model_observatory import ModelObservatory\n", + "from rubin_sim.scheduler.surveys.field_survey import FieldSurvey\n", + "from rubin_sim.scheduler.schedulers import CoreScheduler\n", + "import rubin_sim.scheduler.basis_functions as bf\n", + "from rubin_sim.scheduler import sim_runner\n", + "import schedview.collect\n", + "import schedview.compute\n", + "from rubin_sim.utils import survey_start_mjd" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "96800bac-3d6f-4325-ad09-20780c704096", + "metadata": { + "execution": { + "iopub.execute_input": "2023-10-27T19:43:32.523802Z", + "iopub.status.busy": "2023-10-27T19:43:32.523620Z", + "iopub.status.idle": "2023-10-27T19:43:32.526332Z", + "shell.execute_reply": "2023-10-27T19:43:32.525920Z", + "shell.execute_reply.started": "2023-10-27T19:43:32.523788Z" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "SchedulerPickleContent = namedtuple('SchedulerPickleContent', ['scheduler', 'conditions'])" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "1681d2ba-4d80-416b-8dc3-2fdc88ce5fe7", + "metadata": { + "execution": { + "iopub.execute_input": "2023-10-27T19:43:32.526984Z", + "iopub.status.busy": "2023-10-27T19:43:32.526843Z", + "iopub.status.idle": "2023-10-27T19:43:35.618399Z", + "shell.execute_reply": "2023-10-27T19:43:35.617968Z", + "shell.execute_reply.started": "2023-10-27T19:43:32.526969Z" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "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" + ] + }, + { + "cell_type": "markdown", + "id": "2713726d-4343-4062-8df1-d904df9f77a8", + "metadata": {}, + "source": [ + "# Create a near-baseline sample scheduler" + ] + }, + { + "cell_type": "markdown", + "id": "d6e32f02-db64-4d1a-b7f2-4ac6aa98bdf2", + "metadata": {}, + "source": [ + "Use the `make_sample_test_data.py` script in `schedview`, found in `util/sample_data`:" + ] + }, + { + "cell_type": "raw", + "id": "01f53ab6-4b7e-4062-974c-89317d47e6ba", + "metadata": {}, + "source": [ + "python ../util/sample_data/make_sample_test_data.py --duration 4 " + ] + }, + { + "cell_type": "markdown", + "id": "c946d51c-8582-4082-81e2-606efaef30a0", + "metadata": {}, + "source": [ + "# Get a production auxtel scheduler" + ] + }, + { + "cell_type": "markdown", + "id": "958df168-c723-4b03-a0cd-29e9f9b108d0", + "metadata": {}, + "source": [ + "Use python `efd_sched.py` script in `schedview`, found in `util`" + ] + }, + { + "cell_type": "markdown", + "id": "0783496d-c1ad-4d5d-b04d-b6d9b84a8e08", + "metadata": {}, + "source": [ + "# Create schedulers with problems" + ] + }, + { + "cell_type": "markdown", + "id": "83bb41d6-6ad5-4f38-b8e0-acd83c4f8ce0", + "metadata": {}, + "source": [ + "## Introduction\n", + "\n", + "I start by making an example scheduler with two tiers. The first tier is an equatorial survey in with fields every hour, such that there should be fields visible at all times.\n", + "The second tier is a single greed survey (in g) covering the whole sky." + ] + }, + { + "cell_type": "markdown", + "id": "62c36cd9-7b32-48f8-aeea-bf4951555cca", + "metadata": {}, + "source": [ + "## Make some basis functions" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "c4439c24-ba6a-4ca0-9406-df668cf1c507", + "metadata": { + "execution": { + "iopub.execute_input": "2023-10-27T19:43:35.619061Z", + "iopub.status.busy": "2023-10-27T19:43:35.618938Z", + "iopub.status.idle": "2023-10-27T19:43:35.622546Z", + "shell.execute_reply": "2023-10-27T19:43:35.622203Z", + "shell.execute_reply.started": "2023-10-27T19:43:35.619048Z" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "def make_sky_bf_list(band='g', nside=32):\n", + " not_twilight = bf.feasibility_funcs.NotTwilightBasisFunction()\n", + " moon_limit = bf.mask_basis_funcs.MoonAvoidanceBasisFunction(nside=nside, moon_distance=30.0)\n", + " zenith_limit = bf.mask_basis_funcs.ZenithShadowMaskBasisFunction(nside=nside, min_alt=20.0, max_alt=82.0)\n", + " sky_brightness_limit = bf.basis_functions.SkybrightnessLimitBasisFunction(nside=nside, filtername=band, sbmin=18.5, sbmax=30)\n", + " wind_limit = bf.basis_functions.AvoidDirectWind(5)\n", + " m5diff = bf.basis_functions.M5DiffBasisFunction(filtername=band, nside=nside)\n", + " basis_functions = [\n", + " not_twilight,\n", + " moon_limit,\n", + " zenith_limit,\n", + " sky_brightness_limit,\n", + " wind_limit,\n", + " m5diff\n", + " ]\n", + " return basis_functions" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "2bb70e9d-925a-477f-b304-f5195986f124", + "metadata": { + "execution": { + "iopub.execute_input": "2023-10-27T19:43:35.623877Z", + "iopub.status.busy": "2023-10-27T19:43:35.623744Z", + "iopub.status.idle": "2023-10-27T19:43:35.626559Z", + "shell.execute_reply": "2023-10-27T19:43:35.626188Z", + "shell.execute_reply.started": "2023-10-27T19:43:35.623862Z" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "def make_field_bf_list(ra, decl, band='g', nside=32):\n", + " basis_functions = make_sky_bf_list(band=band, nside=nside)\n", + " basis_functions.append(bf.feasibility_funcs.HourAngleLimitBasisFunction(RA=ra, ha_limits=[[22,24], [0,2]]))\n", + " return basis_functions" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "62f9d5d0-4dc8-4c4f-b2f5-524458268250", + "metadata": { + "execution": { + "iopub.execute_input": "2023-10-27T19:43:35.627157Z", + "iopub.status.busy": "2023-10-27T19:43:35.627036Z", + "iopub.status.idle": "2023-10-27T19:43:35.631772Z", + "shell.execute_reply": "2023-10-27T19:43:35.631406Z", + "shell.execute_reply.started": "2023-10-27T19:43:35.627146Z" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "def make_field_survey(ra, decl, band='g', nside=32):\n", + " basis_functions = make_field_bf_list(ra, decl, band=band, nside=nside)\n", + " sequence = band\n", + " nvis = [1]*len(band)\n", + " survey_name = f\"field_{ra}_{'n' if decl<0 else 'p'}{np.abs(decl)}_{band}\"\n", + " survey = FieldSurvey(basis_functions, np.array([ra]), np.array([decl]), sequence=sequence, nvis=nvis, nside=nside, survey_name=survey_name, reward_value=1.0)\n", + " return survey" + ] + }, + { + "cell_type": "markdown", + "id": "c9930fb1-3e1e-4739-b086-ba7f5d8ad805", + "metadata": {}, + "source": [ + "## Make an equatorial survey in g" + ] + }, + { + "cell_type": "markdown", + "id": "dcee9fd3-d10c-4461-82ef-215519700d71", + "metadata": {}, + "source": [ + "Start by making a list of field surveys in g on the equator, with fields spaced every hour (15 degrees):" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "a24c465e-719c-498e-942f-190dc604946d", + "metadata": { + "execution": { + "iopub.execute_input": "2023-10-27T19:43:35.632364Z", + "iopub.status.busy": "2023-10-27T19:43:35.632235Z", + "iopub.status.idle": "2023-10-27T19:43:35.719031Z", + "shell.execute_reply": "2023-10-27T19:43:35.718605Z", + "shell.execute_reply.started": "2023-10-27T19:43:35.632352Z" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "decl = 0\n", + "band = 'g'\n", + "field_surveys = [make_field_survey(ra, decl, band, nside) for ra in range(0, 360, 15)]" + ] + }, + { + "cell_type": "markdown", + "id": "3cb0b075-c16f-46c0-b17d-5f3e8cb9c9da", + "metadata": {}, + "source": [ + "As a fallback, greate a greedy survey in g that covers the whole sky:" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "cf7a6c39-a974-472f-92bd-c26f6e48facf", + "metadata": { + "execution": { + "iopub.execute_input": "2023-10-27T19:43:35.719728Z", + "iopub.status.busy": "2023-10-27T19:43:35.719601Z", + "iopub.status.idle": "2023-10-27T19:43:35.968489Z", + "shell.execute_reply": "2023-10-27T19:43:35.967971Z", + "shell.execute_reply.started": "2023-10-27T19:43:35.719716Z" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "sky_basis_functions = make_sky_bf_list(band=band, nside=nside)\n", + "weights = [1] * len(sky_basis_functions)\n", + "greedy_surveys = [rubin_sim.scheduler.surveys.surveys.GreedySurvey(sky_basis_functions, weights, filtername=band, survey_name=f\"greedy_{band}\")]" + ] + }, + { + "cell_type": "markdown", + "id": "524082a6-885e-4c29-a80e-301bf7a1e2c0", + "metadata": {}, + "source": [ + "Actually create the scheduler:" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "dce7eaf9-dc00-4a27-8810-5dfc2984b1df", + "metadata": { + "execution": { + "iopub.execute_input": "2023-10-27T19:43:35.969170Z", + "iopub.status.busy": "2023-10-27T19:43:35.969044Z", + "iopub.status.idle": "2023-10-27T19:43:35.984853Z", + "shell.execute_reply": "2023-10-27T19:43:35.984463Z", + "shell.execute_reply.started": "2023-10-27T19:43:35.969158Z" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "scheduler = CoreScheduler([field_surveys, greedy_surveys], nside=nside)" + ] + }, + { + "cell_type": "markdown", + "id": "c80e31a6-8372-4617-b21a-16457aab0716", + "metadata": {}, + "source": [ + "Configure the scheduler to keep reward values:" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "a9351e92-5106-4209-b3dc-be8312fe4c9b", + "metadata": { + "execution": { + "iopub.execute_input": "2023-10-27T19:43:35.985487Z", + "iopub.status.busy": "2023-10-27T19:43:35.985364Z", + "iopub.status.idle": "2023-10-27T19:43:35.987401Z", + "shell.execute_reply": "2023-10-27T19:43:35.987047Z", + "shell.execute_reply.started": "2023-10-27T19:43:35.985476Z" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "scheduler.keep_rewards = True" + ] + }, + { + "cell_type": "markdown", + "id": "de8c1752-464d-41c0-b81d-ff18f7c1beb5", + "metadata": {}, + "source": [ + "Actually run the survey for a little bit:" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "a74d2196-eaf5-4177-ae91-3db2a30504b1", + "metadata": { + "execution": { + "iopub.execute_input": "2023-10-27T19:43:35.987983Z", + "iopub.status.busy": "2023-10-27T19:43:35.987866Z", + "iopub.status.idle": "2023-10-27T19:44:21.398305Z", + "shell.execute_reply": "2023-10-27T19:44:21.397838Z", + "shell.execute_reply.started": "2023-10-27T19:43:35.987972Z" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "progress = 75.46%Skipped 0 observations\n", + "Flushed 0 observations from queue for being stale\n", + "Completed 397 observations\n", + "ran in 0 min = 0.0 hours\n" + ] + } + ], + "source": [ + "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", + " record_rewards=True,\n", + ")\n", + "conditions = scheduler.conditions" + ] + }, + { + "cell_type": "markdown", + "id": "ff53fd9a-cc46-4fd9-ac90-7b1ff7f120d6", + "metadata": {}, + "source": [ + "Save the survey:" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "78a9f360-0aea-4964-8e32-a95d1b56a8ba", + "metadata": { + "execution": { + "iopub.execute_input": "2023-10-27T19:44:21.399088Z", + "iopub.status.busy": "2023-10-27T19:44:21.398924Z", + "iopub.status.idle": "2023-10-27T19:44:22.446474Z", + "shell.execute_reply": "2023-10-27T19:44:22.445986Z", + "shell.execute_reply.started": "2023-10-27T19:44:21.399075Z" + }, + "tags": [] + }, + "outputs": [ + { + "data": { + "text/plain": [ + "PosixPath('/sdf/data/rubin/user/neilsen/devel/schedview/tmp/eq_field_survey_v0.p.xz')" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "output_tuple = (scheduler, conditions)\n", + "fname = Path('../tmp/eq_field_survey_v0.p.xz').resolve()\n", + "with lzma.open(fname, 'wb') as sched_out:\n", + " pickle.dump(output_tuple, sched_out)\n", + "\n", + "fname" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "657d3bc7-f77f-4911-b0b8-705437fd5f0c", + "metadata": { + "execution": { + "iopub.execute_input": "2023-10-27T19:44:22.447260Z", + "iopub.status.busy": "2023-10-27T19:44:22.447079Z", + "iopub.status.idle": "2023-10-27T19:44:22.450233Z", + "shell.execute_reply": "2023-10-27T19:44:22.449837Z", + "shell.execute_reply.started": "2023-10-27T19:44:22.447247Z" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Conditions calculated for 2025-05-01 03:59:35.041 (mjd 60796.16637779371)\n" + ] + } + ], + "source": [ + "print(f\"Conditions calculated for {Time(conditions.mjd[0], format='mjd').iso} (mjd {conditions.mjd[0]})\")" + ] + }, + { + "cell_type": "markdown", + "id": "e919e900-edcd-4c44-948a-3a9b8e9d9458", + "metadata": {}, + "source": [ + "Take a look at one survey:" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "2b17dabd-fb8c-41e5-8306-e5a1314c62a6", + "metadata": { + "execution": { + "iopub.execute_input": "2023-10-27T19:44:22.452208Z", + "iopub.status.busy": "2023-10-27T19:44:22.452014Z", + "iopub.status.idle": "2023-10-27T19:44:22.836211Z", + "shell.execute_reply": "2023-10-27T19:44:22.835784Z", + "shell.execute_reply.started": "2023-10-27T19:44:22.452196Z" + }, + "tags": [] + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
basis_functionbasis_function_classfeasiblemax_basis_rewardbasis_areabasis_weightmax_accum_rewardaccum_areatier_labelsurvey_labelsurvey_classsurvey_reward
list_indexsurvey_index
01NotTwilightNotTwilightBasisFunctionTrue0.03.3571750.1428570.00000041252.961249tier 0field_15_p0_gFieldSurvey-inf
1MoonAvoidanceMoonAvoidanceBasisFunctionTrue1.03.3571750.1428570.14285741252.961249tier 0field_15_p0_gFieldSurvey-inf
1ZenithShadowMaskZenithShadowMaskBasisFunctionFalse-inf0.0000000.142857-inf0.000000tier 0field_15_p0_gFieldSurvey-inf
1SkybrightnessLimit gSkybrightnessLimitBasisFunctionFalse-inf0.0000000.142857-inf0.000000tier 0field_15_p0_gFieldSurvey-inf
1AvoidDirectWindAvoidDirectWindTrue0.03.3571750.142857-inf0.000000tier 0field_15_p0_gFieldSurvey-inf
1M5Diff gM5DiffBasisFunctionFalse-inf0.0000000.142857-inf0.000000tier 0field_15_p0_gFieldSurvey-inf
1HourAngleLimitHourAngleLimitBasisFunctionFalse-inf3.3571750.142857-inf0.000000tier 0field_15_p0_gFieldSurvey-inf
\n", + "
" + ], + "text/plain": [ + " basis_function \\\n", + "list_index survey_index \n", + "0 1 NotTwilight \n", + " 1 MoonAvoidance \n", + " 1 ZenithShadowMask \n", + " 1 SkybrightnessLimit g \n", + " 1 AvoidDirectWind \n", + " 1 M5Diff g \n", + " 1 HourAngleLimit \n", + "\n", + " basis_function_class feasible \\\n", + "list_index survey_index \n", + "0 1 NotTwilightBasisFunction True \n", + " 1 MoonAvoidanceBasisFunction True \n", + " 1 ZenithShadowMaskBasisFunction False \n", + " 1 SkybrightnessLimitBasisFunction False \n", + " 1 AvoidDirectWind True \n", + " 1 M5DiffBasisFunction False \n", + " 1 HourAngleLimitBasisFunction False \n", + "\n", + " max_basis_reward basis_area basis_weight \\\n", + "list_index survey_index \n", + "0 1 0.0 3.357175 0.142857 \n", + " 1 1.0 3.357175 0.142857 \n", + " 1 -inf 0.000000 0.142857 \n", + " 1 -inf 0.000000 0.142857 \n", + " 1 0.0 3.357175 0.142857 \n", + " 1 -inf 0.000000 0.142857 \n", + " 1 -inf 3.357175 0.142857 \n", + "\n", + " max_accum_reward accum_area tier_label \\\n", + "list_index survey_index \n", + "0 1 0.000000 41252.961249 tier 0 \n", + " 1 0.142857 41252.961249 tier 0 \n", + " 1 -inf 0.000000 tier 0 \n", + " 1 -inf 0.000000 tier 0 \n", + " 1 -inf 0.000000 tier 0 \n", + " 1 -inf 0.000000 tier 0 \n", + " 1 -inf 0.000000 tier 0 \n", + "\n", + " survey_label survey_class survey_reward \n", + "list_index survey_index \n", + "0 1 field_15_p0_g FieldSurvey -inf \n", + " 1 field_15_p0_g FieldSurvey -inf \n", + " 1 field_15_p0_g FieldSurvey -inf \n", + " 1 field_15_p0_g FieldSurvey -inf \n", + " 1 field_15_p0_g FieldSurvey -inf \n", + " 1 field_15_p0_g FieldSurvey -inf \n", + " 1 field_15_p0_g FieldSurvey -inf " + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "scheduler_reward_df = scheduler.make_reward_df(conditions, accum=True)\n", + "scheduler_reward_df.loc[(0,1),:]" + ] + }, + { + "cell_type": "markdown", + "id": "37e0c383-74f5-4148-9afa-eeff4b28f22d", + "metadata": {}, + "source": [ + "Take a look at the rewards for all surveys." + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "bc30a69b-7800-40a9-b18c-4e6ae1657f52", + "metadata": { + "execution": { + "iopub.execute_input": "2023-10-27T19:44:22.836865Z", + "iopub.status.busy": "2023-10-27T19:44:22.836741Z", + "iopub.status.idle": "2023-10-27T19:44:22.867707Z", + "shell.execute_reply": "2023-10-27T19:44:22.867194Z", + "shell.execute_reply.started": "2023-10-27T19:44:22.836853Z" + }, + "tags": [] + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
tiersurvey_namesurvey_urlreward
0tier 00: field_0_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...ZenithShadowMask, SkybrightnessLimit g, M5Diff...
1tier 010: field_150_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...HourAngleLimit
2tier 011: field_165_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...HourAngleLimit
3tier 012: field_180_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...0.467255
4tier 013: field_195_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...0.480597
5tier 014: field_210_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...0.482711
6tier 015: field_225_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...0.474278
7tier 016: field_240_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...HourAngleLimit
8tier 017: field_255_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...HourAngleLimit
9tier 018: field_270_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...SkybrightnessLimit g, M5Diff g, HourAngleLimit
10tier 019: field_285_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...ZenithShadowMask, SkybrightnessLimit g, M5Diff...
11tier 01: field_15_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...ZenithShadowMask, SkybrightnessLimit g, M5Diff...
12tier 020: field_300_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...ZenithShadowMask, SkybrightnessLimit g, M5Diff...
13tier 021: field_315_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...ZenithShadowMask, SkybrightnessLimit g, M5Diff...
14tier 022: field_330_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...ZenithShadowMask, SkybrightnessLimit g, M5Diff...
15tier 023: field_345_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...ZenithShadowMask, SkybrightnessLimit g, M5Diff...
16tier 02: field_30_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...ZenithShadowMask, SkybrightnessLimit g, M5Diff...
17tier 03: field_45_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...ZenithShadowMask, SkybrightnessLimit g, M5Diff...
18tier 04: field_60_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...ZenithShadowMask, SkybrightnessLimit g, M5Diff...
19tier 05: field_75_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...ZenithShadowMask, SkybrightnessLimit g, M5Diff...
20tier 06: field_90_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...MoonAvoidance, ZenithShadowMask, Skybrightness...
21tier 07: field_105_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...ZenithShadowMask, SkybrightnessLimit g, M5Diff...
22tier 08: field_120_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...ZenithShadowMask, SkybrightnessLimit g, M5Diff...
23tier 09: field_135_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...ZenithShadowMask, SkybrightnessLimit g, M5Diff...
\n", + "
" + ], + "text/plain": [ + " tier survey_name \\\n", + "0 tier 0 0: field_0_p0_g \n", + "1 tier 0 10: field_150_p0_g \n", + "2 tier 0 11: field_165_p0_g \n", + "3 tier 0 12: field_180_p0_g \n", + "4 tier 0 13: field_195_p0_g \n", + "5 tier 0 14: field_210_p0_g \n", + "6 tier 0 15: field_225_p0_g \n", + "7 tier 0 16: field_240_p0_g \n", + "8 tier 0 17: field_255_p0_g \n", + "9 tier 0 18: field_270_p0_g \n", + "10 tier 0 19: field_285_p0_g \n", + "11 tier 0 1: field_15_p0_g \n", + "12 tier 0 20: field_300_p0_g \n", + "13 tier 0 21: field_315_p0_g \n", + "14 tier 0 22: field_330_p0_g \n", + "15 tier 0 23: field_345_p0_g \n", + "16 tier 0 2: field_30_p0_g \n", + "17 tier 0 3: field_45_p0_g \n", + "18 tier 0 4: field_60_p0_g \n", + "19 tier 0 5: field_75_p0_g \n", + "20 tier 0 6: field_90_p0_g \n", + "21 tier 0 7: field_105_p0_g \n", + "22 tier 0 8: field_120_p0_g \n", + "23 tier 0 9: field_135_p0_g \n", + "\n", + " survey_url \\\n", + "0 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "1 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "2 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "3 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "4 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "5 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "6 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "7 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "8 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "9 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "10 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "11 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "12 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "13 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "14 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "15 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "16 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "17 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "18 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "19 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "20 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "21 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "22 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "23 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "\n", + " reward \n", + "0 ZenithShadowMask, SkybrightnessLimit g, M5Diff... \n", + "1 HourAngleLimit \n", + "2 HourAngleLimit \n", + "3 0.467255 \n", + "4 0.480597 \n", + "5 0.482711 \n", + "6 0.474278 \n", + "7 HourAngleLimit \n", + "8 HourAngleLimit \n", + "9 SkybrightnessLimit g, M5Diff g, HourAngleLimit \n", + "10 ZenithShadowMask, SkybrightnessLimit g, M5Diff... \n", + "11 ZenithShadowMask, SkybrightnessLimit g, M5Diff... \n", + "12 ZenithShadowMask, SkybrightnessLimit g, M5Diff... \n", + "13 ZenithShadowMask, SkybrightnessLimit g, M5Diff... \n", + "14 ZenithShadowMask, SkybrightnessLimit g, M5Diff... \n", + "15 ZenithShadowMask, SkybrightnessLimit g, M5Diff... \n", + "16 ZenithShadowMask, SkybrightnessLimit g, M5Diff... \n", + "17 ZenithShadowMask, SkybrightnessLimit g, M5Diff... \n", + "18 ZenithShadowMask, SkybrightnessLimit g, M5Diff... \n", + "19 ZenithShadowMask, SkybrightnessLimit g, M5Diff... \n", + "20 MoonAvoidance, ZenithShadowMask, Skybrightness... \n", + "21 ZenithShadowMask, SkybrightnessLimit g, M5Diff... \n", + "22 ZenithShadowMask, SkybrightnessLimit g, M5Diff... \n", + "23 ZenithShadowMask, SkybrightnessLimit g, M5Diff... " + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "scheduler_summary_df = schedview.compute.make_scheduler_summary_df(scheduler, conditions, scheduler_reward_df)\n", + "scheduler_summary_df.query('tier==\"tier 0\"')" + ] + }, + { + "cell_type": "markdown", + "id": "f06b17b2-6f1f-4cca-95ac-220dbb22e945", + "metadata": {}, + "source": [ + "# Make a survey where everything is infeasible" + ] + }, + { + "cell_type": "markdown", + "id": "78145a0a-7990-45bc-afe7-527b492d5b76", + "metadata": {}, + "source": [ + "Create a combination of survey and conditions where everything is infeasible, blocked either by wind or by sky brightess, but where there are observations not blocked by both.\n", + "\n", + "The first full moon after the nominal survey start is 2025-05-12. This should be in the default limited sky brightness data set." + ] + }, + { + "cell_type": "markdown", + "id": "856f1e9b-8a81-410b-b7da-cd348f912cba", + "metadata": {}, + "source": [ + "Find the next full moon after the start of the survey:" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "81baec26-7670-4992-8db6-0408d49a2004", + "metadata": { + "execution": { + "iopub.execute_input": "2023-10-27T19:44:22.868408Z", + "iopub.status.busy": "2023-10-27T19:44:22.868273Z", + "iopub.status.idle": "2023-10-27T19:44:22.883968Z", + "shell.execute_reply": "2023-10-27T19:44:22.883567Z", + "shell.execute_reply.started": "2023-10-27T19:44:22.868393Z" + }, + "tags": [] + }, + "outputs": [ + { + "data": { + "text/plain": [ + "'2025-05-13 00:00:00.000'" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "month_mjds = np.arange(int(mjd_start), int(mjd_start)+30)\n", + "month_phases = np.array([model_observatory.almanac.get_sun_moon_positions(mjd)['moon_phase'] for mjd in month_mjds])\n", + "mjd = month_mjds[np.argmax(month_phases)]\n", + "Time(mjd, format='mjd').iso" + ] + }, + { + "cell_type": "markdown", + "id": "d3b3763c-45ca-4064-a09c-2105793772b6", + "metadata": {}, + "source": [ + "Find a time during the night where the moon is at a zd of about 55 degrees." + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "4e38e507-c9b5-4672-a98d-77ec46666140", + "metadata": { + "execution": { + "iopub.execute_input": "2023-10-27T19:44:22.884579Z", + "iopub.status.busy": "2023-10-27T19:44:22.884459Z", + "iopub.status.idle": "2023-10-27T19:44:22.893439Z", + "shell.execute_reply": "2023-10-27T19:44:22.892986Z", + "shell.execute_reply.started": "2023-10-27T19:44:22.884569Z" + }, + "tags": [] + }, + "outputs": [ + { + "data": { + "text/plain": [ + "('2025-05-13 02:06:31.806', 60808.08786812174)" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sunset_info = model_observatory.almanac.get_sunset_info(mjd)\n", + "sunset, sunrise = sunset_info[3], sunset_info[4]\n", + "for mjd in np.arange(sunset, sunrise, 1.0/(24*4)):\n", + " moon_alt = model_observatory.almanac.get_sun_moon_positions(mjd)['moon_alt']\n", + " if np.abs(np.degrees(moon_alt)-55) < 5:\n", + " break\n", + "\n", + "time_to_sched = Time(mjd, format='mjd')\n", + "time_to_sched.iso, mjd" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "6e222897-5a42-4cbd-a58b-e28c93cf04c5", + "metadata": { + "execution": { + "iopub.execute_input": "2023-10-27T19:44:22.894107Z", + "iopub.status.busy": "2023-10-27T19:44:22.893961Z", + "iopub.status.idle": "2023-10-27T19:44:22.896397Z", + "shell.execute_reply": "2023-10-27T19:44:22.895938Z", + "shell.execute_reply.started": "2023-10-27T19:44:22.894096Z" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "model_observatory.mjd = time_to_sched.mjd" + ] + }, + { + "cell_type": "markdown", + "id": "7d069d75-3b17-4fc5-9dc9-c61fa6322ca3", + "metadata": {}, + "source": [ + "Set the wind so it comes from the opposite direction." + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "id": "f842487e-c53d-4c43-a4f3-1a160c682496", + "metadata": { + "execution": { + "iopub.execute_input": "2023-10-27T19:44:22.896988Z", + "iopub.status.busy": "2023-10-27T19:44:22.896874Z", + "iopub.status.idle": "2023-10-27T19:44:22.900153Z", + "shell.execute_reply": "2023-10-27T19:44:22.899698Z", + "shell.execute_reply.started": "2023-10-27T19:44:22.896977Z" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "moon_az = model_observatory.almanac.get_sun_moon_positions(time_to_sched.mjd)['moon_az']\n", + "wind_az = moon_az - np.pi ;# opposite moon\n", + "wind_data = rubin_sim.site_models.ConstantWindData(wind_speed=18.0, wind_direction=wind_az)\n", + "model_observatory.wind_data = wind_data" + ] + }, + { + "cell_type": "markdown", + "id": "7e8dd32f-e7f2-47e6-b463-0b0cc4909a54", + "metadata": {}, + "source": [ + "Actually build our instance of Conditions:" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "id": "b3b3707d-1b43-4213-98d6-6f86b01a64d6", + "metadata": { + "execution": { + "iopub.execute_input": "2023-10-27T19:44:22.900796Z", + "iopub.status.busy": "2023-10-27T19:44:22.900681Z", + "iopub.status.idle": "2023-10-27T19:44:26.753093Z", + "shell.execute_reply": "2023-10-27T19:44:26.752640Z", + "shell.execute_reply.started": "2023-10-27T19:44:22.900786Z" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "conditions = model_observatory.return_conditions()" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "id": "775f7e96-2a26-46d0-8284-47867ed7feea", + "metadata": { + "execution": { + "iopub.execute_input": "2023-10-27T19:44:26.753821Z", + "iopub.status.busy": "2023-10-27T19:44:26.753697Z", + "iopub.status.idle": "2023-10-27T19:44:27.193877Z", + "shell.execute_reply": "2023-10-27T19:44:27.193494Z", + "shell.execute_reply.started": "2023-10-27T19:44:26.753808Z" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/sdf/data/rubin/user/neilsen/devel/rubin_sim/rubin_sim/scheduler/schedulers/core_scheduler.py:547: RuntimeWarning: All-NaN axis encountered\n", + " survey_df[\"survey_reward\"] = np.nanmax(survey.calc_reward_function(conditions))\n", + "/sdf/data/rubin/user/neilsen/devel/rubin_sim/rubin_sim/scheduler/schedulers/core_scheduler.py:547: RuntimeWarning: All-NaN axis encountered\n", + " survey_df[\"survey_reward\"] = np.nanmax(survey.calc_reward_function(conditions))\n", + "/sdf/data/rubin/user/neilsen/devel/rubin_sim/rubin_sim/scheduler/schedulers/core_scheduler.py:547: RuntimeWarning: All-NaN axis encountered\n", + " survey_df[\"survey_reward\"] = np.nanmax(survey.calc_reward_function(conditions))\n", + "/sdf/data/rubin/user/neilsen/devel/rubin_sim/rubin_sim/scheduler/schedulers/core_scheduler.py:547: RuntimeWarning: All-NaN axis encountered\n", + " survey_df[\"survey_reward\"] = np.nanmax(survey.calc_reward_function(conditions))\n", + "/sdf/data/rubin/user/neilsen/devel/rubin_sim/rubin_sim/scheduler/schedulers/core_scheduler.py:547: RuntimeWarning: All-NaN slice encountered\n", + " survey_df[\"survey_reward\"] = np.nanmax(survey.calc_reward_function(conditions))\n" + ] + }, + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
basis_functionbasis_function_classfeasiblemax_basis_rewardbasis_areabasis_weightmax_accum_rewardaccum_areatier_labelsurvey_labelsurvey_classsurvey_reward
list_indexsurvey_index
00NotTwilightNotTwilightBasisFunctionTrue0.0000003.3571750.1428570.00000041252.961249tier 0field_0_p0_gFieldSurvey-inf
0MoonAvoidanceMoonAvoidanceBasisFunctionTrue1.0000003.3571750.1428570.14285741252.961249tier 0field_0_p0_gFieldSurvey-inf
0ZenithShadowMaskZenithShadowMaskBasisFunctionFalse-inf0.0000000.142857-inf0.000000tier 0field_0_p0_gFieldSurvey-inf
0SkybrightnessLimit gSkybrightnessLimitBasisFunctionFalse-inf0.0000000.142857-inf0.000000tier 0field_0_p0_gFieldSurvey-inf
0AvoidDirectWindAvoidDirectWindTrue-52.6448173.3571750.142857-inf0.000000tier 0field_0_p0_gFieldSurvey-inf
..........................................
10MoonAvoidanceMoonAvoidanceBasisFunctionTrue1.00000038483.2922201.0000001.00000038483.292220tier 1greedy_gGreedySurveyNaN
0ZenithShadowMaskZenithShadowMaskBasisFunctionTrue1.00000013334.6974351.0000002.00000010601.957326tier 1greedy_gGreedySurveyNaN
0SkybrightnessLimit gSkybrightnessLimitBasisFunctionTrue1.0000002141.8773831.0000003.0000002141.877383tier 1greedy_gGreedySurveyNaN
0AvoidDirectWindAvoidDirectWindTrue-0.00020124329.4441871.000000-inf0.000000tier 1greedy_gGreedySurveyNaN
0M5Diff gM5DiffBasisFunctionTrue-1.63477312045.5423961.000000-inf0.000000tier 1greedy_gGreedySurveyNaN
\n", + "

174 rows × 12 columns

\n", + "
" + ], + "text/plain": [ + " basis_function \\\n", + "list_index survey_index \n", + "0 0 NotTwilight \n", + " 0 MoonAvoidance \n", + " 0 ZenithShadowMask \n", + " 0 SkybrightnessLimit g \n", + " 0 AvoidDirectWind \n", + "... ... \n", + "1 0 MoonAvoidance \n", + " 0 ZenithShadowMask \n", + " 0 SkybrightnessLimit g \n", + " 0 AvoidDirectWind \n", + " 0 M5Diff g \n", + "\n", + " basis_function_class feasible \\\n", + "list_index survey_index \n", + "0 0 NotTwilightBasisFunction True \n", + " 0 MoonAvoidanceBasisFunction True \n", + " 0 ZenithShadowMaskBasisFunction False \n", + " 0 SkybrightnessLimitBasisFunction False \n", + " 0 AvoidDirectWind True \n", + "... ... ... \n", + "1 0 MoonAvoidanceBasisFunction True \n", + " 0 ZenithShadowMaskBasisFunction True \n", + " 0 SkybrightnessLimitBasisFunction True \n", + " 0 AvoidDirectWind True \n", + " 0 M5DiffBasisFunction True \n", + "\n", + " max_basis_reward basis_area basis_weight \\\n", + "list_index survey_index \n", + "0 0 0.000000 3.357175 0.142857 \n", + " 0 1.000000 3.357175 0.142857 \n", + " 0 -inf 0.000000 0.142857 \n", + " 0 -inf 0.000000 0.142857 \n", + " 0 -52.644817 3.357175 0.142857 \n", + "... ... ... ... \n", + "1 0 1.000000 38483.292220 1.000000 \n", + " 0 1.000000 13334.697435 1.000000 \n", + " 0 1.000000 2141.877383 1.000000 \n", + " 0 -0.000201 24329.444187 1.000000 \n", + " 0 -1.634773 12045.542396 1.000000 \n", + "\n", + " max_accum_reward accum_area tier_label \\\n", + "list_index survey_index \n", + "0 0 0.000000 41252.961249 tier 0 \n", + " 0 0.142857 41252.961249 tier 0 \n", + " 0 -inf 0.000000 tier 0 \n", + " 0 -inf 0.000000 tier 0 \n", + " 0 -inf 0.000000 tier 0 \n", + "... ... ... ... \n", + "1 0 1.000000 38483.292220 tier 1 \n", + " 0 2.000000 10601.957326 tier 1 \n", + " 0 3.000000 2141.877383 tier 1 \n", + " 0 -inf 0.000000 tier 1 \n", + " 0 -inf 0.000000 tier 1 \n", + "\n", + " survey_label survey_class survey_reward \n", + "list_index survey_index \n", + "0 0 field_0_p0_g FieldSurvey -inf \n", + " 0 field_0_p0_g FieldSurvey -inf \n", + " 0 field_0_p0_g FieldSurvey -inf \n", + " 0 field_0_p0_g FieldSurvey -inf \n", + " 0 field_0_p0_g FieldSurvey -inf \n", + "... ... ... ... \n", + "1 0 greedy_g GreedySurvey NaN \n", + " 0 greedy_g GreedySurvey NaN \n", + " 0 greedy_g GreedySurvey NaN \n", + " 0 greedy_g GreedySurvey NaN \n", + " 0 greedy_g GreedySurvey NaN \n", + "\n", + "[174 rows x 12 columns]" + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "scheduler.make_reward_df(conditions, accum=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "id": "76205852-dfba-4061-a1f0-d167255ffe3f", + "metadata": { + "execution": { + "iopub.execute_input": "2023-10-27T19:44:27.194544Z", + "iopub.status.busy": "2023-10-27T19:44:27.194419Z", + "iopub.status.idle": "2023-10-27T19:44:27.648717Z", + "shell.execute_reply": "2023-10-27T19:44:27.648311Z", + "shell.execute_reply.started": "2023-10-27T19:44:27.194532Z" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/sdf/data/rubin/user/neilsen/devel/rubin_sim/rubin_sim/scheduler/schedulers/core_scheduler.py:547: RuntimeWarning: All-NaN axis encountered\n", + " survey_df[\"survey_reward\"] = np.nanmax(survey.calc_reward_function(conditions))\n", + "/sdf/data/rubin/user/neilsen/devel/rubin_sim/rubin_sim/scheduler/schedulers/core_scheduler.py:547: RuntimeWarning: All-NaN axis encountered\n", + " survey_df[\"survey_reward\"] = np.nanmax(survey.calc_reward_function(conditions))\n", + "/sdf/data/rubin/user/neilsen/devel/rubin_sim/rubin_sim/scheduler/schedulers/core_scheduler.py:547: RuntimeWarning: All-NaN axis encountered\n", + " survey_df[\"survey_reward\"] = np.nanmax(survey.calc_reward_function(conditions))\n", + "/sdf/data/rubin/user/neilsen/devel/rubin_sim/rubin_sim/scheduler/schedulers/core_scheduler.py:547: RuntimeWarning: All-NaN axis encountered\n", + " survey_df[\"survey_reward\"] = np.nanmax(survey.calc_reward_function(conditions))\n", + "/sdf/data/rubin/user/neilsen/devel/rubin_sim/rubin_sim/scheduler/schedulers/core_scheduler.py:547: RuntimeWarning: All-NaN slice encountered\n", + " survey_df[\"survey_reward\"] = np.nanmax(survey.calc_reward_function(conditions))\n" + ] + }, + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
tiersurvey_namesurvey_urlreward
0tier 00: field_0_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...ZenithShadowMask, SkybrightnessLimit g, M5Diff...
1tier 010: field_150_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...AvoidDirectWind, HourAngleLimit
2tier 011: field_165_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...AvoidDirectWind
3tier 012: field_180_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...SkybrightnessLimit g, AvoidDirectWind
4tier 013: field_195_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...SkybrightnessLimit g
5tier 014: field_210_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...SkybrightnessLimit g
6tier 015: field_225_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...MoonAvoidance, SkybrightnessLimit g, HourAngle...
7tier 016: field_240_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...MoonAvoidance, SkybrightnessLimit g, HourAngle...
8tier 017: field_255_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...SkybrightnessLimit g, M5Diff g, HourAngleLimit
9tier 018: field_270_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...ZenithShadowMask, SkybrightnessLimit g, M5Diff...
10tier 019: field_285_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...ZenithShadowMask, SkybrightnessLimit g, M5Diff...
11tier 01: field_15_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...ZenithShadowMask, SkybrightnessLimit g, M5Diff...
12tier 020: field_300_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...ZenithShadowMask, SkybrightnessLimit g, M5Diff...
13tier 021: field_315_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...ZenithShadowMask, SkybrightnessLimit g, M5Diff...
14tier 022: field_330_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...ZenithShadowMask, SkybrightnessLimit g, M5Diff...
15tier 023: field_345_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...ZenithShadowMask, SkybrightnessLimit g, M5Diff...
16tier 02: field_30_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...ZenithShadowMask, SkybrightnessLimit g, AvoidD...
17tier 03: field_45_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...ZenithShadowMask, SkybrightnessLimit g, AvoidD...
18tier 04: field_60_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...ZenithShadowMask, SkybrightnessLimit g, AvoidD...
19tier 05: field_75_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...ZenithShadowMask, SkybrightnessLimit g, AvoidD...
20tier 06: field_90_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...ZenithShadowMask, SkybrightnessLimit g, AvoidD...
21tier 07: field_105_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...ZenithShadowMask, SkybrightnessLimit g, AvoidD...
22tier 08: field_120_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...ZenithShadowMask, SkybrightnessLimit g, AvoidD...
23tier 09: field_135_p0_ghttps://rubin-sim.lsst.io/api/FieldSurvey.html...SkybrightnessLimit g, AvoidDirectWind, HourAng...
24tier 10: greedy_ghttps://rubin-sim.lsst.io/api/GreedySurvey.htm...-inf
\n", + "
" + ], + "text/plain": [ + " tier survey_name \\\n", + "0 tier 0 0: field_0_p0_g \n", + "1 tier 0 10: field_150_p0_g \n", + "2 tier 0 11: field_165_p0_g \n", + "3 tier 0 12: field_180_p0_g \n", + "4 tier 0 13: field_195_p0_g \n", + "5 tier 0 14: field_210_p0_g \n", + "6 tier 0 15: field_225_p0_g \n", + "7 tier 0 16: field_240_p0_g \n", + "8 tier 0 17: field_255_p0_g \n", + "9 tier 0 18: field_270_p0_g \n", + "10 tier 0 19: field_285_p0_g \n", + "11 tier 0 1: field_15_p0_g \n", + "12 tier 0 20: field_300_p0_g \n", + "13 tier 0 21: field_315_p0_g \n", + "14 tier 0 22: field_330_p0_g \n", + "15 tier 0 23: field_345_p0_g \n", + "16 tier 0 2: field_30_p0_g \n", + "17 tier 0 3: field_45_p0_g \n", + "18 tier 0 4: field_60_p0_g \n", + "19 tier 0 5: field_75_p0_g \n", + "20 tier 0 6: field_90_p0_g \n", + "21 tier 0 7: field_105_p0_g \n", + "22 tier 0 8: field_120_p0_g \n", + "23 tier 0 9: field_135_p0_g \n", + "24 tier 1 0: greedy_g \n", + "\n", + " survey_url \\\n", + "0 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "1 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "2 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "3 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "4 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "5 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "6 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "7 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "8 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "9 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "10 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "11 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "12 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "13 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "14 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "15 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "16 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "17 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "18 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "19 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "20 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "21 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "22 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "23 https://rubin-sim.lsst.io/api/FieldSurvey.html... \n", + "24 https://rubin-sim.lsst.io/api/GreedySurvey.htm... \n", + "\n", + " reward \n", + "0 ZenithShadowMask, SkybrightnessLimit g, M5Diff... \n", + "1 AvoidDirectWind, HourAngleLimit \n", + "2 AvoidDirectWind \n", + "3 SkybrightnessLimit g, AvoidDirectWind \n", + "4 SkybrightnessLimit g \n", + "5 SkybrightnessLimit g \n", + "6 MoonAvoidance, SkybrightnessLimit g, HourAngle... \n", + "7 MoonAvoidance, SkybrightnessLimit g, HourAngle... \n", + "8 SkybrightnessLimit g, M5Diff g, HourAngleLimit \n", + "9 ZenithShadowMask, SkybrightnessLimit g, M5Diff... \n", + "10 ZenithShadowMask, SkybrightnessLimit g, M5Diff... \n", + "11 ZenithShadowMask, SkybrightnessLimit g, M5Diff... \n", + "12 ZenithShadowMask, SkybrightnessLimit g, M5Diff... \n", + "13 ZenithShadowMask, SkybrightnessLimit g, M5Diff... \n", + "14 ZenithShadowMask, SkybrightnessLimit g, M5Diff... \n", + "15 ZenithShadowMask, SkybrightnessLimit g, M5Diff... \n", + "16 ZenithShadowMask, SkybrightnessLimit g, AvoidD... \n", + "17 ZenithShadowMask, SkybrightnessLimit g, AvoidD... \n", + "18 ZenithShadowMask, SkybrightnessLimit g, AvoidD... \n", + "19 ZenithShadowMask, SkybrightnessLimit g, AvoidD... \n", + "20 ZenithShadowMask, SkybrightnessLimit g, AvoidD... \n", + "21 ZenithShadowMask, SkybrightnessLimit g, AvoidD... \n", + "22 ZenithShadowMask, SkybrightnessLimit g, AvoidD... \n", + "23 SkybrightnessLimit g, AvoidDirectWind, HourAng... \n", + "24 -inf " + ] + }, + "execution_count": 23, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "schedview.compute.make_scheduler_summary_df(scheduler, conditions)" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "id": "8896369f-8935-4839-aeec-1153cda52712", + "metadata": { + "execution": { + "iopub.execute_input": "2023-10-27T19:44:27.649523Z", + "iopub.status.busy": "2023-10-27T19:44:27.649281Z", + "iopub.status.idle": "2023-10-27T19:44:28.955667Z", + "shell.execute_reply": "2023-10-27T19:44:28.955358Z", + "shell.execute_reply.started": "2023-10-27T19:44:27.649510Z" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "PosixPath('/sdf/data/rubin/user/neilsen/devel/schedview/tmp/eq_field_survey_v0_infeasible1.p.xz')" + ] + }, + "execution_count": 24, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "output_tuple = (scheduler, conditions)\n", + "fname = Path('../tmp/eq_field_survey_v0_infeasible1.p.xz').resolve()\n", + "with lzma.open(fname, 'wb') as sched_out:\n", + " pickle.dump(output_tuple, sched_out)\n", + "\n", + "fname" + ] + }, + { + "cell_type": "markdown", + "id": "22e7c644-493d-4e3b-be0f-69eda97b243f", + "metadata": {}, + "source": [ + "# Making pickles available" + ] + }, + { + "cell_type": "markdown", + "id": "46e78665-64db-42ca-a26f-aae401dad7d7", + "metadata": {}, + "source": [ + "Copy them to `/sdf/group/rubin/web_data/sim-data/sched_pickles` at the USDF for them to be visible at https://s3df.slac.stanford.edu/data/rubin/sim-data/sched_pickles" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0993d5ce-3f0a-4827-841d-c90b223ada1b", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "ehn311", + "language": "python", + "name": "ehn311" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.5" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}