Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions DP0.2/13a_Image_Cutout_SciDemo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"<img align=\"left\" src = https://project.lsst.org/sites/default/files/Rubin-O-Logo_0.png width=250 style=\"padding: 10px\" alt=\"Rubin Observatory logo, a graphical representation of turning stars into data.\">\n",
"<br>\n",
"Contact author: Christina Williams <br>\n",
"Last verified to run: 2025-09-02 <br>\n",
"Last verified to run: 2025-12-15 <br>\n",
"LSST Science Pipelines version: r29.2.0 <br>\n",
"Container Size: medium <br>\n",
"Targeted learning level: beginner <br>"
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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)"
]
},
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions DP0.2/18_Galaxy_Photometry.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"<img align=\"left\" src = https://noirlab.edu/public/media/archives/logos/svg/logo250.svg width=250 style=\"background-color:white; padding:10px\" alt=\"Rubin Observatory logo, a graphical representation of turning stars into data.\">\n",
"</div>\n",
"Contact author(s): Christina Williams <br>\n",
"Last verified to run: 2025-09-02 <br>\n",
"Last verified to run: 2025-12-14 <br>\n",
"LSST Science Pipelines version: r29.2.0 <br>\n",
"Container Size: medium <br>"
]
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"Data Release: DP1 <br>\n",
"Container Size: large <br>\n",
"LSST Science Pipelines version: r29.2.0 <br>\n",
"Last verified to run: 2025-11-20 <br>\n",
"Last verified to run: 2025-12-16 <br>\n",
"Repository: <a href=\"https://github.com/lsst/tutorial-notebooks\">github.com/lsst/tutorial-notebooks</a> <br>"
]
},
Expand Down Expand Up @@ -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",
Expand All @@ -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"
]
},
{
Expand Down Expand Up @@ -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."
]
},
{
Expand All @@ -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())"
]
},
Expand Down Expand Up @@ -386,15 +392,15 @@
"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"
]
},
{
"cell_type": "markdown",
"id": "324be87a-337b-4db7-b57d-842f14614613",
"metadata": {},
"source": [
"Display the cutout."
"Display the image extension of the `ExposureF` cutout."
]
},
{
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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": {
Expand All @@ -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",
Expand All @@ -694,14 +830,6 @@
"\n",
"</div>\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6b611f9f-aaa5-4e2b-b4a5-b7acc6aecbf9",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"Data Release: <a href=\"https://dp1.lsst.io/\">Data Preview 1</a> <br>\n",
"Container Size: large <br>\n",
"LSST Science Pipelines version: r29.2.0 <br>\n",
"Last verified to run: 2025-09-02 <br>\n",
"Last verified to run: 2025-12-17 <br>\n",
"Repository: <a href=\"https://github.com/lsst/tutorial-notebooks\">github.com/lsst/tutorial-notebooks</a> <br>"
]
},
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions DP1/300_Science_Demos/303_Galaxies/303_2_Galaxy_Shapes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"Data Release: <a href=\"https://dp1.lsst.io/\">Data Preview 1</a> <br>\n",
"Container Size: Large <br>\n",
"LSST Science Pipelines version: r29.2.0 <br>\n",
"Last verified to run: 2025-09-02 <br>\n",
"Last verified to run: 2025-12-11 <br>\n",
"Repository: <a href=\"https://github.com/lsst/tutorial-notebooks\">github.com/lsst/tutorial-notebooks</a> <br>"
]
},
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"Data Release: <a href=\"https://dp1.lsst.io/\">Data Preview 1</a> <br>\n",
"Container Size: large <br>\n",
"LSST Science Pipelines version: r29.2.0 <br>\n",
"Last verified to run: 2025-09-17 <br>\n",
"Last verified to run: 2025-12-11 <br>\n",
"Repository: <a href=\"https://github.com/lsst/tutorial-notebooks\">github.com/lsst/tutorial-notebooks</a> <br>"
]
},
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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": {
Expand Down