Skip to content

Commit 76f938c

Browse files
authored
Merge pull request #145 from lsst/tickets/SP-3127
SP-3127: update DP1 102 NB to use the IQ data
2 parents 4b07cd5 + 0098e4a commit 76f938c

1 file changed

Lines changed: 184 additions & 15 deletions

File tree

DP2/102_Visit_and_tract_metadata.ipynb

Lines changed: 184 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"Data Release: Data Preview 2\\\n",
2323
"Container Size: Large\\\n",
2424
"LSST Science Pipelines version: r29.2.0\\\n",
25-
"Last verified to run: 2026-04-08\\\n",
25+
"Last verified to run: 2026-05-01\\\n",
2626
"Repository: [github.com/lsst/tutorial-notebooks](https://github.com/lsst/tutorial-notebooks)\\\n",
2727
"DOI: [10.11578/rubin/dc.20250909.20](https://doi.org/10.11578/rubin/dc.20250909.20)"
2828
]
@@ -185,7 +185,9 @@
185185
"* `airmass`: Airmass of the telescope pointing.\n",
186186
"* `expTime`: Exposure time, in seconds.\n",
187187
"* `expMidptMJD`: Time at the middle of the exposure, in modified Julian date (MJD).\n",
188-
"* `obsStartMJD`: Time at the start of the exposure, in MJD."
188+
"* `obsStartMJD`: Time at the start of the exposure, in MJD.\n",
189+
"* `mean_seeing`: Initial estimate of seeing, averaged over all detectors, in arcseconds.\n",
190+
"* `mean_maglim`: Initial estimate of PSF magnitude limit, averaged over all detectors, in mags."
189191
]
190192
},
191193
{
@@ -205,7 +207,7 @@
205207
"metadata": {},
206208
"outputs": [],
207209
"source": [
208-
"visits_table = ascii.read(file_path + 'dp2_visits_table.ecsv')\n",
210+
"visits_table = ascii.read(file_path + 'dp2_visits_table_with_iq.ecsv')\n",
209211
"print('Number of visits: ', len(visits_table))\n",
210212
"visits_table[:5]"
211213
]
@@ -451,12 +453,56 @@
451453
"> **Figure 5:** The binned cumulative distribution of visit airmass by filter (see figure legend). The x-axis has been cropped to show only airmass $\\leq 1.6$."
452454
]
453455
},
456+
{
457+
"cell_type": "markdown",
458+
"id": "827a3b55-a35f-4790-82aa-17881385996f",
459+
"metadata": {},
460+
"source": [
461+
"### 2.5. Initial IQ estimates\n",
462+
"\n",
463+
"Plot the initial estimates of seeing and magnitude limit, averaged over all detectors, per visit per filter."
464+
]
465+
},
466+
{
467+
"cell_type": "code",
468+
"execution_count": null,
469+
"id": "30a948a9-ff53-4382-91c1-0fe3a2dadfa2",
470+
"metadata": {},
471+
"outputs": [],
472+
"source": [
473+
"fig, ax = plt.subplots(1, 2, figsize=(10, 4), sharey=True)\n",
474+
"for f, filt in enumerate(filter_names):\n",
475+
" tx = np.where(visits_table['band'] == filt)[0]\n",
476+
" ax[0].hist(visits_table['mean_seeing'][tx], histtype='step', bins=75,\n",
477+
" cumulative=True, log=True,\n",
478+
" linestyle=filter_linestyles[filt], color=filter_colors[filt], label=filt)\n",
479+
" ax[1].hist(visits_table['mean_maglim'][tx], histtype='step', bins=75,\n",
480+
" cumulative=True, log=True,\n",
481+
" linestyle=filter_linestyles[filt], color=filter_colors[filt], label=filt)\n",
482+
" del tx\n",
483+
"ax[1].legend(loc='upper left', ncol=2)\n",
484+
"ax[0].set_xlabel('Mean Seeing [arcsec]')\n",
485+
"ax[1].set_xlabel('Mean Magnitude Limit [mag]')\n",
486+
"ax[0].set_ylabel('Number of visits per filter')\n",
487+
"plt.subplots_adjust(wspace=0)\n",
488+
"plt.suptitle('Binned cumulative distribution of initial visit image quality estimates, by filter')\n",
489+
"plt.show()"
490+
]
491+
},
492+
{
493+
"cell_type": "markdown",
494+
"id": "3f2140cd-d224-425e-a72f-1c887de1acdf",
495+
"metadata": {},
496+
"source": [
497+
"> **Figure 6:** The binned cumulative distribution of initial estimates for the mean seeing (left) and mean magnitude limit (right) per visit (averaged over all detectors), by filter."
498+
]
499+
},
454500
{
455501
"cell_type": "markdown",
456502
"id": "f6b75f4c-4063-4b58-adbc-e8f8db4ae30e",
457503
"metadata": {},
458504
"source": [
459-
"### 2.5. Sky distribution\n",
505+
"### 2.6. Sky distribution\n",
460506
"\n",
461507
"Use the `healpy` package to print the area of one 19-sided HEALPix.\n",
462508
"It is similar to the LSSTCam field of view (FOV) of 9.6 square degrees."
@@ -506,7 +552,7 @@
506552
"id": "c7147dc2-8c53-4d5a-b9d7-f607ada424b4",
507553
"metadata": {},
508554
"source": [
509-
"> **Figure 6:** A 2D histogram illustrating the distribution of DP2 visits on the sky (for all filters, combined)."
555+
"> **Figure 7:** A 2D histogram illustrating the distribution of DP2 visits on the sky (for all filters, combined)."
510556
]
511557
},
512558
{
@@ -567,7 +613,7 @@
567613
"id": "9a9f5399-336e-4a79-be40-29030fec5833",
568614
"metadata": {},
569615
"source": [
570-
"> **Figure 7:** Similar to Figure 6, but for $g$-band visits only."
616+
"> **Figure 8:** Similar to Figure 6, but for $g$-band visits only."
571617
]
572618
},
573619
{
@@ -610,7 +656,17 @@
610656
"\n",
611657
"* `tractId`: A unique integer identifier; the tract number.\n",
612658
"* `filters_list`: A string of up to six characters containing the filters with a deep coadd image in the tract (e.g., `gi`, `ugr`, `ugrizy`).\n",
613-
"* `vertices_deg`: A list of the sky coordinates for the tract's four corners. For north-up east-left alignment (RA increases left), the order of the corners are: south-east (lower-left), south-west (lower-right), north-west (upper-right), north-east (upper-left)."
659+
"* `vertices_deg`: A list of the sky coordinates for the tract's four corners. For north-up east-left alignment (RA increases left), the order of the corners are: south-east (lower-left), south-west (lower-right), north-west (upper-right), north-east (upper-left).\n",
660+
"* `psf_maglim`: The $5\\sigma$ PSF magnitude limit in the $r$ and $i$ bands, in AB magnitudes.\n",
661+
"* `psf_size`: The PSF characteristic width as computed from the determinant radius, in the $r$ and $i$ bands, in pixels.\n",
662+
"\n",
663+
"The two image quality (IQ) parameters, the magnitude limit and PSF size, are evaluated from the survey property maps at the center of the tract:\n",
664+
"* `deepCoadd_psf_maglim_consolidated_map_weighted_mean`\n",
665+
"* `deepCoadd_psf_size_consolidated_map_weighted_mean`\n",
666+
"\n",
667+
"The `psf_size` is the $\\sigma$ in pixels, and can be approximately converted to arcseconds with a pixel scale of $\\sim0.2$ arcsec/pixel.\n",
668+
"To convert the `psf_size` to a FWHM in arcseconds, use:\n",
669+
"$FWHM = 0.2 \\sigma \\times 2 \\sqrt{2 \\ln(2)} = 2.3548 \\times 0.2 \\sigma$"
614670
]
615671
},
616672
{
@@ -631,7 +687,7 @@
631687
"metadata": {},
632688
"outputs": [],
633689
"source": [
634-
"tracts_table = ascii.read(file_path + 'dp2_tracts_table.ecsv')\n",
690+
"tracts_table = ascii.read(file_path + 'dp2_tracts_table_with_iq.ecsv')\n",
635691
"print('Number of deep coadd tracts: ', len(tracts_table))\n",
636692
"print('Maximum sky area covered by deep coadd tracts: ', int(len(tracts_table) * 1.66**2),\n",
637693
" ' square degrees.')"
@@ -711,12 +767,85 @@
711767
"del tally"
712768
]
713769
},
770+
{
771+
"cell_type": "markdown",
772+
"id": "963a3d2b-b17d-4edb-bfc3-1635df985896",
773+
"metadata": {},
774+
"source": [
775+
"Some tracts are not fully filled by deep coadd images, and have a `nan` value for the PSF magnitude limit or PSF size.\n",
776+
"Print the total number (and fraction) of $r$- and $i$-band tracts that have sufficient data for the PSF magnitude limit to be estimated."
777+
]
778+
},
779+
{
780+
"cell_type": "code",
781+
"execution_count": null,
782+
"id": "55083a39-f0da-4e33-a192-9e4d1e642b73",
783+
"metadata": {},
784+
"outputs": [],
785+
"source": [
786+
"for filt in ['r', 'i']:\n",
787+
" tally = 0\n",
788+
" tally2 = 0\n",
789+
" for f, flist in enumerate(tracts_table['filters_list']):\n",
790+
" if flist.find(filt) >= 0:\n",
791+
" tally += 1\n",
792+
" if np.isfinite(tracts_table['psf_maglim_' + filt][f]):\n",
793+
" tally2 += 1\n",
794+
" print(filt, tally, tally2, np.round(tally2/tally, 2))\n",
795+
"del tally"
796+
]
797+
},
798+
{
799+
"cell_type": "markdown",
800+
"id": "4fd69847-90ba-40f1-bac2-392d3166fb06",
801+
"metadata": {},
802+
"source": [
803+
"### 3.3. IQ parameters\n",
804+
"\n",
805+
"Plot histograms of the tract image quality (IQ) parameters provided in the table."
806+
]
807+
},
808+
{
809+
"cell_type": "code",
810+
"execution_count": null,
811+
"id": "db014376-ccb3-4534-a78d-4a3983289288",
812+
"metadata": {},
813+
"outputs": [],
814+
"source": [
815+
"fig, ax = plt.subplots(1, 2, figsize=(10, 4), sharey=True)\n",
816+
"for f, filt in enumerate(['r', 'i']):\n",
817+
" tx1 = np.where(np.isfinite(tracts_table['psf_maglim_' + filt]))[0]\n",
818+
" tx2 = np.where(np.isfinite(tracts_table['psf_size_' + filt]))[0]\n",
819+
" ax[0].hist(tracts_table['psf_maglim_' + filt][tx1], histtype='step',\n",
820+
" bins=75, cumulative=True, log=True,\n",
821+
" linestyle=filter_linestyles[filt], color=filter_colors[filt], label=filt)\n",
822+
" ax[1].hist(0.2 * 2.3548 * tracts_table['psf_size_' + filt][tx2], histtype='step',\n",
823+
" bins=75, cumulative=True, log=True,\n",
824+
" linestyle=filter_linestyles[filt], color=filter_colors[filt], label=filt)\n",
825+
" del tx1, tx2\n",
826+
"ax[1].legend(loc='upper left', ncol=2)\n",
827+
"ax[0].set_xlabel('PSF Magnitude Limit [mag]')\n",
828+
"ax[1].set_xlabel('PSF FWHM [arcsec]')\n",
829+
"ax[0].set_ylabel('Number of tracts per filter')\n",
830+
"plt.subplots_adjust(wspace=0)\n",
831+
"plt.suptitle('Binned cumulative distribution of tract image quality parameters')\n",
832+
"plt.show()"
833+
]
834+
},
835+
{
836+
"cell_type": "markdown",
837+
"id": "34c9b18d-3a40-40d3-9296-847184865e48",
838+
"metadata": {},
839+
"source": [
840+
"> **Figure 9:** The binned cumulative distribution of tract IQ parameters, the PSF magnitude limit (left) and the PSF FWHM (right) in the $r$- and $i$-filters."
841+
]
842+
},
714843
{
715844
"cell_type": "markdown",
716845
"id": "dfda2aae-4f25-4f99-a4ac-85a4126e64fb",
717846
"metadata": {},
718847
"source": [
719-
"### 3.3. Sky distribution\n",
848+
"### 3.4. Sky distribution\n",
720849
"\n",
721850
"Use the tract vertices to draw one polygon per tract."
722851
]
@@ -745,15 +874,15 @@
745874
"id": "709d29e0-ef46-458e-977b-c3166b6804dd",
746875
"metadata": {},
747876
"source": [
748-
"> **Figure 8:** All of the DP2 tracts for which deep coadd images will exist, in any filter."
877+
"> **Figure 10:** All of the DP2 tracts for which deep coadd images will exist, in any filter."
749878
]
750879
},
751880
{
752881
"cell_type": "markdown",
753882
"id": "f567d17d-18dd-4981-ae5a-841b39e27185",
754883
"metadata": {},
755884
"source": [
756-
"Create a plot that is similar to the one above, but for only tracts that will have a $y$-band deep coadd image."
885+
"Create a plot that is similar to the one above, but for only tracts that will have an $r$-band deep coadd image."
757886
]
758887
},
759888
{
@@ -763,7 +892,7 @@
763892
"metadata": {},
764893
"outputs": [],
765894
"source": [
766-
"show_filter = 'y'\n",
895+
"show_filter = 'r'\n",
767896
"fig, ax = plt.subplots(figsize=(8, 6))\n",
768897
"sp = skyproj.McBrydeSkyproj(ax=ax)\n",
769898
"for i, vertices in enumerate(tracts_table['vertices_deg']):\n",
@@ -784,7 +913,47 @@
784913
"id": "331076de-c131-43a3-b1e7-889185625e10",
785914
"metadata": {},
786915
"source": [
787-
"> **Figure 9:** The DP2 tracts for which $y$-band deep coadd images will exist."
916+
"> **Figure 11:** The DP2 tracts for which $r$-band deep coadd images will exist."
917+
]
918+
},
919+
{
920+
"cell_type": "markdown",
921+
"id": "9df06a00-79f1-4d55-9d47-3aef60528fbe",
922+
"metadata": {},
923+
"source": [
924+
"Create a plot that is similar to the one above, but only for tracts with $r$-band for which the $r$-band magnitude limit is $>23$ mag."
925+
]
926+
},
927+
{
928+
"cell_type": "code",
929+
"execution_count": null,
930+
"id": "1645927e-6e3c-42f0-a61e-1a7cbde2e64b",
931+
"metadata": {},
932+
"outputs": [],
933+
"source": [
934+
"show_filter = 'r'\n",
935+
"fig, ax = plt.subplots(figsize=(8, 6))\n",
936+
"sp = skyproj.McBrydeSkyproj(ax=ax)\n",
937+
"for i, vertices in enumerate(tracts_table['vertices_deg']):\n",
938+
" flist = str(tracts_table['filters_list'][i])\n",
939+
" if flist.find(show_filter) >= 0:\n",
940+
" if (tracts_table['psf_maglim_r'][i] > 23.0):\n",
941+
" ras = vertices.transpose()[0]\n",
942+
" decs = vertices.transpose()[1]\n",
943+
" sp.draw_polygon(ras, decs, edgecolor=filter_colors[show_filter],\n",
944+
" alpha=0.5, linewidth=0.5, facecolor=None)\n",
945+
"sp.ax.set_xlabel(\"Right Ascension\", fontsize=14)\n",
946+
"sp.ax.set_ylabel(\"Declination\", fontsize=14)\n",
947+
"plt.show()\n",
948+
"del sp, show_filter"
949+
]
950+
},
951+
{
952+
"cell_type": "markdown",
953+
"id": "a1d65a2c-4809-4ecc-9e55-1d703b1794d5",
954+
"metadata": {},
955+
"source": [
956+
"> **Figure 12:** The DP2 tracts for which $r$-band deep coadd images will exist, and have a magnitude limit fainter than 23 mag."
788957
]
789958
},
790959
{
@@ -1087,7 +1256,7 @@
10871256
"id": "599638e6-f98f-46cf-88e1-350287fc23e9",
10881257
"metadata": {},
10891258
"source": [
1090-
"> **Figure 10:** A 2D histogram illustrating the distribution of DP2 visits on the sky (for all filters, combined), similar to Figure 6 but plotted in blue-scale. Boxes are drawn to represent each skymap tract that will have at least one patch with a deep coadd image (similar to Figure 8). Overplotted are the coordinates of the three target coordinates (1 as a yellow star; 2 as a green triangle; 3 as a magenta square)."
1259+
"> **Figure 13:** A 2D histogram illustrating the distribution of DP2 visits on the sky (for all filters, combined), similar to Figure 6 but plotted in blue-scale. Boxes are drawn to represent each skymap tract that will have at least one patch with a deep coadd image (similar to Figure 8). Overplotted are the coordinates of the three target coordinates (1 as a yellow star; 2 as a green triangle; 3 as a magenta square)."
10911260
]
10921261
},
10931262
{
@@ -1235,7 +1404,7 @@
12351404
"id": "5676c6ae-313e-406e-9998-d514a4bde4e8",
12361405
"metadata": {},
12371406
"source": [
1238-
"> **Figure 11:** Similar to Figure 10, this plot shows the distribution of DP2 visits (blue-scale), with boxes drawn for DP2 tracts, and with the locations of the DP1 fields marked."
1407+
"> **Figure 14:** Similar to Figure 10, this plot shows the distribution of DP2 visits (blue-scale), with boxes drawn for DP2 tracts, and with the locations of the DP1 fields marked."
12391408
]
12401409
},
12411410
{

0 commit comments

Comments
 (0)