Skip to content

Commit 2c3b25e

Browse files
updating image stamps nb
1 parent fee8e68 commit 2c3b25e

1 file changed

Lines changed: 22 additions & 45 deletions

File tree

DP1/100_How_to_Use_RSP_Tools/103_Image_access_and_display/103_5_Image_stamps.ipynb

Lines changed: 22 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@
3131
"id": "ae760c59-bf94-45b3-9f8e-b4551b22e193",
3232
"metadata": {},
3333
"source": [
34-
"**Learning objective:** An overview of candidate transient (Ia Supernovae) identification in DP1.\n",
34+
"**Learning objective:** Generate many image cutouts using the Rubin image cutout service.\n",
3535
"\n",
3636
"**LSST data products:** `DiaObject`, `Visit`, `visit_image`, `template_coadd`, `difference_image`\n",
3737
"\n",
3838
"**Packages:** `matplotlib`, `numpy`, `lsst.rsp`,`lsst.afw`, `lsst.geom`, `lsst.resources`, `lsst.utils.plotting`, `pyvo.dal.adhoc`, `reproject`\n",
3939
"\n",
4040
"**Credit:**\n",
41-
"Originally developed by the Rubin Community Science team with feedback from Eric Bellm. This notebook also utilizes a transient detection from LSSTComCam first identified by Dan Taranu.\n",
41+
"Originally developed by the Rubin Community Science team with feedback from Gregory Dubois-Feldman. This notebook also utilizes a transient detection from LSSTComCam first identified by Dan Taranu.\n",
4242
"Please consider acknowledging them if this notebook is used for the preparation of journal articles, software releases, or other notebooks.\n",
4343
"\n",
4444
"**Get Support:**\n",
@@ -95,25 +95,20 @@
9595
"source": [
9696
"import matplotlib.pyplot as plt\n",
9797
"import math\n",
98-
"\n",
9998
"import numpy as np\n",
100-
"from astropy import units as u\n",
10199
"\n",
102100
"from lsst.rsp import get_tap_service\n",
103101
"from lsst.rsp.service import get_siav2_service\n",
104102
"from lsst.rsp.utils import get_pyvo_auth\n",
105103
"\n",
106-
"from lsst.utils.plotting import (get_multiband_plot_colors,\n",
107-
" get_multiband_plot_symbols)\n",
108104
"\n",
109105
"import lsst.afw.display as afwDisplay\n",
110106
"from lsst.afw.image import ImageF\n",
111107
"from lsst.afw.fits import MemFileManager\n",
112-
"import lsst.geom as geom\n",
113-
"import lsst.resources\n",
114108
"\n",
115109
"from pyvo.dal.adhoc import DatalinkResults, SodaQuery\n",
116110
"\n",
111+
"from astropy import units as u\n",
117112
"from astropy.wcs import WCS\n",
118113
"from astropy.io import fits\n",
119114
"import io\n",
@@ -173,26 +168,6 @@
173168
"assert sia_service is not None"
174169
]
175170
},
176-
{
177-
"cell_type": "markdown",
178-
"id": "9b02d9d2-23ce-48c4-8265-460604817467",
179-
"metadata": {},
180-
"source": [
181-
"Define filter names, plot markers, linestyles, and colors for plotting"
182-
]
183-
},
184-
{
185-
"cell_type": "code",
186-
"execution_count": null,
187-
"id": "c5f87c79-8798-4306-bb82-495edb1463b2",
188-
"metadata": {},
189-
"outputs": [],
190-
"source": [
191-
"filter_names = ['u', 'g', 'r', 'i', 'z', 'y']\n",
192-
"filter_colors = get_multiband_plot_colors()\n",
193-
"filter_symbols = get_multiband_plot_symbols()"
194-
]
195-
},
196171
{
197172
"cell_type": "markdown",
198173
"id": "cc51bd61-5bea-47d8-b67b-30ff46f6e180",
@@ -334,16 +309,12 @@
334309
"metadata": {},
335310
"outputs": [],
336311
"source": [
337-
"def get_cutout(dl_result, spherePoint, session, fov):\n",
312+
"def get_cutout(dl_result, ra, dec, session, fov):\n",
338313
" sq = SodaQuery.from_resource(dl_result,\n",
339314
" dl_result.get_adhocservice_by_id(\"cutout-sync\"),\n",
340315
" session=session)\n",
341-
" sphereRadius = fov * u.deg\n",
342-
" sq.circle = (spherePoint.getRa().asDegrees() * u.deg,\n",
343-
" spherePoint.getDec().asDegrees() * u.deg,\n",
344-
" sphereRadius)\n",
345-
" # can remove spherepoint stuff using:\n",
346-
" #sq.circle = (cutout_ra, cutout_dec, Radius)\n",
316+
"\n",
317+
" sq.circle = (ra * u.deg, dec * u.deg, fov * u.deg)\n",
347318
"\n",
348319
" cutout_bytes = sq.execute_stream().read()\n",
349320
" sq.raise_if_error()\n",
@@ -353,6 +324,15 @@
353324
" return ImageF(mem), hdul"
354325
]
355326
},
327+
{
328+
"cell_type": "markdown",
329+
"id": "3d998864-d33a-449d-a28a-42e94607f901",
330+
"metadata": {},
331+
"source": [
332+
"#### 1.2.4. subplots\n",
333+
"Define a function to organize the display with matplotlib of many cutouts."
334+
]
335+
},
356336
{
357337
"cell_type": "code",
358338
"execution_count": null,
@@ -403,10 +383,8 @@
403383
"metadata": {},
404384
"outputs": [],
405385
"source": [
406-
"#SNcandID = 611255759837069401\n",
407386
"ra = 53.124767650110215\n",
408-
"dec = -27.739814591611168\n",
409-
"spherePoint = lsst.geom.SpherePoint(ra*geom.degrees, dec*geom.degrees)"
387+
"dec = -27.739814591611168"
410388
]
411389
},
412390
{
@@ -484,8 +462,7 @@
484462
"tx = np.where((lvl2_table['dataproduct_subtype'] == 'lsst.visit_image')\n",
485463
" & (lvl2_table['lsst_band'] == 'r'))[0]\n",
486464
"scitab = lvl2_table[tx]\n",
487-
"scitab.sort('t_max')\n",
488-
"print(scitab['t_max'])"
465+
"scitab.sort('t_max')"
489466
]
490467
},
491468
{
@@ -579,9 +556,9 @@
579556
"outputs": [],
580557
"source": [
581558
"fov = 0.002\n",
582-
"sci, scihdul = get_cutout(dl_result_sci, spherePoint, get_pyvo_auth(), fov)\n",
583-
"ref, refhdul = get_cutout(dl_result_ref, spherePoint, get_pyvo_auth(), fov)\n",
584-
"diff, diffhdul = get_cutout(dl_result_diff, spherePoint, get_pyvo_auth(), fov)"
559+
"sci, scihdul = get_cutout(dl_result_sci, ra, dec, get_pyvo_auth(), fov)\n",
560+
"ref, refhdul = get_cutout(dl_result_ref, ra, dec, get_pyvo_auth(), fov)\n",
561+
"diff, diffhdul = get_cutout(dl_result_diff, ra, dec, get_pyvo_auth(), fov)"
585562
]
586563
},
587564
{
@@ -752,7 +729,7 @@
752729
" dl_result_sci = DatalinkResults.from_result_url(scitab['access_url'][j],\n",
753730
" session=get_pyvo_auth())\n",
754731
"\n",
755-
" sci, scihdul = get_cutout(dl_result_sci, spherePoint, get_pyvo_auth(), fov)\n",
732+
" sci, scihdul = get_cutout(dl_result_sci, ra, dec, get_pyvo_auth(), fov)\n",
756733
" sci_hdu = scihdul[1]\n",
757734
" sci_header = scihdul[1].header\n",
758735
" scidata = scihdul[1].data\n",
@@ -804,7 +781,7 @@
804781
" dl_result_sci = DatalinkResults.from_result_url(scitab['access_url'][j],\n",
805782
" session=get_pyvo_auth())\n",
806783
"\n",
807-
" sci, scihdul = get_cutout(dl_result_sci, spherePoint, get_pyvo_auth(), fov)\n",
784+
" sci, scihdul = get_cutout(dl_result_sci, ra, dec, get_pyvo_auth(), fov)\n",
808785
" sci_hdu = scihdul[1]\n",
809786
" sci_header = scihdul[1].header\n",
810787
" scidata = scihdul[1].data\n",

0 commit comments

Comments
 (0)