Skip to content

Commit f89109e

Browse files
committed
updated files
1 parent a56c5de commit f89109e

6 files changed

Lines changed: 200 additions & 54 deletions

DP1/300_Science_Demos/301_Field_explorations/301_1_47Tuc_Globular_Cluster.ipynb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,11 @@
473473
{
474474
"cell_type": "markdown",
475475
"id": "00f38067-8ee3-422c-b774-63ac8b83b60f",
476-
"metadata": {},
476+
"metadata": {
477+
"jupyter": {
478+
"source_hidden": true
479+
}
480+
},
477481
"source": [
478482
"Fetch the results as an `astropy` table."
479483
]

DP1/300_Science_Demos/301_Field_explorations/301_3_Fornax_Dwarf_Spheroidal_Galaxy.ipynb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@
9999
"from lsst.daf.butler import Butler\n",
100100
"import lsst.afw.display as afw_display\n",
101101
"import lsst.sphgeom as sphgeom\n",
102-
"import lsst.geom as geom\n",
103102
"from lsst.utils.plotting import (\n",
104103
" get_multiband_plot_colors,\n",
105104
" get_multiband_plot_symbols,\n",

DP1/300_Science_Demos/301_Field_explorations/301_4_Extended_Chandra_Deep_Field_South.ipynb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@
9191
"from lsst.daf.butler import Butler\n",
9292
"import lsst.afw.display as afw_display\n",
9393
"import lsst.sphgeom as sphgeom\n",
94-
"import lsst.geom as geom\n",
9594
"\n",
9695
"from lsst.utils.plotting import (get_multiband_plot_colors,\n",
9796
" get_multiband_plot_symbols,\n",

DP1/300_Science_Demos/301_Field_explorations/301_5_Euclid_Deep_Field_South.ipynb

Lines changed: 65 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"source": [
8585
"Import `numpy`, a fundamental package for scientific computing with arrays in Python (<a href=\"https://numpy.org\">numpy.org</a>), and `matplotlib`, a comprehensive library for data visualization (<a href=\"https://matplotlib.org/\">matplotlib.org</a>; <a href=\"https://matplotlib.org/stable/gallery/index.html\">matplotlib gallery</a>), including custom shapes (`Polygon`) and lines (`mlines`). `itertools` supports efficient iteration and combinatorics.\n",
8686
"\n",
87-
"From the `lsst` package, import modules for accessing the Table Access Protocol (TAP) service, for retrieving datasets from the butler, and for image displaying from the LSST Science Pipelines (<a href=\"https://pipelines.lsst.io/\">pipelines.lsst.io</a>). Additional modules support spherical geometry (`sphgeom`), 2D geometry (`geom`), and standardized multiband plotting (`lsst.utils.plotting`) for LSST data analysis and visualization."
87+
"From the `lsst` package, import modules for accessing the Table Access Protocol (TAP) service, for retrieving datasets from the butler, and for image displaying from the LSST Science Pipelines (<a href=\"https://pipelines.lsst.io/\">pipelines.lsst.io</a>). Additional modules support spherical geometry (`sphgeom`), and standardized multiband plotting (`lsst.utils.plotting`) for LSST data analysis and visualization."
8888
]
8989
},
9090
{
@@ -104,7 +104,6 @@
104104
"from lsst.daf.butler import Butler\n",
105105
"import lsst.afw.display as afw_display\n",
106106
"import lsst.sphgeom as sphgeom\n",
107-
"import lsst.geom as geom\n",
108107
"from lsst.utils.plotting import (get_multiband_plot_colors,\n",
109108
" get_multiband_plot_symbols,\n",
110109
" get_multiband_plot_linestyles)"
@@ -464,14 +463,58 @@
464463
"}"
465464
]
466465
},
466+
{
467+
"cell_type": "markdown",
468+
"id": "59dcf20d-5f2a-4eea-9912-5141725d5267",
469+
"metadata": {},
470+
"source": [
471+
"Use TAP to find vertices of each patch covering the field in the `dp1.coaddPatches` table."
472+
]
473+
},
474+
{
475+
"cell_type": "code",
476+
"execution_count": null,
477+
"id": "408b2c05-bbb8-42cb-8c46-f6d6f2267417",
478+
"metadata": {},
479+
"outputs": [],
480+
"source": [
481+
"query = \"SELECT lsst_patch, lsst_tract, s_ra, s_dec, s_region \" \\\n",
482+
" \"FROM dp1.CoaddPatches \" \\\n",
483+
" \"WHERE CONTAINS(POINT('ICRS', s_ra, s_dec), \" \\\n",
484+
" \"CIRCLE('ICRS', {}, {}, {})) = 1 \".format(ra_cen, dec_cen, radius)\n",
485+
"job = service.submit_job(query)\n",
486+
"job.run()\n",
487+
"job.wait(phases=['COMPLETED', 'ERROR'])\n",
488+
"print('Job phase is', job.phase)\n",
489+
"if job.phase == 'ERROR':\n",
490+
" job.raise_if_error()"
491+
]
492+
},
493+
{
494+
"cell_type": "markdown",
495+
"id": "cb5e6cf9-a54d-4b6f-bffb-a0e9bbebb4ce",
496+
"metadata": {},
497+
"source": [
498+
"Fetch the results as an `astropy` table."
499+
]
500+
},
501+
{
502+
"cell_type": "code",
503+
"execution_count": null,
504+
"id": "c5a1e2fe-0a36-4b83-9baf-c3e02b720ec5",
505+
"metadata": {},
506+
"outputs": [],
507+
"source": [
508+
"assert job.phase == 'COMPLETED'\n",
509+
"coadd_patches = job.fetch_result().to_table()"
510+
]
511+
},
467512
{
468513
"cell_type": "markdown",
469514
"id": "34601d6c-4a03-4c22-8730-f17c99a34966",
470515
"metadata": {},
471516
"source": [
472-
"The `coadd_datasetrefs` returned from the butler include region information for each dataset, stored as a `ConvexPolygon3D` with four vertices defining the sky footprint of each overlapping tract and patch.\n",
473-
"\n",
474-
"Convert these vertices to 2D sky coordinates (RA, Dec) using `geom.SpherePoint`, and use `matplotlib.patches.Polygon` along with `ax.add_patch()` to draw each patch outline. Each tract is plotted with a distinct color and linestyle for visual clarity."
517+
"Use `matplotlib.patches.Polygon` along with `ax.add_patch()` to draw each patch outline. Each tract is plotted with a distinct color and linestyle for visual clarity."
475518
]
476519
},
477520
{
@@ -486,17 +529,21 @@
486529
"mesh = ax.pcolormesh(x, y, values_rmaglim, cmap='Greys_r', shading='auto')\n",
487530
"fig.colorbar(mesh, ax=ax, label=\"r-band limiting magnitude (mag)\")\n",
488531
"\n",
489-
"for rec in coadd_datasetrefs:\n",
490-
" vertices = rec.dataId.patch.region.getVertices()\n",
491-
" vertices_deg = []\n",
492-
" for vertex in vertices:\n",
493-
" vertices_deg.append([geom.SpherePoint(vertex).getRa().asDegrees(),\n",
494-
" geom.SpherePoint(vertex).getDec().asDegrees()])\n",
495-
" polygon = Polygon(vertices_deg, closed=True, facecolor='None',\n",
496-
" edgecolor=style_dict[rec.dataId['tract']]['color'],\n",
497-
" linestyle=style_dict[rec.dataId['tract']]['linestyle'],\n",
498-
" linewidth=2)\n",
499-
" ax.add_patch(polygon)\n",
532+
"for tract in tracts:\n",
533+
" s_regions = coadd_patches[coadd_patches['lsst_tract'] == tract]['s_region']\n",
534+
"\n",
535+
" for s_region in s_regions:\n",
536+
" coordinates = np.array(s_region.split()[2:], dtype=float)\n",
537+
" ra = coordinates[0::2]\n",
538+
" ra = (ra + 180) % 360 - 180\n",
539+
" dec = coordinates[1::2]\n",
540+
" vertices_deg = np.vstack([ra, dec]).T\n",
541+
"\n",
542+
" polygon = Polygon(vertices_deg, closed=True, facecolor='None',\n",
543+
" edgecolor=style_dict[tract]['color'],\n",
544+
" linestyle=style_dict[tract]['linestyle'],\n",
545+
" linewidth=2)\n",
546+
" ax.add_patch(polygon)\n",
500547
"\n",
501548
"ax.set_xlim(ra_max, ra_min)\n",
502549
"ax.set_ylim(dec_min, dec_max)\n",
@@ -542,7 +589,8 @@
542589
"del coadd_datasetrefs\n",
543590
"del hspmap_rmaglim, hspmap_rexptime\n",
544591
"del x, y, values_rmaglim, values_rexptime\n",
545-
"del style_dict"
592+
"del style_dict\n",
593+
"del tracts, s_regions, coordinates, ra, dec"
546594
]
547595
},
548596
{

DP1/300_Science_Demos/301_Field_explorations/301_6_Low_Galactic_Latitude_Field.ipynb

Lines changed: 65 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
"(<a href=\"https://matplotlib.org/\">matplotlib.org</a>; \n",
8383
"<a href=\"https://matplotlib.org/stable/gallery/index.html\">matplotlib gallery</a>), including custom shapes (`Polygon`) and lines (`mlines`). `itertools` supports efficient iteration and combinatorics.\n",
8484
"\n",
85-
"From the `lsst` package, import modules for accessing the Table Access Protocol (TAP) service, for retrieving datasets from the butler, and image display functions from the LSST Science Pipelines (<a href=\"https://pipelines.lsst.io/\">pipelines.lsst.io</a>). Additional modules support spherical geometry (`sphgeom`), 2D geometry (`geom`), and standardized multiband plotting (`lsst.utils.plotting`) for LSST data analysis and visualization."
85+
"From the `lsst` package, import modules for accessing the Table Access Protocol (TAP) service, for retrieving datasets from the butler, and image display functions from the LSST Science Pipelines (<a href=\"https://pipelines.lsst.io/\">pipelines.lsst.io</a>). Additional modules support spherical geometry (`sphgeom`), and standardized multiband plotting (`lsst.utils.plotting`) for LSST data analysis and visualization."
8686
]
8787
},
8888
{
@@ -104,7 +104,6 @@
104104
"from lsst.daf.butler import Butler\n",
105105
"import lsst.afw.display as afw_display\n",
106106
"import lsst.sphgeom as sphgeom\n",
107-
"import lsst.geom as geom\n",
108107
"from lsst.utils.plotting import (get_multiband_plot_colors,\n",
109108
" get_multiband_plot_symbols,\n",
110109
" get_multiband_plot_linestyles)"
@@ -436,14 +435,58 @@
436435
" for i, tract in enumerate(unique_tracts)}"
437436
]
438437
},
438+
{
439+
"cell_type": "markdown",
440+
"id": "0ae67050-1ff9-451b-94a7-9c94e91dc9c8",
441+
"metadata": {},
442+
"source": [
443+
"Use TAP to find vertices of each patch covering the field in the `dp1.coaddPatches` table."
444+
]
445+
},
446+
{
447+
"cell_type": "code",
448+
"execution_count": null,
449+
"id": "13d13091-92cb-4fde-a9a2-84174e9b405e",
450+
"metadata": {},
451+
"outputs": [],
452+
"source": [
453+
"query = \"SELECT lsst_patch, lsst_tract, s_ra, s_dec, s_region \" \\\n",
454+
" \"FROM dp1.CoaddPatches \" \\\n",
455+
" \"WHERE CONTAINS(POINT('ICRS', s_ra, s_dec), \" \\\n",
456+
" \"CIRCLE('ICRS', {}, {}, {})) = 1 \".format(ra_cen, dec_cen, radius)\n",
457+
"job = service.submit_job(query)\n",
458+
"job.run()\n",
459+
"job.wait(phases=['COMPLETED', 'ERROR'])\n",
460+
"print('Job phase is', job.phase)\n",
461+
"if job.phase == 'ERROR':\n",
462+
" job.raise_if_error()"
463+
]
464+
},
465+
{
466+
"cell_type": "markdown",
467+
"id": "759e8504-4518-427e-8c82-989cb33e6951",
468+
"metadata": {},
469+
"source": [
470+
"Fetch the results as an `astropy` table."
471+
]
472+
},
473+
{
474+
"cell_type": "code",
475+
"execution_count": null,
476+
"id": "be779cfb-e6d6-4faa-b0e2-955cb22fc854",
477+
"metadata": {},
478+
"outputs": [],
479+
"source": [
480+
"assert job.phase == 'COMPLETED'\n",
481+
"coadd_patches = job.fetch_result().to_table()"
482+
]
483+
},
439484
{
440485
"cell_type": "markdown",
441486
"id": "76ef7e00-f9e5-425e-9c74-26b4697107c1",
442487
"metadata": {},
443488
"source": [
444-
"The `coadd_datasetrefs` returned from the butler include region information for each dataset, stored as a `ConvexPolygon3D` with four vertices defining the sky footprint of each overlapping tract and patch.\n",
445-
"\n",
446-
"Convert these vertices to 2D sky coordinates (RA, Dec) using `geom.SpherePoint`, and use `matplotlib.patches.Polygon` along with `ax.add_patch()` to draw each patch outline. Each tract is plotted with a distinct color and linestyle for visual clarity.\n",
489+
"Use `matplotlib.patches.Polygon` along with `ax.add_patch()` to draw each patch outline. Each tract is plotted with a distinct color and linestyle for visual clarity.\n",
447490
"\n",
448491
"For more details on tracts and patches, see the 100-level tutorials on the butler."
449492
]
@@ -460,17 +503,21 @@
460503
"mesh = ax.pcolormesh(x, y, values_rmaglim, cmap='Greys_r', shading='auto')\n",
461504
"fig.colorbar(mesh, ax=ax, label=\"r-band limiting magnitude (mag)\")\n",
462505
"\n",
463-
"for rec in coadd_datasetrefs:\n",
464-
" vertices = rec.dataId.patch.region.getVertices()\n",
465-
" vertices_deg = []\n",
466-
" for vertex in vertices:\n",
467-
" vertices_deg.append([geom.SpherePoint(vertex).getRa().asDegrees(),\n",
468-
" geom.SpherePoint(vertex).getDec().asDegrees()])\n",
469-
" polygon = Polygon(vertices_deg, closed=True, facecolor='None',\n",
470-
" edgecolor=style_dict[rec.dataId['tract']]['color'],\n",
471-
" linestyle=style_dict[rec.dataId['tract']]['linestyle'],\n",
472-
" linewidth=2)\n",
473-
" ax.add_patch(polygon)\n",
506+
"for tract in tracts:\n",
507+
" s_regions = coadd_patches[coadd_patches['lsst_tract'] == tract]['s_region']\n",
508+
"\n",
509+
" for s_region in s_regions:\n",
510+
" coordinates = np.array(s_region.split()[2:], dtype=float)\n",
511+
" ra = coordinates[0::2]\n",
512+
" ra = (ra + 180) % 360 - 180\n",
513+
" dec = coordinates[1::2]\n",
514+
" vertices_deg = np.vstack([ra, dec]).T\n",
515+
"\n",
516+
" polygon = Polygon(vertices_deg, closed=True, facecolor='None',\n",
517+
" edgecolor=style_dict[tract]['color'],\n",
518+
" linestyle=style_dict[tract]['linestyle'],\n",
519+
" linewidth=2)\n",
520+
" ax.add_patch(polygon)\n",
474521
"\n",
475522
"ax.set_xlim(ra_max, ra_min)\n",
476523
"ax.set_ylim(dec_min, dec_max)\n",
@@ -517,7 +564,8 @@
517564
"del coadd_datasetrefs\n",
518565
"del hspmap_rmaglim, hspmap_rexptime\n",
519566
"del x, y, values_rmaglim, values_rexptime\n",
520-
"del style_dict"
567+
"del style_dict\n",
568+
"del tracts, s_regions, coordinates, ra, dec"
521569
]
522570
},
523571
{

DP1/300_Science_Demos/301_Field_explorations/301_7_Seagull_Nebula.ipynb

Lines changed: 65 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"\n",
7979
"Import `numpy`, a fundamental package for scientific computing with arrays in Python (<a href=\"https://numpy.org\">numpy.org</a>), and `matplotlib`, a comprehensive library for data visualization (<a href=\"https://matplotlib.org/\">matplotlib.org</a>; <a href=\"https://matplotlib.org/stable/gallery/index.html\">matplotlib gallery</a>), including custom shapes (`Polygon`) and lines (`mlines`). `itertools` supports efficient iteration and combinatorics.\n",
8080
"\n",
81-
"From the `lsst` package, import modules for accessing the Table Access Protocol (TAP) service, for retrieving datasets from the butler, and for image displaying from the LSST Science Pipelines (<a href=\"https://pipelines.lsst.io/\">pipelines.lsst.io</a>). Additional modules support spherical geometry (`sphgeom`), 2D geometry (`geom`), and standardized multiband plotting (`lsst.utils.plotting`) for LSST data analysis and visualization."
81+
"From the `lsst` package, import modules for accessing the Table Access Protocol (TAP) service, for retrieving datasets from the butler, and for image displaying from the LSST Science Pipelines (<a href=\"https://pipelines.lsst.io/\">pipelines.lsst.io</a>). Additional modules support spherical geometry (`sphgeom`), and standardized multiband plotting (`lsst.utils.plotting`) for LSST data analysis and visualization."
8282
]
8383
},
8484
{
@@ -97,7 +97,6 @@
9797
"from lsst.daf.butler import Butler\n",
9898
"import lsst.afw.display as afw_display\n",
9999
"import lsst.sphgeom as sphgeom\n",
100-
"import lsst.geom as geom\n",
101100
"from lsst.utils.plotting import (get_multiband_plot_colors,\n",
102101
" get_multiband_plot_symbols,\n",
103102
" get_multiband_plot_linestyles)"
@@ -422,14 +421,58 @@
422421
" for i, tract in enumerate(unique_tracts)}"
423422
]
424423
},
424+
{
425+
"cell_type": "markdown",
426+
"id": "b07f2eee-e69c-4017-9836-89dbc45ec242",
427+
"metadata": {},
428+
"source": [
429+
"Use TAP to find vertices of each patch covering the field in the `dp1.coaddPatches` table."
430+
]
431+
},
432+
{
433+
"cell_type": "code",
434+
"execution_count": null,
435+
"id": "8de318b7-fb2e-4a1d-bf54-de9598721846",
436+
"metadata": {},
437+
"outputs": [],
438+
"source": [
439+
"query = \"SELECT lsst_patch, lsst_tract, s_ra, s_dec, s_region \" \\\n",
440+
" \"FROM dp1.CoaddPatches \" \\\n",
441+
" \"WHERE CONTAINS(POINT('ICRS', s_ra, s_dec), \" \\\n",
442+
" \"CIRCLE('ICRS', {}, {}, {})) = 1 \".format(ra_cen, dec_cen, radius)\n",
443+
"job = service.submit_job(query)\n",
444+
"job.run()\n",
445+
"job.wait(phases=['COMPLETED', 'ERROR'])\n",
446+
"print('Job phase is', job.phase)\n",
447+
"if job.phase == 'ERROR':\n",
448+
" job.raise_if_error()"
449+
]
450+
},
451+
{
452+
"cell_type": "markdown",
453+
"id": "d2be4b93-2325-4917-aa8d-de126d11ce8d",
454+
"metadata": {},
455+
"source": [
456+
"Fetch the results as an `astropy` table."
457+
]
458+
},
459+
{
460+
"cell_type": "code",
461+
"execution_count": null,
462+
"id": "c67bdee6-72bf-4786-b270-c7d527c022b9",
463+
"metadata": {},
464+
"outputs": [],
465+
"source": [
466+
"assert job.phase == 'COMPLETED'\n",
467+
"coadd_patches = job.fetch_result().to_table()"
468+
]
469+
},
425470
{
426471
"cell_type": "markdown",
427472
"id": "6609a121-2d12-4bb1-b29e-5b3a9f262501",
428473
"metadata": {},
429474
"source": [
430-
"The `coadd_datasetrefs` returned from the butler include region information for each dataset, stored as a `ConvexPolygon3D` with four vertices defining the sky footprint of each overlapping tract and patch.\n",
431-
"\n",
432-
"Convert these vertices to 2D sky coordinates (RA, Dec) using `geom.SpherePoint`, and use `matplotlib.patches.Polygon` along with `ax.add_patch()` to draw each patch outline. Each tract is plotted with a distinct color and linestyle for visual clarity.\n"
475+
"Use `matplotlib.patches.Polygon` along with `ax.add_patch()` to draw each patch outline. Each tract is plotted with a distinct color and linestyle for visual clarity.\n"
433476
]
434477
},
435478
{
@@ -445,17 +488,21 @@
445488
" vmin=23.5, shading='auto')\n",
446489
"fig.colorbar(mesh, ax=ax, label=\"r-band limiting magnitude (mag)\")\n",
447490
"\n",
448-
"for rec in coadd_datasetrefs:\n",
449-
" vertices = rec.dataId.patch.region.getVertices()\n",
450-
" vertices_deg = []\n",
451-
" for vertex in vertices:\n",
452-
" vertices_deg.append([geom.SpherePoint(vertex).getRa().asDegrees(),\n",
453-
" geom.SpherePoint(vertex).getDec().asDegrees()])\n",
454-
" polygon = Polygon(vertices_deg, closed=True, facecolor='None',\n",
455-
" edgecolor=style_dict[rec.dataId['tract']]['color'],\n",
456-
" linestyle=style_dict[rec.dataId['tract']]['linestyle'],\n",
457-
" linewidth=2)\n",
458-
" ax.add_patch(polygon)\n",
491+
"for tract in tracts:\n",
492+
" s_regions = coadd_patches[coadd_patches['lsst_tract'] == tract]['s_region']\n",
493+
"\n",
494+
" for s_region in s_regions:\n",
495+
" coordinates = np.array(s_region.split()[2:], dtype=float)\n",
496+
" ra = coordinates[0::2]\n",
497+
" ra = (ra + 180) % 360 - 180\n",
498+
" dec = coordinates[1::2]\n",
499+
" vertices_deg = np.vstack([ra, dec]).T\n",
500+
"\n",
501+
" polygon = Polygon(vertices_deg, closed=True, facecolor='None',\n",
502+
" edgecolor=style_dict[tract]['color'],\n",
503+
" linestyle=style_dict[tract]['linestyle'],\n",
504+
" linewidth=2)\n",
505+
" ax.add_patch(polygon)\n",
459506
"\n",
460507
"ax.set_xlim(105.5, 107)\n",
461508
"ax.set_ylim(-11.25, dec_max)\n",
@@ -503,7 +550,8 @@
503550
"del coadd_datasetrefs\n",
504551
"del hspmap_rmaglim, hspmap_rexptime\n",
505552
"del x, y, values_rmaglim, values_rexptime\n",
506-
"del style_dict"
553+
"del style_dict\n",
554+
"del tracts, s_regions, coordinates, ra, dec"
507555
]
508556
},
509557
{

0 commit comments

Comments
 (0)