Skip to content

Commit 622aeae

Browse files
update deblender nb Fred comments
1 parent 097fa69 commit 622aeae

1 file changed

Lines changed: 53 additions & 28 deletions

File tree

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

Lines changed: 53 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -829,11 +829,9 @@
829829
"id": "e5d82724-fbd0-47f7-8be0-057d806f09ab",
830830
"metadata": {},
831831
"source": [
832-
"## 5. Analyzing data for our source\n",
832+
"## 5. Analyzing a single object\n",
833833
"\n",
834-
"### 5.1 Matching the source\n",
835-
"\n",
836-
"Recall that we began with an object located at a given RA and DEC and stored it's source ID. We now iterate over the blend models until we find the source with the same **objectId**."
834+
"Individual objects can be inspected. Here, select the second brightest object in the blend (listed as Source 1 in the output in Section 4.1) and access its objectId."
837835
]
838836
},
839837
{
@@ -843,10 +841,8 @@
843841
"metadata": {},
844842
"outputs": [],
845843
"source": [
846-
"for sidx, source in enumerate(blend.sources):\n",
847-
" if source.record_id == sid:\n",
848-
" break\n",
849-
"print(f\"Selected source is at index {sidx}\")"
844+
"object1 = blend.sources[1]\n",
845+
"print(object1.record_id)\n"
850846
]
851847
},
852848
{
@@ -856,7 +852,7 @@
856852
"source": [
857853
"### 5.2 Creating the flux re-distributed models\n",
858854
"\n",
859-
"In the science pipelines measurements are not made on the scarlet models directly. Imperfections in the PSF measurement and deviations of bright galaxies from a simple two-component monotonic morphology solution (see Melchior paper cited above) result in improper measurements. Instead we perform a deblending algorithm based on the SDSS deblender, where we use the scarlet models as templates and re-distribute the flux from the input image based on the ratio of values for overlapping templates in an image."
855+
"In the LSST science pipelines, measurements are not made on the scarlet models directly. Imperfections in the PSF measurement and deviations of bright galaxies from a simple two-component monotonic morphology solution (see Melchior paper cited above) result in improper measurements. THIS STATEMENT TBD: Instead, a deblending algorithm based on the SDSS deblender is employed, using the scarlet models as templates, and flux is re-distributed from the input image based on the ratio of values for overlapping templates in an image."
860856
]
861857
},
862858
{
@@ -876,10 +872,47 @@
876872
"source": [
877873
"### 5.3 Display the source model\n",
878874
"\n",
879-
"We now view the three different models for the source:\n",
880-
"- The deconvolved scarlet model\n",
881-
"- The convolution of the scarlet model with the difference kernel\n",
882-
"- The flux-redistributed model that the science pipelines use for measurement"
875+
"Three different models for the object are available for inspection. 1) The deconvolved scarlet model; 2) the convolution of the scarlet model with the difference kernel; and 3) the flux-redistributed model that the science pipelines use for measurement. The section demonstrates how to plot these three different models for source 1 in the blend.\n",
876+
"\n",
877+
"First, extract the deconvolved model from the object. The output is a Scarlet Lite image."
878+
]
879+
},
880+
{
881+
"cell_type": "code",
882+
"execution_count": null,
883+
"id": "da188ade-30ce-4f85-a55a-e001dabb67e9",
884+
"metadata": {},
885+
"outputs": [],
886+
"source": [
887+
"source_model = object1.get_model()"
888+
]
889+
},
890+
{
891+
"cell_type": "markdown",
892+
"id": "04ecbf7d-6039-49e2-ad8c-848f911d4817",
893+
"metadata": {},
894+
"source": [
895+
"Next, project the model into a box large enough to fit the convolved model."
896+
]
897+
},
898+
{
899+
"cell_type": "code",
900+
"execution_count": null,
901+
"id": "e0be3f3d-c6f8-4238-8e19-0a0b16aebf74",
902+
"metadata": {},
903+
"outputs": [],
904+
"source": [
905+
"psf_radius = int((np.max(blend.observation.psfs.shape)+1)//2)\n",
906+
"enlarged_box = source_model.bbox.grow(psf_radius)\n",
907+
"convolved_model = source_model.copy().project(bbox=enlarged_box)"
908+
]
909+
},
910+
{
911+
"cell_type": "markdown",
912+
"id": "747da137-5b5d-499d-b828-4e102b81c6ac",
913+
"metadata": {},
914+
"source": [
915+
"Finally, plot the three models for the object for inspection."
883916
]
884917
},
885918
{
@@ -889,33 +922,25 @@
889922
"metadata": {},
890923
"outputs": [],
891924
"source": [
892-
"# Extract the deconvovled model from the source (a scarlet lite Image)\n",
893-
"source_model = source.get_model()\n",
894-
"\n",
895925
"fig, ax = plt.subplots(1, 3, figsize=(15, 5))\n",
896926
"\n",
897927
"# Display the deconvolved model\n",
898-
"extent = scl.display.get_extent(source.bbox)\n",
899-
"rgb = scl.display.img_to_rgb(source_model[display_bands], norm=norm)\n",
928+
"extent = sl.display.get_extent(object1.bbox)\n",
929+
"rgb = sl.display.img_to_rgb(source_model[display_bands], norm=norm)\n",
900930
"ax[0].imshow(rgb, origin='lower', extent=extent)\n",
901931
"ax[0].set_title(\"Deconvolved Model\")\n",
902932
"\n",
903-
"# Project the model into a box large enough to fit the convolved model\n",
904-
"psf_radius = int((np.max(blend.observation.psfs.shape)+1)//2)\n",
905-
"enlarged_box = source_model.bbox.grow(psf_radius)\n",
906-
"convolved_model = source_model.copy().project(bbox=enlarged_box)\n",
907-
"\n",
908933
"# Convolve the model with the difference kernel\n",
909934
"convolved_model = blend.observation.convolve(convolved_model)\n",
910-
"extent = scl.display.get_extent(enlarged_box)\n",
911-
"rgb = scl.display.img_to_rgb(convolved_model[display_bands], norm=norm)\n",
935+
"extent = sl.display.get_extent(enlarged_box)\n",
936+
"rgb = sl.display.img_to_rgb(convolved_model[display_bands], norm=norm)\n",
912937
"ax[1].imshow(rgb, origin='lower', extent=extent)\n",
913938
"ax[1].set_title(\"Convolved Model\")\n",
914939
"\n",
915940
"# Display the flux-weighted image\n",
916-
"flux_model = source.flux_weighted_image\n",
917-
"extent = scl.display.get_extent(flux_model.bbox)\n",
918-
"rgb = scl.display.img_to_rgb(flux_model[display_bands], norm=norm)\n",
941+
"flux_model = object1.flux_weighted_image\n",
942+
"extent = sl.display.get_extent(flux_model.bbox)\n",
943+
"rgb = sl.display.img_to_rgb(flux_model[display_bands], norm=norm)\n",
919944
"ax[2].imshow(rgb, origin='lower', extent=extent)\n",
920945
"ax[2].set_title(\"Flux Re-distributed Model\")\n",
921946
"\n",

0 commit comments

Comments
 (0)