Skip to content

Commit 1fbe853

Browse files
committed
add ddf and filter functionality
1 parent 39f6337 commit 1fbe853

1 file changed

Lines changed: 127 additions & 24 deletions

File tree

Commissioning/102_rubin_schedule_viewer.ipynb

Lines changed: 127 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
"\n",
1919
"</div>\n",
2020
"\n",
21-
"For the Rubin Science Platform at data.lsst.cloud. <br>\n",
22-
"Container Size: Large <br>\n",
23-
"LSST Science Pipelines version: v29.2.0 <br>\n",
24-
"Last verified to run: 2025-12-04 <br>\n",
21+
"For the Rubin Science Platform at data.lsst.cloud.\\\n",
22+
"Container Size: Large\\\n",
23+
"LSST Science Pipelines version: v29.2.0\\\n",
24+
"Last verified to run: 2025-01-28\\\n",
2525
"Repository: [github.com/lsst/tutorial-notebooks](https://github.com/lsst/tutorial-notebooks)\\\n",
2626
"DOI: [10.11578/rubin/dc.20250909.20](https://doi.org/10.11578/rubin/dc.20250909.20)"
2727
]
@@ -88,28 +88,32 @@
8888
"The ObsLocTAP data model (table schema) for the scheduled observations is defined in the `ivoa.obsplan` table -- <a href=\"https://www.ivoa.net/documents/ObsLocTAP/20210609/PR-ObsLocTAP-1.0-20210609.pdf\">Observation Locator \n",
8989
"Table Access Protocol Version 1.0</a>\n",
9090
"\n",
91-
"The database contains 28 columns in total, but these are the key columns used in this tutorial.\n",
91+
"The database contains 28 columns in total, but these are the key columns.\n",
9292
"\n",
93-
"* `t_planning` : Time (MJD) when this observation has been added or modified into the planning log.\n",
94-
"* `target_name` : The name of the astronomical object observed, if any.\n",
95-
"* `obs_id` : The observation ID from the Camera.\n",
93+
"* `t_min` : The start time (MJD).\n",
94+
"* `t_max` : The stop time (MJD).\n",
9695
"* `s_ra` : The Right Ascension of the visit or planned observation (degrees).\n",
9796
"* `s_dec` : The Declination of the visit or planned observation (degrees).\n",
98-
"* `s_fov` : The diameter (bounds) of the covered region.\n",
9997
"* `s_region` : Sky region covered by the data product (expressed in ICRS frame).\n",
100-
"* `s_resolution` : The spatial resolution of the data expressed as FWHM.\n",
101-
"* `t_min` : The start time (MJD).\n",
102-
"* `t_max` : The stop time (MJD).\n",
103-
"* `t_exptime` : The total exposure time = `t_max - t_min`.\n",
104-
"* `t_resolution` : Temporal resolution.\n",
105-
"* `facility_name` : Name of the facility used for this observation e.g Rubin Simonyi, AuxTel.\n",
106-
"* `instrument_name` : Name of the instrument used for this observation e.g LSSTCam, LSSTComCam.\n",
107-
"* `t_plan_exptime` : The planned or scheduled exposure time.\n",
98+
"* `em_min` : The filter minimum wavelength (m).\n",
99+
"* `em_max` : The filter maximum wavelength (m).\n",
100+
"* `target_name` : The name of the astronomical object observed, if any.\n",
101+
"* `tracking_type` : One of the following values: Sidereal, Solar-system-object-tracking, Fixed-az-el-transit.\n",
108102
"* `priority` : The Priority level { 0, 1, 2}. 0 = in the target queue as the next visit\n",
109103
"(meaning its execution is highly likely), 1 = in the 1 hour look-ahead summit queue (meaning likely),\n",
110104
"2 = 24 hour pre-night simulation, meaning it is not in the summit queue and has a high degree of uncertainty. \n",
111105
"* `execution_status` : Execution status of the prediction: One of the following values: Planned, Scheduled, Unscheduled, Performed, Aborted.\n",
112-
"* `tracking_type` : One of the following values: Sidereal, Solar-system-object-tracking, Fixed-az-el-transit.\n",
106+
"* `obs_id` : The observation ID from the Camera.\n",
107+
"* `t_planning` : Time (MJD) when this observation has been added or modified into the planning log.\n",
108+
"\n",
109+
"These are also columns of interest, but which are the same for most observations taken with LSSTCam.\n",
110+
"\n",
111+
"* `t_plan_exptime` : The planned or scheduled exposure time.\n",
112+
"* `t_exptime` : The total exposure time = `t_max - t_min`.\n",
113+
"* `s_fov` : The diameter (bounds) of the covered region.\n",
114+
"* `s_resolution` : The spatial resolution of the data expressed as FWHM.\n",
115+
"* `facility_name` : Name of the facility used for this observation e.g Rubin Simonyi, AuxTel.\n",
116+
"* `instrument_name` : Name of the instrument used for this observation e.g LSSTCam, LSSTComCam.\n",
113117
"\n",
114118
"See <a href=\"https://dmtn-263.lsst.io/\">DMTN-263</a> for a description of all fields in the schema."
115119
]
@@ -155,6 +159,53 @@
155159
"warnings.filterwarnings(\"ignore\")"
156160
]
157161
},
162+
{
163+
"cell_type": "markdown",
164+
"id": "cd2a8cab-f364-420d-80ec-3c9f99e47cf7",
165+
"metadata": {},
166+
"source": [
167+
"### 1.4. Define functions\n",
168+
"\n",
169+
"Define a function to convert the `em_min` and `em_max` columns into the bandpass (filter) name."
170+
]
171+
},
172+
{
173+
"cell_type": "code",
174+
"execution_count": null,
175+
"id": "27684781-bdf6-4fb4-a57b-e8b510253375",
176+
"metadata": {},
177+
"outputs": [],
178+
"source": [
179+
"def em_min_max_to_band(em_min, em_max):\n",
180+
" \"\"\"\n",
181+
" Convert the wavelength minimum and maximum to band name.\n",
182+
"\n",
183+
" Parameters\n",
184+
" ----------\n",
185+
" em_min: float\n",
186+
" Wavelength minimum, in m.\n",
187+
" em_max: float\n",
188+
" Wavelength maximum, in m.\n",
189+
"\n",
190+
" Returns\n",
191+
" -------\n",
192+
" band: string\n",
193+
" Band (filter) name.\n",
194+
" \"\"\"\n",
195+
"\n",
196+
" band = None\n",
197+
" band_dict = {'u': (2.95e-7, 4.00e-7), 'g': (4.00e-7, 5.55e-7),\n",
198+
" 'r': (5.50e-7, 6.92e-7), 'i': (6.90e-7, 8.20e-7),\n",
199+
" 'z': (8.15e-7, 9.25e-7), 'y': (9.20e-7, 11.1e-7)}\n",
200+
" for b in band_dict.keys():\n",
201+
" if em_min > band_dict[b][0] and em_max < band_dict[b][1]:\n",
202+
" band = b\n",
203+
" if band is None:\n",
204+
" print(em_min, em_max, ' no band found')\n",
205+
"\n",
206+
" return band"
207+
]
208+
},
158209
{
159210
"cell_type": "markdown",
160211
"id": "d7cbe189-5a7c-4373-8fcb-076d661b0a6f",
@@ -196,7 +247,9 @@
196247
"id": "9",
197248
"metadata": {},
198249
"source": [
199-
"Programmatically check the health of the static UI by executing the following cell, and assert that the static user interface service must be alive."
250+
"Programmatically check the health of the static UI by executing the following cell, and assert that the static user interface service must be alive.\n",
251+
"\n",
252+
"> **Warning:** If `RemoteDisconnect` errors are returned, it means the service is temporarily unstable or unavailable, and to try again later."
200253
]
201254
},
202255
{
@@ -206,7 +259,7 @@
206259
"metadata": {},
207260
"outputs": [],
208261
"source": [
209-
"rubin_static_schedule_url = obsloctap_url + \"/static/viewer.html\"\n",
262+
"rubin_static_schedule_url = obsloctap_url + \"/static/viewer.html\"\n",
210263
"response = requests.get(rubin_static_schedule_url)\n",
211264
"assert response.status_code == 200, f\"request failed with status {response.status_code}\"\n",
212265
"print(f\"Rubin Schedule Viewer at {response.url} is alive.\")"
@@ -376,7 +429,57 @@
376429
"id": "26",
377430
"metadata": {},
378431
"source": [
379-
"Note that the values in the \"Execution Status\" field are all \"Scheduled\"."
432+
"Note that the values in the \"Execution Status\" field are all \"Scheduled\".\n",
433+
"\n",
434+
"#### 3.1.1. Planned DDF observations\n",
435+
"\n",
436+
"When alerts begin streaming in early 2026, template images will only exist for the DDFs, and thus alerts will only stream in the DDFs.\n",
437+
"\n",
438+
"Print the number of planned observations per DDF in the next 24h, and in which filters the observations are planned.\n",
439+
"\n",
440+
"First, add a column for the band (filter), converted from the `em_min` and `em_max` columns."
441+
]
442+
},
443+
{
444+
"cell_type": "code",
445+
"execution_count": null,
446+
"id": "6769ff38-6b03-4649-9f39-01c475a9e478",
447+
"metadata": {},
448+
"outputs": [],
449+
"source": [
450+
"em_min = forward_24h_schedule['em_min'].values\n",
451+
"em_max = forward_24h_schedule['em_max'].values\n",
452+
"temp = []\n",
453+
"for i in range(len(forward_24h_schedule)):\n",
454+
" temp.append(em_min_max_to_band(em_min[i], em_max[i]))\n",
455+
"forward_24h_schedule['band'] = temp\n",
456+
"del temp"
457+
]
458+
},
459+
{
460+
"cell_type": "markdown",
461+
"id": "4148b3ff-9173-484a-991b-495ee6d25b95",
462+
"metadata": {},
463+
"source": [
464+
"Define the names of the DDF fields, in the format of the `target_name` column.\n",
465+
"For each field, sum the number of planned observations and print the unique filters for those observations."
466+
]
467+
},
468+
{
469+
"cell_type": "code",
470+
"execution_count": null,
471+
"id": "fec6e949-a299-4eae-b4b4-f15da82c9e16",
472+
"metadata": {},
473+
"outputs": [],
474+
"source": [
475+
"ddf_names = ['ddf_cosmos', 'ddf_ecdfs', 'ddf_elaiss1',\n",
476+
" 'ddf_edfs_a', 'ddf_edfs_b', 'ddf_xmm_lss']\n",
477+
"\n",
478+
"for ddf_name in ddf_names:\n",
479+
" temp = forward_24h_schedule.query(\"target_name.str.contains(@ddf_name)\")\n",
480+
" band_list = \"\".join(str(value) for value in np.unique(temp['band']))\n",
481+
" print('%-12s %3i bands: %-15s' % (ddf_name, len(temp), band_list))\n",
482+
" del temp, band_list"
380483
]
381484
},
382485
{
@@ -650,9 +753,9 @@
650753
"metadata": {},
651754
"outputs": [],
652755
"source": [
653-
"print(f\"Min gap: {np.min(obs_visit_gap):.2f}\")\n",
654-
"print(f\"Max gap: {np.max(obs_visit_gap):.2f}\")\n",
655-
"print(f\"Mean gap: {np.mean(obs_visit_gap):.2f}\")"
756+
"print(f\"Min gap: {np.min(obs_visit_gap): .2f}\")\n",
757+
"print(f\"Max gap: {np.max(obs_visit_gap): .2f}\")\n",
758+
"print(f\"Mean gap: {np.mean(obs_visit_gap): .2f}\")"
656759
]
657760
},
658761
{

0 commit comments

Comments
 (0)