Skip to content

Commit 32ba7df

Browse files
update deblender nb Fred comments
1 parent 622aeae commit 32ba7df

1 file changed

Lines changed: 6 additions & 137 deletions

File tree

DP1/200_Data_Products/206_Deblender_Products/206_2_Deblender_Footprints.ipynb

Lines changed: 6 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,9 @@
697697
"id": "feb57f86-ccdd-4d84-8546-1e48f644654c",
698698
"metadata": {},
699699
"source": [
700-
"Load the subset of the image that overlaps with the blend, then use the `blend_data` and the `observation` to create a full `Blend`. All of the model information is the same as the information from the `Blend` that we created earlier. Here, attach real `Observation` data as opposed to an empty `Observation` (as was done in Section 3.2). Notice that the **observed_bands** are passed here, not the **display_bands**, as these bands must match the order of the bands in the `blend`."
700+
"Load the subset of the image that overlaps with the blend, then use the `blend_data` and the `observation` to create a full `Blend`. All of the model information is the same as the information from the `Blend` that we created earlier. Here, attach real `Observation` data as opposed to an empty `Observation` (as was done in Section 3.2). Notice that the **observed_bands** are passed here, not the **display_bands**, as these bands must match the order of the bands in the `blend`.\n",
701+
"\n",
702+
"Model residuals compared to the observations are of interest for exploring how well the blend model matches the data. To do this, first load a multiband exposure as the input observation. Use the patch and tract to reconstruct the multiband deep_coadd for this blend.\n"
701703
]
702704
},
703705
{
@@ -761,7 +763,7 @@
761763
"\n",
762764
"To normalize the image use the Lupton red green blue (RGB) AsinhMapping, which preserves the observed colors.\n",
763765
"\n",
764-
"Note: You'll notice that the colors match the processed color order, not the correct band order. In the future passing `blend[display_bands]` should display everything in the correct order."
766+
"Note: You'll notice that the colors match the processed color order, not the correct band order. In the future passing `blend[display_bands]` should display everything in the correct order.\n"
765767
]
766768
},
767769
{
@@ -821,7 +823,7 @@
821823
"id": "17e2781f-5f28-4e44-8a6b-550d320c2941",
822824
"metadata": {},
823825
"source": [
824-
"> Figure 4: Visualization of the individual deblended sources (top to bottom show ID 0 to 8). For each source, left panel shows the PSF-deconvolved model footprint (where the color scale corresponds to the weighted RGB color), middle panel shows the observation of the blend with the source identified by a white box, and right panel shows the flux in each band, from u to y in order of wavelength as defined in Section 3.2."
826+
"> Figure 4: Visualization of the individual deblended sources (top to bottom show ID 0 to 8). For each source, left panel shows the PSF-deconvolved model footprint (where the color scale corresponds to the weighted RGB color), middle panel shows the observation of the blend with the source identified by a white box, and right panel shows the flux in each band, from u to y in order of wavelength as defined in Section 3.2. TBD IF THIS WAVELENGTH STATEMENT IS TRUE?"
825827
]
826828
},
827829
{
@@ -952,140 +954,7 @@
952954
"id": "cb5c74a8-b1cb-4e89-9ec3-182bbe880900",
953955
"metadata": {},
954956
"source": [
955-
"> Figure 5:"
956-
]
957-
},
958-
{
959-
"cell_type": "markdown",
960-
"id": "711aaf6f-500d-4215-a6f8-bce00807c878",
961-
"metadata": {},
962-
"source": [
963-
"FRED DELETED EVERYTHING BELOW THIS:\n",
964-
"\n",
965-
"### 3.3 Blend Model Residuals\n",
966-
"\n",
967-
"Model residuals compared to the observations are of interest for exploring how well the blend model matches the data. To do this, first load a multiband exposure as the input observation. \n",
968-
"\n",
969-
"The cell below prepares to build the multiband exposure by first finding the patch and tract that covers the blend of interest."
970-
]
971-
},
972-
{
973-
"cell_type": "code",
974-
"execution_count": null,
975-
"id": "8dafe145-8091-422a-9071-263ea0c68e7c",
976-
"metadata": {},
977-
"outputs": [],
978-
"source": [
979-
"skymap = butler.get(\"skyMap\")\n",
980-
"radec = geom.SpherePoint(children['coord_ra'][0], children['coord_dec'][0], geom.degrees)\n",
981-
"\n",
982-
"tractInfo = skymap.findTract(radec)\n",
983-
"patchInfo = tractInfo.findPatch(radec)\n",
984-
"patch = tractInfo.getSequentialPatchIndex(patchInfo)\n",
985-
"tract = tractInfo.getId()\n"
986-
]
987-
},
988-
{
989-
"cell_type": "markdown",
990-
"id": "f2049e77-abd7-40c7-89de-4df0c4a16a0c",
991-
"metadata": {},
992-
"source": [
993-
"Next, use the patch and tract to reconstruct the multiband deep_coadd for this blend, using the bands that were observed."
994-
]
995-
},
996-
{
997-
"cell_type": "code",
998-
"execution_count": null,
999-
"id": "72de1035-7f29-469c-9650-2a62e9f82ecf",
1000-
"metadata": {},
1001-
"outputs": [],
1002-
"source": [
1003-
"mCoadd = MultibandExposure.fromButler(butler, display_bands,\n",
1004-
" \"deep_coadd\", tract=tract, patch=patch)\n",
1005-
"bbox = sl.Box(blend_data.shape, blend_data.origin)\n",
1006-
"bbox = mes.utils.scarletBoxToBBox(bbox)\n",
1007-
"\n",
1008-
"observation = mes.utils.buildObservation(\n",
1009-
" modelPsf=model_psf,\n",
1010-
" psfCenter=bbox.getCenter(),\n",
1011-
" mExposure=mCoadd[:, bbox],\n",
1012-
")\n",
1013-
"\n",
1014-
"blend = blend_data.to_blend(observation)\n"
1015-
]
1016-
},
1017-
{
1018-
"cell_type": "markdown",
1019-
"id": "5f16b7ba-1b0b-47e3-a207-ac4d334fa64f",
1020-
"metadata": {},
1021-
"source": [
1022-
"Then, display the scene. The function scarlet `show_scene` will include the model footprints, the model rendered (i.e. convolved with the PSF), the locations on the observed multiband image, and residuals between the real image and the model.\n",
1023-
"\n",
1024-
"To normalize the image use the Lupton red green blue (RGB) `AsinhMapping`, which preserves the observed colors. "
1025-
]
1026-
},
1027-
{
1028-
"cell_type": "code",
1029-
"execution_count": null,
1030-
"id": "4ad78ea8-51e4-4956-94c4-7e02a4c5de2d",
1031-
"metadata": {},
1032-
"outputs": [],
1033-
"source": [
1034-
"norm = sl.display.AsinhMapping(minimum=0, stretch=1, Q=10)\n",
1035-
"\n",
1036-
"sl.display.show_scene(\n",
1037-
" blend,\n",
1038-
" norm=norm,\n",
1039-
" show_model=True,\n",
1040-
" show_rendered=True,\n",
1041-
" show_observed=True,\n",
1042-
" show_residual=True,\n",
1043-
" linear=False,\n",
1044-
" add_boxes=True,\n",
1045-
" add_labels=True,\n",
1046-
" figsize=(10, 7),\n",
1047-
")\n",
1048-
"\n",
1049-
"plt.show()"
1050-
]
1051-
},
1052-
{
1053-
"cell_type": "markdown",
1054-
"id": "3f5800d3-b018-4685-8555-fcf3e696c16a",
1055-
"metadata": {},
1056-
"source": [
1057-
"> Figure 3: Visualization of the model generated by Scarlet Lite, with x and y axes indicating pixel number from the patch/tract. The panels show the blend model (not PSF-convolved; top left), the blend model rendered (PSF-convolved; top right), the observation (bottom left) and the residual image (observation - model rendered; bottom right). All deblended sources are identified with white boxes and a number indicating its ID within the set of deblended objects."
1058-
]
1059-
},
1060-
{
1061-
"cell_type": "markdown",
1062-
"id": "79111d63-105f-408a-ab49-3118c67b2096",
1063-
"metadata": {},
1064-
"source": [
1065-
"Finally, use the `show_sources` function to display each individual deblended object's model (left), its location in the image (middle), and its spectral energy distribution (right)."
1066-
]
1067-
},
1068-
{
1069-
"cell_type": "code",
1070-
"execution_count": null,
1071-
"id": "d0ced1f4-3b6c-4bc6-a2dc-80018c3f15f4",
1072-
"metadata": {},
1073-
"outputs": [],
1074-
"source": [
1075-
"sl.display.show_sources(blend,\n",
1076-
" norm=norm,\n",
1077-
" show_observed=True,\n",
1078-
" add_boxes=True\n",
1079-
" )\n",
1080-
"plt.show()"
1081-
]
1082-
},
1083-
{
1084-
"cell_type": "markdown",
1085-
"id": "895b605f-c964-4dbe-99a3-bdf2bdcec2cc",
1086-
"metadata": {},
1087-
"source": [
1088-
"> Figure 4: Visualization of the individual deblended sources (top to bottom show ID 0 to 8). For each source, left panel shows the PSF-deconvolved model footprint (where the color scale corresponds to the weighted RGB color), middle panel shows the observation of the blend with the source identified by a white box, and right panel shows the flux in each band, from u to y in order of wavelength as defined in Section 3.2."
957+
"> Figure 5: Visualization of deblended source 1. Left panel shows the PSF-deconvolved model footprint (where the color scale corresponds to the weighted RGB color), middle panel shows the convolution of the scarlet model with the difference kernel and right panel shows the flux-redistributed model that the science pipelines use for measurements."
1089958
]
1090959
}
1091960
],

0 commit comments

Comments
 (0)