diff --git a/DP0.2/13a_Image_Cutout_SciDemo.ipynb b/DP0.2/13a_Image_Cutout_SciDemo.ipynb index 22fd2f9f..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-09-02
\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
" @@ -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", diff --git a/DP0.2/18_Galaxy_Photometry.ipynb b/DP0.2/18_Galaxy_Photometry.ipynb index 8eda55f8..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
" ] @@ -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", 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..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 @@ -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-16
\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,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. 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." ] }, { @@ -335,7 +341,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())" ] }, @@ -386,7 +392,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 +400,7 @@ "id": "324be87a-337b-4db7-b57d-842f14614613", "metadata": {}, "source": [ - "Display the cutout." + "Display the image extension of the `ExposureF` cutout." ] }, { @@ -468,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", @@ -502,7 +506,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 +569,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 +608,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 +678,138 @@ "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. 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 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" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "837fbd2a-c3e2-4ee3-a06d-69f4df50823b", + "metadata": {}, + "outputs": [], + "source": [ + "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", + "\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": "markdown", + "id": "454a017b-df88-48cc-975e-cac4ff3a37b5", + "metadata": {}, + "source": [ + "Receive the cutout into memory, as in Section 3." + ] + }, + { + "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" + ] + }, + { + "cell_type": "markdown", + "id": "2ae72a88-8002-46b5-8eee-164a2c903314", + "metadata": {}, + "source": [ + "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": "ed3f7908-a256-42f5-939f-61f38645c7ca", + "metadata": {}, + "outputs": [], + "source": [ + "data = mem.getData()" + ] + }, + { + "cell_type": "markdown", + "id": "441a49fb-42be-4f37-853e-141419f1da14", + "metadata": {}, + "source": [ + "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": "d23a0397-6500-4e36-b956-7917ed6a7173", + "metadata": {}, + "outputs": [], + "source": [ + "hdul = fits.open(io.BytesIO(data))\n", + "hdul.info()\n", + "\n", + "image_hdu = hdul[1]\n", + "image_data = image_hdu.data\n" + ] + }, + { + "cell_type": "markdown", + "id": "c0eea8e5-ae86-456d-9d67-798557a4a707", + "metadata": {}, + "source": [ + "To enable image display, first store `image_data` as an LSST `ImageF` object." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "78e1c658-916c-4a73-8c0b-a50d281f4764", + "metadata": {}, + "outputs": [], + "source": [ + "image = afwImage.ImageF(image_data.astype(\"float32\"))\n" + ] + }, + { + "cell_type": "markdown", + "id": "6a19e7cd-4096-44b9-832f-baa6b6c40482", + "metadata": {}, + "source": [ + "Display the image cutout." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1aa9009a-b493-41ea-bc3c-e0c79adef913", + "metadata": {}, + "outputs": [], + "source": [ + "display = afwDisplay.Display()\n", + "display.scale('asinh', 'zscale')\n", + "display.image(image)\n", + "plt.show()" + ] + }, { "attachments": { "923e951d-30c0-4a8f-a1b0-8bb851f1cb5f.png": { @@ -684,7 +820,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", @@ -694,14 +830,6 @@ "\n", "\n" ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "6b611f9f-aaa5-4e2b-b4a5-b7acc6aecbf9", - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { 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", 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", 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..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 @@ -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", @@ -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": {