From 8de48bc99aba299e2e329360b646a00d88d4faf7 Mon Sep 17 00:00:00 2001 From: christinawilliams Date: Wed, 10 Dec 2025 23:38:59 +0000 Subject: [PATCH 01/16] updating DP02 13a for new cutout syntax --- DP0.2/13a_Image_Cutout_SciDemo.ipynb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DP0.2/13a_Image_Cutout_SciDemo.ipynb b/DP0.2/13a_Image_Cutout_SciDemo.ipynb index 22fd2f9f..80b6553d 100644 --- a/DP0.2/13a_Image_Cutout_SciDemo.ipynb +++ b/DP0.2/13a_Image_Cutout_SciDemo.ipynb @@ -445,7 +445,7 @@ " # from_resource: creates a instance from\n", " # a number of records and a Datalink Resource.\n", " sq = SodaQuery.from_resource(dl,\n", - " dl.get_adhocservice_by_id(\"cutout-sync\"),\n", + " dl.get_adhocservice_by_id(\"cutout-sync-exposure\"),\n", " session=auth_session)\n", "\n", " sq.circle = (spherePoint.getRa().asDegrees() * u.deg,\n", @@ -753,7 +753,7 @@ "outputs": [], "source": [ "sq = SodaQuery.from_resource(dl_results,\n", - " dl_results.get_adhocservice_by_id(\"cutout-sync\"),\n", + " dl_results.get_adhocservice_by_id(\"cutout-sync-exposure\"),\n", " session=auth_session)" ] }, @@ -916,7 +916,7 @@ "outputs": [], "source": [ "sq2 = SodaQuery.from_resource(dl_results,\n", - " dl_results.get_adhocservice_by_id(\"cutout-sync\"),\n", + " dl_results.get_adhocservice_by_id(\"cutout-sync-exposure\"),\n", " session=auth_session)\n", "sphereRadius1 = 0.03 * u.deg\n", "sphereRadius2 = 0.01 * u.deg\n", From 5085dace94de0316ca26678ecbf0e244b16de7ad Mon Sep 17 00:00:00 2001 From: christinawilliams Date: Wed, 10 Dec 2025 23:41:34 +0000 Subject: [PATCH 02/16] updating DP02 13a for new cutout syntax --- DP0.2/13a_Image_Cutout_SciDemo.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DP0.2/13a_Image_Cutout_SciDemo.ipynb b/DP0.2/13a_Image_Cutout_SciDemo.ipynb index 80b6553d..4a4e92d4 100644 --- a/DP0.2/13a_Image_Cutout_SciDemo.ipynb +++ b/DP0.2/13a_Image_Cutout_SciDemo.ipynb @@ -10,7 +10,7 @@ "\"Rubin\n", "
\n", "Contact author: Christina Williams
\n", - "Last verified to run: 2025-09-02
\n", + "Last verified to run: 2025-12-10
\n", "LSST Science Pipelines version: r29.2.0
\n", "Container Size: medium
\n", "Targeted learning level: beginner
" From 25d6b5b049e6ba6033f2fc19c0cb82ac0bf5ea60 Mon Sep 17 00:00:00 2001 From: christinawilliams Date: Wed, 10 Dec 2025 23:41:53 +0000 Subject: [PATCH 03/16] updating DP02 18 for new cutout syntax --- DP0.2/18_Galaxy_Photometry.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DP0.2/18_Galaxy_Photometry.ipynb b/DP0.2/18_Galaxy_Photometry.ipynb index 8eda55f8..80454ee7 100644 --- a/DP0.2/18_Galaxy_Photometry.ipynb +++ b/DP0.2/18_Galaxy_Photometry.ipynb @@ -327,7 +327,7 @@ " session=auth_session)\n", "\n", " sq = SodaQuery.from_resource(dl,\n", - " dl.get_adhocservice_by_id(\"cutout-sync\"),\n", + " dl.get_adhocservice_by_id(\"cutout-sync-exposure\"),\n", " session=auth_session)\n", "\n", " sq.circle = (spherePoint.getRa().asDegrees() * u.deg,\n", From 4efde8e3a7fd28090f19789e2198c4830794b5dd Mon Sep 17 00:00:00 2001 From: christinawilliams Date: Wed, 10 Dec 2025 23:48:00 +0000 Subject: [PATCH 04/16] updating DP1 103_4 notebook --- .../103_Image_access_and_display/103_4_Small_Image_Cutout.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DP1/100_How_to_Use_RSP_Tools/103_Image_access_and_display/103_4_Small_Image_Cutout.ipynb b/DP1/100_How_to_Use_RSP_Tools/103_Image_access_and_display/103_4_Small_Image_Cutout.ipynb index 486fd371..82845c8d 100644 --- a/DP1/100_How_to_Use_RSP_Tools/103_Image_access_and_display/103_4_Small_Image_Cutout.ipynb +++ b/DP1/100_How_to_Use_RSP_Tools/103_Image_access_and_display/103_4_Small_Image_Cutout.ipynb @@ -335,7 +335,7 @@ "outputs": [], "source": [ "sq = SodaQuery.from_resource(dl_result,\n", - " dl_result.get_adhocservice_by_id(\"cutout-sync\"),\n", + " dl_result.get_adhocservice_by_id(\"cutout-sync-exposure\"),\n", " session=get_pyvo_auth())" ] }, From 4129eff90de4eb1b57ea50e1f04a364797b46e0e Mon Sep 17 00:00:00 2001 From: christinawilliams Date: Thu, 11 Dec 2025 17:28:57 +0000 Subject: [PATCH 05/16] updating 303_2 galaxy shapes nb for cutout --- DP1/300_Science_Demos/303_Galaxies/303_2_Galaxy_Shapes.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DP1/300_Science_Demos/303_Galaxies/303_2_Galaxy_Shapes.ipynb b/DP1/300_Science_Demos/303_Galaxies/303_2_Galaxy_Shapes.ipynb index 8579c2bc..858a4ca2 100644 --- a/DP1/300_Science_Demos/303_Galaxies/303_2_Galaxy_Shapes.ipynb +++ b/DP1/300_Science_Demos/303_Galaxies/303_2_Galaxy_Shapes.ipynb @@ -22,7 +22,7 @@ "Data Release: Data Preview 1
\n", "Container Size: Large
\n", "LSST Science Pipelines version: r29.2.0
\n", - "Last verified to run: 2025-09-02
\n", + "Last verified to run: 2025-12-11
\n", "Repository: github.com/lsst/tutorial-notebooks
" ] }, @@ -170,7 +170,7 @@ " dl = DatalinkResults.from_result_url(datalink_url, session=get_pyvo_auth())\n", "\n", " sq = SodaQuery.from_resource(dl,\n", - " dl.get_adhocservice_by_id(\"cutout-sync\"),\n", + " dl.get_adhocservice_by_id(\"cutout-sync-exposure\"),\n", " session=get_pyvo_auth())\n", "\n", " sq.circle = (spherePoint.getRa().asDegrees() * u.deg,\n", From 4708b80568e65898f38a19a6be64b82ac4991cac Mon Sep 17 00:00:00 2001 From: christinawilliams Date: Thu, 11 Dec 2025 17:33:24 +0000 Subject: [PATCH 06/16] updating 306_2 exgal transients nb --- .../306_2_Candidate_transient_identification.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DP1/300_Science_Demos/306_Extragalactic_transients/306_2_Candidate_transient_identification.ipynb b/DP1/300_Science_Demos/306_Extragalactic_transients/306_2_Candidate_transient_identification.ipynb index 86dedb41..df3c2d82 100644 --- a/DP1/300_Science_Demos/306_Extragalactic_transients/306_2_Candidate_transient_identification.ipynb +++ b/DP1/300_Science_Demos/306_Extragalactic_transients/306_2_Candidate_transient_identification.ipynb @@ -22,7 +22,7 @@ "Data Release: Data Preview 1
\n", "Container Size: large
\n", "LSST Science Pipelines version: r29.2.0
\n", - "Last verified to run: 2025-09-17
\n", + "Last verified to run: 2025-12-11
\n", "Repository: github.com/lsst/tutorial-notebooks
" ] }, @@ -587,7 +587,7 @@ "source": [ "def get_cutout(dl_result, spherePoint, session, fov):\n", " sq = SodaQuery.from_resource(dl_result,\n", - " dl_result.get_adhocservice_by_id(\"cutout-sync\"),\n", + " dl_result.get_adhocservice_by_id(\"cutout-sync-exposure\"),\n", " session=session)\n", " sphereRadius = fov * u.deg\n", " sq.circle = (spherePoint.getRa().asDegrees() * u.deg,\n", From dc70505c4bf90ecd33c6f916051da90f63899e68 Mon Sep 17 00:00:00 2001 From: christinawilliams Date: Sun, 14 Dec 2025 18:03:11 +0000 Subject: [PATCH 07/16] adding new cutout sync section 4 to image cutout nb --- .../103_4_Small_Image_Cutout.ipynb | 127 +++++++++++++++++- 1 file changed, 120 insertions(+), 7 deletions(-) diff --git a/DP1/100_How_to_Use_RSP_Tools/103_Image_access_and_display/103_4_Small_Image_Cutout.ipynb b/DP1/100_How_to_Use_RSP_Tools/103_Image_access_and_display/103_4_Small_Image_Cutout.ipynb index 82845c8d..e0620013 100644 --- a/DP1/100_How_to_Use_RSP_Tools/103_Image_access_and_display/103_4_Small_Image_Cutout.ipynb +++ b/DP1/100_How_to_Use_RSP_Tools/103_Image_access_and_display/103_4_Small_Image_Cutout.ipynb @@ -324,7 +324,9 @@ "id": "d945e191-7ee4-458a-bb0f-fb00cd219e30", "metadata": {}, "source": [ - "Lastly, call the Rubin Image Cutout Service. This is the IVOA procedure `cutout-sync` that is called using `get_adhocservice_by_id`. It is done by feeding the data link created above (called `dl_result`) to `from_resource`. Since the Rubin DP1 imaging is proprietary it is necessary to again provide the authorization for the current RSP session. Do this using the `get_pyvo_auth` function." + "Lastly, call the Rubin Image Cutout Service. Three types of cutout services exist: `cutout-sync` which, by default, returns just the image extension of the LSST imaging; `cutout-sync-exposure`, which returns the full set of metadata and image extensions that are contained in the `ExposureF` data type; and `cutout-sync-mask` which contains just the mask extension. This section will demonstrate the use of `cutout-sync-exposure` and Section 4 below will demonstrate the other two. \n", + "\n", + "To use the cutout service in this example, the IVOA procedure `cutout-sync-exposure` is called using `get_adhocservice_by_id`. It is done by feeding the data link created above (called `dl_result`) to `from_resource`. Since the Rubin DP1 imaging is proprietary it is necessary to again provide the authorization for the current RSP session. Do this using the `get_pyvo_auth` function." ] }, { @@ -386,7 +388,7 @@ "sq.raise_if_error()\n", "mem = MemFileManager(len(cutout_bytes))\n", "mem.setData(cutout_bytes, len(cutout_bytes))\n", - "exposure = ExposureF(mem)" + "exposure = ExposureF(mem)\n" ] }, { @@ -394,7 +396,7 @@ "id": "324be87a-337b-4db7-b57d-842f14614613", "metadata": {}, "source": [ - "Display the cutout." + "Display the image extension of the `ExposureF` cutout." ] }, { @@ -502,7 +504,7 @@ "outputs": [], "source": [ "sqp = SodaQuery.from_resource(dl_result,\n", - " dl_result.get_adhocservice_by_id(\"cutout-sync\"),\n", + " dl_result.get_adhocservice_by_id(\"cutout-sync-exposure\"),\n", " session=get_pyvo_auth())\n", "\n", "ra_edge = 0.02 * u.deg\n", @@ -565,7 +567,7 @@ "outputs": [], "source": [ "sq2 = SodaQuery.from_resource(dl_result,\n", - " dl_result.get_adhocservice_by_id(\"cutout-sync\"),\n", + " dl_result.get_adhocservice_by_id(\"cutout-sync-exposure\"),\n", " session=get_pyvo_auth())\n", "\n", "edge1 = Radius\n", @@ -604,7 +606,7 @@ "cosd = np.cos(a.radian)\n", "\n", "sq3 = SodaQuery.from_resource(dl_result,\n", - " dl_result.get_adhocservice_by_id(\"cutout-sync\"),\n", + " dl_result.get_adhocservice_by_id(\"cutout-sync-exposure\"),\n", " session=get_pyvo_auth())\n", "\n", "sq3.polygon = (spherePoint.getRa().asDegrees() * u.deg - edge1/cosd,\n", @@ -674,6 +676,117 @@ "The zooniverse package should be used instead of this procedure for citizen science applications. " ] }, + { + "cell_type": "markdown", + "id": "99e75a7a-348e-409e-88f6-871b68a4e9dc", + "metadata": {}, + "source": [ + "## 4. Other cutout service data types\n", + "\n", + "As mentioned in Section 3, there are three types of cutout services: cutout-sync-exposure to return an `ExposureF` type image with all LSST image extensions (demonstrated above); cutout-sync which returns just the image extension, and and cutout-sync-mask which contains just the mask extension. The latter 2 will be demonstrated below.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c2c8ab4c-cd1d-4ae8-937d-b34a21035e1e", + "metadata": {}, + "outputs": [], + "source": [ + "from astropy.io import fits\n", + "import io\n", + "\n", + "print(results[0])\n", + "datalink_url = results[0].access_url\n", + "dl_result = DatalinkResults.from_result_url(datalink_url,\n", + " session=get_pyvo_auth())\n", + "\n", + "f\"Datalink status: {dl_result.status}. Datalink service url: {datalink_url}\"\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "837fbd2a-c3e2-4ee3-a06d-69f4df50823b", + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "sq5 = SodaQuery.from_resource(dl_result,\n", + " dl_result.get_adhocservice_by_id(\"cutout-sync\"),\n", + " session=get_pyvo_auth())\n", + "\n", + "spherePoint = geom.SpherePoint(target_ra*geom.degrees, target_dec*geom.degrees)\n", + "Radius = 0.01 * u.deg\n", + "sq5.circle = (spherePoint.getRa().asDegrees() * u.deg,\n", + " spherePoint.getDec().asDegrees() * u.deg,\n", + " Radius)\n", + "\n", + "cutout_bytes = sq5.execute_stream().read()\n", + "sq5.raise_if_error()\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "516dbd86-d573-4d81-a017-2ebbce8fb445", + "metadata": {}, + "outputs": [], + "source": [ + "mem = MemFileManager(len(cutout_bytes))\n", + "mem.setData(cutout_bytes, len(cutout_bytes))\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ed3f7908-a256-42f5-939f-61f38645c7ca", + "metadata": {}, + "outputs": [], + "source": [ + "data = mem.getData() # returns `bytes`\n", + "\n", + "# this doesn't work\n", + "import lsst.afw.image as afwImage\n", + "\n", + "#image = afwImage.ImageF(mem)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d23a0397-6500-4e36-b956-7917ed6a7173", + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "#data = mem.getData()\n", + "hdul = fits.open(io.BytesIO(data))\n", + "hdul.info()\n", + "\n", + "image_hdu = hdul[1] # IMAGE extension\n", + "image_data = image_hdu.data # NumPy array\n", + "#image = afwImage.ImageF(image_data)\n", + "image = afwImage.ImageF(image_data.astype(\"float32\"))\n", + "print(type(image_data)) # numpy.ndarray\n", + "print(type(image)) # lsst.afw.image._image.ImageF\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1aa9009a-b493-41ea-bc3c-e0c79adef913", + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "display = afwDisplay.Display()\n", + "display.scale('asinh', 'zscale')\n", + "display.image(image)\n", + "plt.show()" + ] + }, { "attachments": { "923e951d-30c0-4a8f-a1b0-8bb851f1cb5f.png": { @@ -684,7 +797,7 @@ "id": "acbe9638-e7b7-4229-8301-3f57eb0b0c5b", "metadata": {}, "source": [ - "## 4. Exercise for the learner\n", + "## 5. Exercise for the learner\n", "\n", "Reproduce the cutout below, whose center is (ra, dec) = 59.1, -48.8 with 0.06 degrees on a side.\n", "\n", From 406fe55d1cac7165c1cc969aa0bdbf9c782aad42 Mon Sep 17 00:00:00 2001 From: christinawilliams Date: Sun, 14 Dec 2025 19:07:48 +0000 Subject: [PATCH 08/16] adding new cutout sync section 4 to image cutout nb --- .../103_4_Small_Image_Cutout.ipynb | 99 ++++++++++++++++++- 1 file changed, 98 insertions(+), 1 deletion(-) diff --git a/DP1/100_How_to_Use_RSP_Tools/103_Image_access_and_display/103_4_Small_Image_Cutout.ipynb b/DP1/100_How_to_Use_RSP_Tools/103_Image_access_and_display/103_4_Small_Image_Cutout.ipynb index e0620013..eee2b97e 100644 --- a/DP1/100_How_to_Use_RSP_Tools/103_Image_access_and_display/103_4_Small_Image_Cutout.ipynb +++ b/DP1/100_How_to_Use_RSP_Tools/103_Image_access_and_display/103_4_Small_Image_Cutout.ipynb @@ -683,7 +683,11 @@ "source": [ "## 4. Other cutout service data types\n", "\n", - "As mentioned in Section 3, there are three types of cutout services: cutout-sync-exposure to return an `ExposureF` type image with all LSST image extensions (demonstrated above); cutout-sync which returns just the image extension, and and cutout-sync-mask which contains just the mask extension. The latter 2 will be demonstrated below.\n" + "As mentioned in Section 3, there are three types of cutout services: `cutout-sync-exposure` to return an `ExposureF` type image with all LSST image extensions (demonstrated above); `cutout-sync` which returns just the image extension, and and `cutout-sync-mask` which contains just the mask extension. The latter 2 will be demonstrated below.\n", + "\n", + "### 4.1 Single extension image cutouts\n", + "\n", + "Below demonstrates how to retrieve single extension images using `cutout-sync`." ] }, { @@ -787,6 +791,99 @@ "plt.show()" ] }, + { + "cell_type": "markdown", + "id": "918e8779-2939-4978-9ec4-c8a4047f04e9", + "metadata": {}, + "source": [ + "### 4.2 Single extension mask cutouts\n", + "\n", + "Below demonstrates how to retrieve the corresponding mask using `cutout-sync-mask`." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a1213ce5-9049-43ce-8032-f1ea2db9c576", + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "sq5 = SodaQuery.from_resource(dl_result,\n", + " dl_result.get_adhocservice_by_id(\"cutout-sync-maskedimage\"),\n", + " session=get_pyvo_auth())\n", + "\n", + "spherePoint = geom.SpherePoint(target_ra*geom.degrees, target_dec*geom.degrees)\n", + "Radius = 0.01 * u.deg\n", + "sq5.circle = (spherePoint.getRa().asDegrees() * u.deg,\n", + " spherePoint.getDec().asDegrees() * u.deg,\n", + " Radius)\n", + "\n", + "cutout_bytes = sq5.execute_stream().read()\n", + "sq5.raise_if_error()\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a2f5ed28-c17d-451b-969c-b7d9186eeb23", + "metadata": {}, + "outputs": [], + "source": [ + "mem = MemFileManager(len(cutout_bytes))\n", + "mem.setData(cutout_bytes, len(cutout_bytes))\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "770c6bc2-67f5-4d3f-9d3a-98cd27e28b35", + "metadata": {}, + "outputs": [], + "source": [ + "data = mem.getData() # returns `bytes`\n", + "\n", + "# this doesn't work\n", + "import lsst.afw.image as afwImage\n", + "\n", + "#image = afwImage.ImageF(mem)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ba884db3-cd3e-45b9-bba0-ecd98cd95358", + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "#data = mem.getData()\n", + "hdul = fits.open(io.BytesIO(data))\n", + "hdul.info()\n", + "\n", + "image_hdu = hdul[2] # IMAGE extension\n", + "image_data = image_hdu.data # NumPy array\n", + "#image = afwImage.ImageF(image_data)\n", + "image = afwImage.ImageF(image_data)#.astype(\"float32\"))\n", + "print(type(image_data)) # numpy.ndarray\n", + "print(type(image)) # lsst.afw.image._image.ImageF\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "cceab1fb-7f66-4858-b46f-d71fddb50159", + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "display = afwDisplay.Display()\n", + "display.scale('asinh', 'zscale')\n", + "display.image(image)\n", + "plt.show()" + ] + }, { "attachments": { "923e951d-30c0-4a8f-a1b0-8bb851f1cb5f.png": { From 72b7c54cdc07263ccd6853aa1fac7e886d6ef2b9 Mon Sep 17 00:00:00 2001 From: christinawilliams Date: Sun, 14 Dec 2025 20:06:49 +0000 Subject: [PATCH 09/16] updating last verified date for DP02 nb 18 --- DP0.2/18_Galaxy_Photometry.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DP0.2/18_Galaxy_Photometry.ipynb b/DP0.2/18_Galaxy_Photometry.ipynb index 80454ee7..61c79f94 100644 --- a/DP0.2/18_Galaxy_Photometry.ipynb +++ b/DP0.2/18_Galaxy_Photometry.ipynb @@ -13,7 +13,7 @@ "\"Rubin\n", "\n", "Contact author(s): Christina Williams
\n", - "Last verified to run: 2025-09-02
\n", + "Last verified to run: 2025-12-14
\n", "LSST Science Pipelines version: r29.2.0
\n", "Container Size: medium
" ] From b90df47fe8c2b4a92e25907874b26109508e8659 Mon Sep 17 00:00:00 2001 From: christinawilliams Date: Mon, 15 Dec 2025 22:23:32 +0000 Subject: [PATCH 10/16] updates to 103_4 nb --- .../103_4_Small_Image_Cutout.ipynb | 174 +++++------------- 1 file changed, 47 insertions(+), 127 deletions(-) diff --git a/DP1/100_How_to_Use_RSP_Tools/103_Image_access_and_display/103_4_Small_Image_Cutout.ipynb b/DP1/100_How_to_Use_RSP_Tools/103_Image_access_and_display/103_4_Small_Image_Cutout.ipynb index eee2b97e..94a4ed82 100644 --- a/DP1/100_How_to_Use_RSP_Tools/103_Image_access_and_display/103_4_Small_Image_Cutout.ipynb +++ b/DP1/100_How_to_Use_RSP_Tools/103_Image_access_and_display/103_4_Small_Image_Cutout.ipynb @@ -22,7 +22,7 @@ "Data Release: DP1
\n", "Container Size: large
\n", "LSST Science Pipelines version: r29.2.0
\n", - "Last verified to run: 2025-11-20
\n", + "Last verified to run: 2025-12-15
\n", "Repository: github.com/lsst/tutorial-notebooks
" ] }, @@ -98,12 +98,13 @@ "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt\n", - "import os\n", "\n", "import lsst.afw.display as afwDisplay\n", + "import lsst.afw.image as afwImage\n", "from lsst.afw.image import ExposureF\n", "from lsst.afw.fits import MemFileManager\n", "\n", + "\n", "from lsst.rsp.utils import get_pyvo_auth\n", "from lsst.rsp.service import get_siav2_service\n", "\n", @@ -113,7 +114,10 @@ "\n", "from astropy import units as u\n", "from astropy.coordinates import Angle\n", - "from astropy.time import Time" + "from astropy.time import Time\n", + "\n", + "from astropy.io import fits\n", + "import io\n" ] }, { @@ -324,7 +328,7 @@ "id": "d945e191-7ee4-458a-bb0f-fb00cd219e30", "metadata": {}, "source": [ - "Lastly, call the Rubin Image Cutout Service. Three types of cutout services exist: `cutout-sync` which, by default, returns just the image extension of the LSST imaging; `cutout-sync-exposure`, which returns the full set of metadata and image extensions that are contained in the `ExposureF` data type; and `cutout-sync-mask` which contains just the mask extension. This section will demonstrate the use of `cutout-sync-exposure` and Section 4 below will demonstrate the other two. \n", + "Lastly, call the Rubin Image Cutout Service. This notebook demonstrates two types of cutout services: `cutout-sync` which, by default, returns just the image extension of the LSST imaging; `cutout-sync-exposure`, which returns the full set of metadata and image extensions that are contained in the `ExposureF` data type. This section will demonstrate the use of `cutout-sync-exposure` and Section 4 below will demonstrate the other. \n", "\n", "To use the cutout service in this example, the IVOA procedure `cutout-sync-exposure` is called using `get_adhocservice_by_id`. It is done by feeding the data link created above (called `dl_result`) to `from_resource`. Since the Rubin DP1 imaging is proprietary it is necessary to again provide the authorization for the current RSP session. Do this using the `get_pyvo_auth` function." ] @@ -681,31 +685,11 @@ "id": "99e75a7a-348e-409e-88f6-871b68a4e9dc", "metadata": {}, "source": [ - "## 4. Other cutout service data types\n", - "\n", - "As mentioned in Section 3, there are three types of cutout services: `cutout-sync-exposure` to return an `ExposureF` type image with all LSST image extensions (demonstrated above); `cutout-sync` which returns just the image extension, and and `cutout-sync-mask` which contains just the mask extension. The latter 2 will be demonstrated below.\n", - "\n", - "### 4.1 Single extension image cutouts\n", - "\n", - "Below demonstrates how to retrieve single extension images using `cutout-sync`." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "c2c8ab4c-cd1d-4ae8-937d-b34a21035e1e", - "metadata": {}, - "outputs": [], - "source": [ - "from astropy.io import fits\n", - "import io\n", + "## 4. Single extension image cutouts\n", "\n", - "print(results[0])\n", - "datalink_url = results[0].access_url\n", - "dl_result = DatalinkResults.from_result_url(datalink_url,\n", - " session=get_pyvo_auth())\n", + "As mentioned in Section 3, there are three types of cutout services: `cutout-sync-exposure` to return an `ExposureF` type image with all LSST image extensions (demonstrated above); `cutout-sync` which returns just the image extension. The latter 2 will be demonstrated below.\n", "\n", - "f\"Datalink status: {dl_result.status}. Datalink service url: {datalink_url}\"\n" + "First, reuse the data link `dl_result` that was defined in Section 3 to define a new cutout, this time using `cutout-sync`. Call this soda query `sq4` to differentiate from the earlier ones. Define the cutout as a square subtended by a circle of radius 0.01 degrees, as done in Section 3.\n" ] }, { @@ -715,169 +699,113 @@ "metadata": {}, "outputs": [], "source": [ - "\n", - "sq5 = SodaQuery.from_resource(dl_result,\n", - " dl_result.get_adhocservice_by_id(\"cutout-sync\"),\n", - " session=get_pyvo_auth())\n", + "sq4 = SodaQuery.from_resource(dl_result,\n", + " dl_result.get_adhocservice_by_id(\"cutout-sync\"),\n", + " session=get_pyvo_auth())\n", "\n", "spherePoint = geom.SpherePoint(target_ra*geom.degrees, target_dec*geom.degrees)\n", "Radius = 0.01 * u.deg\n", - "sq5.circle = (spherePoint.getRa().asDegrees() * u.deg,\n", - " spherePoint.getDec().asDegrees() * u.deg,\n", - " Radius)\n", "\n", - "cutout_bytes = sq5.execute_stream().read()\n", - "sq5.raise_if_error()\n" + "sq4.circle = (spherePoint.getRa().asDegrees() * u.deg,\n", + " spherePoint.getDec().asDegrees() * u.deg,\n", + " Radius)\n", + "\n", + "cutout_bytes = sq4.execute_stream().read()\n", + "sq4.raise_if_error()\n" ] }, { - "cell_type": "code", - "execution_count": null, - "id": "516dbd86-d573-4d81-a017-2ebbce8fb445", + "cell_type": "markdown", + "id": "454a017b-df88-48cc-975e-cac4ff3a37b5", "metadata": {}, - "outputs": [], "source": [ - "mem = MemFileManager(len(cutout_bytes))\n", - "mem.setData(cutout_bytes, len(cutout_bytes))\n", - "\n" + "Receive the cutout into memory, as in Section 3." ] }, { "cell_type": "code", "execution_count": null, - "id": "ed3f7908-a256-42f5-939f-61f38645c7ca", + "id": "516dbd86-d573-4d81-a017-2ebbce8fb445", "metadata": {}, "outputs": [], "source": [ - "data = mem.getData() # returns `bytes`\n", - "\n", - "# this doesn't work\n", - "import lsst.afw.image as afwImage\n", - "\n", - "#image = afwImage.ImageF(mem)\n" + "mem = MemFileManager(len(cutout_bytes))\n", + "mem.setData(cutout_bytes, len(cutout_bytes))\n" ] }, { - "cell_type": "code", - "execution_count": null, - "id": "d23a0397-6500-4e36-b956-7917ed6a7173", + "cell_type": "markdown", + "id": "2ae72a88-8002-46b5-8eee-164a2c903314", "metadata": {}, - "outputs": [], "source": [ - "\n", - "#data = mem.getData()\n", - "hdul = fits.open(io.BytesIO(data))\n", - "hdul.info()\n", - "\n", - "image_hdu = hdul[1] # IMAGE extension\n", - "image_data = image_hdu.data # NumPy array\n", - "#image = afwImage.ImageF(image_data)\n", - "image = afwImage.ImageF(image_data.astype(\"float32\"))\n", - "print(type(image_data)) # numpy.ndarray\n", - "print(type(image)) # lsst.afw.image._image.ImageF\n" + "Use the `getData` method from the `MemFileManager` class to return and store the bytes associated with the cutout. " ] }, { "cell_type": "code", "execution_count": null, - "id": "1aa9009a-b493-41ea-bc3c-e0c79adef913", + "id": "ed3f7908-a256-42f5-939f-61f38645c7ca", "metadata": {}, "outputs": [], "source": [ - "\n", - "display = afwDisplay.Display()\n", - "display.scale('asinh', 'zscale')\n", - "display.image(image)\n", - "plt.show()" + "data = mem.getData()\n" ] }, { "cell_type": "markdown", - "id": "918e8779-2939-4978-9ec4-c8a4047f04e9", + "id": "441a49fb-42be-4f37-853e-141419f1da14", "metadata": {}, "source": [ - "### 4.2 Single extension mask cutouts\n", - "\n", - "Below demonstrates how to retrieve the corresponding mask using `cutout-sync-mask`." + "Use the astropy.io fits package to access the bytes and store in an HDUList object. Then, the image extension `image_hdu`, and pixel values `image_data` (a numpy array) can be accessed similar to opening a fits file. " ] }, { "cell_type": "code", "execution_count": null, - "id": "a1213ce5-9049-43ce-8032-f1ea2db9c576", + "id": "d23a0397-6500-4e36-b956-7917ed6a7173", "metadata": {}, "outputs": [], "source": [ + "hdul = fits.open(io.BytesIO(data))\n", + "hdul.info()\n", "\n", - "sq5 = SodaQuery.from_resource(dl_result,\n", - " dl_result.get_adhocservice_by_id(\"cutout-sync-maskedimage\"),\n", - " session=get_pyvo_auth())\n", - "\n", - "spherePoint = geom.SpherePoint(target_ra*geom.degrees, target_dec*geom.degrees)\n", - "Radius = 0.01 * u.deg\n", - "sq5.circle = (spherePoint.getRa().asDegrees() * u.deg,\n", - " spherePoint.getDec().asDegrees() * u.deg,\n", - " Radius)\n", - "\n", - "cutout_bytes = sq5.execute_stream().read()\n", - "sq5.raise_if_error()\n" + "image_hdu = hdul[1]\n", + "image_data = image_hdu.data\n" ] }, { - "cell_type": "code", - "execution_count": null, - "id": "a2f5ed28-c17d-451b-969c-b7d9186eeb23", + "cell_type": "markdown", + "id": "c0eea8e5-ae86-456d-9d67-798557a4a707", "metadata": {}, - "outputs": [], "source": [ - "mem = MemFileManager(len(cutout_bytes))\n", - "mem.setData(cutout_bytes, len(cutout_bytes))\n", - "\n" + "To enable image display, first store `image_data` as an LSST `ImageF` object." ] }, { "cell_type": "code", "execution_count": null, - "id": "770c6bc2-67f5-4d3f-9d3a-98cd27e28b35", + "id": "78e1c658-916c-4a73-8c0b-a50d281f4764", "metadata": {}, "outputs": [], "source": [ - "data = mem.getData() # returns `bytes`\n", - "\n", - "# this doesn't work\n", - "import lsst.afw.image as afwImage\n", - "\n", - "#image = afwImage.ImageF(mem)\n" + "image = afwImage.ImageF(image_data.astype(\"float32\"))\n" ] }, { - "cell_type": "code", - "execution_count": null, - "id": "ba884db3-cd3e-45b9-bba0-ecd98cd95358", + "cell_type": "markdown", + "id": "6a19e7cd-4096-44b9-832f-baa6b6c40482", "metadata": {}, - "outputs": [], "source": [ - "\n", - "#data = mem.getData()\n", - "hdul = fits.open(io.BytesIO(data))\n", - "hdul.info()\n", - "\n", - "image_hdu = hdul[2] # IMAGE extension\n", - "image_data = image_hdu.data # NumPy array\n", - "#image = afwImage.ImageF(image_data)\n", - "image = afwImage.ImageF(image_data)#.astype(\"float32\"))\n", - "print(type(image_data)) # numpy.ndarray\n", - "print(type(image)) # lsst.afw.image._image.ImageF\n" + "Display the image cutout." ] }, { "cell_type": "code", "execution_count": null, - "id": "cceab1fb-7f66-4858-b46f-d71fddb50159", + "id": "1aa9009a-b493-41ea-bc3c-e0c79adef913", "metadata": {}, "outputs": [], "source": [ - "\n", "display = afwDisplay.Display()\n", "display.scale('asinh', 'zscale')\n", "display.image(image)\n", @@ -904,14 +832,6 @@ "\n", "\n" ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "6b611f9f-aaa5-4e2b-b4a5-b7acc6aecbf9", - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { From 0c24a2a003b9d9a695a8c3e756444a9e60111e9a Mon Sep 17 00:00:00 2001 From: christinawilliams Date: Mon, 15 Dec 2025 22:45:48 +0000 Subject: [PATCH 11/16] updating 13a DP02 nb --- DP0.2/13a_Image_Cutout_SciDemo.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DP0.2/13a_Image_Cutout_SciDemo.ipynb b/DP0.2/13a_Image_Cutout_SciDemo.ipynb index 4a4e92d4..c53ad6c3 100644 --- a/DP0.2/13a_Image_Cutout_SciDemo.ipynb +++ b/DP0.2/13a_Image_Cutout_SciDemo.ipynb @@ -10,7 +10,7 @@ "\"Rubin\n", "
\n", "Contact author: Christina Williams
\n", - "Last verified to run: 2025-12-10
\n", + "Last verified to run: 2025-12-15
\n", "LSST Science Pipelines version: r29.2.0
\n", "Container Size: medium
\n", "Targeted learning level: beginner
" From 22391832f9eb6ca026736302c94687faef67caa2 Mon Sep 17 00:00:00 2001 From: christinawilliams Date: Tue, 16 Dec 2025 18:06:56 +0000 Subject: [PATCH 12/16] fixing import to avoid a merge issue with earlier updates --- .../103_Image_access_and_display/103_4_Small_Image_Cutout.ipynb | 2 -- 1 file changed, 2 deletions(-) diff --git a/DP1/100_How_to_Use_RSP_Tools/103_Image_access_and_display/103_4_Small_Image_Cutout.ipynb b/DP1/100_How_to_Use_RSP_Tools/103_Image_access_and_display/103_4_Small_Image_Cutout.ipynb index 94a4ed82..6ff344dc 100644 --- a/DP1/100_How_to_Use_RSP_Tools/103_Image_access_and_display/103_4_Small_Image_Cutout.ipynb +++ b/DP1/100_How_to_Use_RSP_Tools/103_Image_access_and_display/103_4_Small_Image_Cutout.ipynb @@ -474,8 +474,6 @@ "metadata": {}, "outputs": [], "source": [ - "# from astropy.io import fits\n", - "\n", "# fits.info(sodaCutout)\n", "\n", "# sodaCutout_small = os.path.join(tempdir, 'cutout-circle_small.fits')\n", From 3a7a5c32a270f0a02224b5ba66384d95daecb987 Mon Sep 17 00:00:00 2001 From: christinawilliams Date: Tue, 16 Dec 2025 18:10:47 +0000 Subject: [PATCH 13/16] fixing import to avoid a merge issue with earlier updates --- .../103_Image_access_and_display/103_4_Small_Image_Cutout.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DP1/100_How_to_Use_RSP_Tools/103_Image_access_and_display/103_4_Small_Image_Cutout.ipynb b/DP1/100_How_to_Use_RSP_Tools/103_Image_access_and_display/103_4_Small_Image_Cutout.ipynb index 6ff344dc..4eb83c4e 100644 --- a/DP1/100_How_to_Use_RSP_Tools/103_Image_access_and_display/103_4_Small_Image_Cutout.ipynb +++ b/DP1/100_How_to_Use_RSP_Tools/103_Image_access_and_display/103_4_Small_Image_Cutout.ipynb @@ -22,7 +22,7 @@ "Data Release: DP1
\n", "Container Size: large
\n", "LSST Science Pipelines version: r29.2.0
\n", - "Last verified to run: 2025-12-15
\n", + "Last verified to run: 2025-12-16
\n", "Repository: github.com/lsst/tutorial-notebooks
" ] }, From d8fce388afbd5e78857d744514bdddbe8601e721 Mon Sep 17 00:00:00 2001 From: christinawilliams Date: Tue, 16 Dec 2025 18:29:50 +0000 Subject: [PATCH 14/16] precommit --- .../306_2_Candidate_transient_identification.ipynb | 8 -------- 1 file changed, 8 deletions(-) diff --git a/DP1/300_Science_Demos/306_Extragalactic_transients/306_2_Candidate_transient_identification.ipynb b/DP1/300_Science_Demos/306_Extragalactic_transients/306_2_Candidate_transient_identification.ipynb index df3c2d82..969cae2e 100644 --- a/DP1/300_Science_Demos/306_Extragalactic_transients/306_2_Candidate_transient_identification.ipynb +++ b/DP1/300_Science_Demos/306_Extragalactic_transients/306_2_Candidate_transient_identification.ipynb @@ -839,14 +839,6 @@ "source": [ "> **Figure 4**: The cutout triplet for the first detection of this `DiaObject`, a candidate SN Ia." ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "89ed684b-147e-4ed5-a340-205491c0f096", - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { From cb620fa450dfb6717d9cc92530464bf0b302f851 Mon Sep 17 00:00:00 2001 From: christinawilliams Date: Tue, 16 Dec 2025 22:58:01 +0000 Subject: [PATCH 15/16] last update --- .../103_4_Small_Image_Cutout.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DP1/100_How_to_Use_RSP_Tools/103_Image_access_and_display/103_4_Small_Image_Cutout.ipynb b/DP1/100_How_to_Use_RSP_Tools/103_Image_access_and_display/103_4_Small_Image_Cutout.ipynb index 4eb83c4e..cd98dae3 100644 --- a/DP1/100_How_to_Use_RSP_Tools/103_Image_access_and_display/103_4_Small_Image_Cutout.ipynb +++ b/DP1/100_How_to_Use_RSP_Tools/103_Image_access_and_display/103_4_Small_Image_Cutout.ipynb @@ -685,7 +685,7 @@ "source": [ "## 4. Single extension image cutouts\n", "\n", - "As mentioned in Section 3, there are three types of cutout services: `cutout-sync-exposure` to return an `ExposureF` type image with all LSST image extensions (demonstrated above); `cutout-sync` which returns just the image extension. The latter 2 will be demonstrated below.\n", + "As mentioned in Section 3, there are three types of cutout services: `cutout-sync-exposure` to return an `ExposureF` type image with all LSST image extensions (demonstrated above); `cutout-sync` which returns just the image extension. The latter will be demonstrated below.\n", "\n", "First, reuse the data link `dl_result` that was defined in Section 3 to define a new cutout, this time using `cutout-sync`. Call this soda query `sq4` to differentiate from the earlier ones. Define the cutout as a square subtended by a circle of radius 0.01 degrees, as done in Section 3.\n" ] @@ -746,7 +746,7 @@ "metadata": {}, "outputs": [], "source": [ - "data = mem.getData()\n" + "data = mem.getData()" ] }, { From 108ffc42152e7c2c1d9df9e8c62976c12732b3b6 Mon Sep 17 00:00:00 2001 From: christinawilliams Date: Wed, 17 Dec 2025 20:48:31 +0000 Subject: [PATCH 16/16] added excluded package import --- .../203_Maps/203_1_Survey_property_maps.ipynb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/DP1/200_Data_Products/203_Maps/203_1_Survey_property_maps.ipynb b/DP1/200_Data_Products/203_Maps/203_1_Survey_property_maps.ipynb index c7c9720b..ba523fbe 100644 --- a/DP1/200_Data_Products/203_Maps/203_1_Survey_property_maps.ipynb +++ b/DP1/200_Data_Products/203_Maps/203_1_Survey_property_maps.ipynb @@ -22,7 +22,7 @@ "Data Release: Data Preview 1
\n", "Container Size: large
\n", "LSST Science Pipelines version: r29.2.0
\n", - "Last verified to run: 2025-09-02
\n", + "Last verified to run: 2025-12-17
\n", "Repository: github.com/lsst/tutorial-notebooks
" ] }, @@ -653,6 +653,7 @@ "metadata": {}, "outputs": [], "source": [ + "# from astropy.wcs import WCS\n", "# temp = deep_coadd.image.array.flatten()\n", "# norm = ImageNormalize(temp, interval=ZScaleInterval(),\n", "# stretch=LinearStretch())\n",