Skip to content
Merged
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
39 changes: 33 additions & 6 deletions DP2/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: [Data Preview 2](https://dp2.lsst.io/)\\\n",
"Container Size: Large\\\n",
"LSST Science Pipelines version: r30.0.11\\\n",
"Last verified to run: 2026-09-04\\\n",
"Last verified to run: 2026-10-26\\\n",
"Repository: [github.com/lsst/tutorial-notebooks](https://github.com/lsst/tutorial-notebooks)\\\n",
"DOI: [10.11578/rubin/dc.20250909.20](https://doi.org/10.11578/rubin/dc.20250909.20)"
]
Expand Down Expand Up @@ -514,15 +514,25 @@
"Convert the Sersic morphological parameters stored in the `Object` table (the effective Sersic radii in x and y directions, `sersic_reff_x`, `sersic_reff_y`, and the correlation coefficient from the multiband Sersic model fit `sersic_rho` that is related to orientation angle) into the more conventional sersic parameters (axis ratio `ba` defined as the ratio of the semi-minor half-light radius divided to semi-major half-light radius, the position angle `pa`, and the semi-major half-light radius `r_major`). The position angle (`pa`) convention is counter-clockwise relative to the x-axis. In this case, return the `pa` in units of degrees instead of the previous example in radians, to demonstrate its use with `photutils`."
]
},
{
"cell_type": "markdown",
"id": "c3663ec0",
"metadata": {},
"source": [
"> **Warning:** There is a known issue where `sersic_reff_x`, `sersic_reff_y`, `sersic_reff_major`, `sersic_reff_minor`, `exponential_reff_major`, and `exponential_reff_minor` (and their corresponding error columns) in the `Object` table are too small by a factor of $2\\ln(2) \\approx 1.386$, due to a data-entry error in the `multiprofit` code that produced them. The cells below multiply the affected values by this factor to obtain the correct sizes. See the [DP2 known issues documentation](https://dp2.lsst.io/overview/known_issues.html#sersic-and-exponential-model-outputs) for details."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2a340194-b202-413c-b233-014c6d1c3370",
"metadata": {},
"outputs": [],
"source": [
"x = EllipseMajor(Ellipse(sigma_x=tab['sersic_reff_x'][0],\n",
" sigma_y=tab['sersic_reff_y'][0],\n",
"sersic_reff_correction = 2 * np.log(2)\n",
"\n",
"x = EllipseMajor(Ellipse(sigma_x=tab['sersic_reff_x'][0] * sersic_reff_correction,\n",
" sigma_y=tab['sersic_reff_y'][0] * sersic_reff_correction,\n",
" rho=tab['sersic_rho'][0]), degrees=True)\n",
"ba = x.axrat\n",
"pa = x.angle\n",
Expand Down Expand Up @@ -643,15 +653,23 @@
"New in DP2, the `Object` table now contains standard Sersic parameters (semi-major and minor half-light radii, position angle) which can be used in place of the x-y parameters that were needed in DP1. For this section, as a demonstration, replace those calculated in Section 3.3.1 using the x-y Sersic parameters with the ones stored in the `Object` table."
]
},
{
"cell_type": "markdown",
"id": "896f8b3a",
"metadata": {},
"source": [
"> **Warning:** As in Section 3.3.1, `sersic_reff_major` and `sersic_reff_minor` are too small by a factor of $2\\ln(2) \\approx 1.386$; correct for this before use (see the [DP2 known issues documentation](https://dp2.lsst.io/overview/known_issues.html#sersic-and-exponential-model-outputs))."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "05d6600c-66b2-4041-975d-9d247e05cd11",
"metadata": {},
"outputs": [],
"source": [
"r_major = tab['sersic_reff_major']\n",
"r_minor = tab['sersic_reff_minor']\n",
"r_major = tab['sersic_reff_major'] * sersic_reff_correction\n",
"r_minor = tab['sersic_reff_minor'] * sersic_reff_correction\n",
"ba = tab['sersic_reff_minor'] / tab['sersic_reff_major']\n",
"pa = tab['sersic_theta'][0] + 90"
]
Expand Down Expand Up @@ -714,6 +732,14 @@
"Below, generate the model for the best fitting exponential model (`n=1`). Note that since the best fit single Sersic index `sersic_index` `n=2.2` in the `Object` table, fitting with a different Sersic index n=1 results in a more extended light distribution (compared to `n=2.2`, which is more concentrated), and as a result, a different measurement of total flux from that when Sersic index is left as a free parameter."
]
},
{
"cell_type": "markdown",
"id": "59b50905",
"metadata": {},
"source": [
"> **Warning:** As in Section 3.3.1, `exponential_reff_major` is too small by a factor of $2\\ln(2) \\approx 1.386$; correct for this before use (see the [DP2 known issues documentation](https://dp2.lsst.io/overview/known_issues.html#sersic-and-exponential-model-outputs))."
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -723,7 +749,8 @@
"source": [
"ba = tab['exponential_reff_minor'][0]/tab['exponential_reff_major'][0]\n",
"use_beta = (tab['exponential_theta'][0] + 90) * gs.degrees\n",
"sm = gs.Sersic(n=1, half_light_radius=tab['exponential_reff_major'][0] * np.sqrt(ba),\n",
"exp_reff_major = tab['exponential_reff_major'][0] * sersic_reff_correction\n",
"sm = gs.Sersic(n=1, half_light_radius=exp_reff_major * np.sqrt(ba),\n",
" flux=tab['i_exponentialFlux'][0]).shear(q=ba, beta=use_beta)\n",
"\n",
"exp_model = sm.drawImage(nx=img_w, ny=img_h, scale=arcsec_per_pix).array\n",
Expand Down
Loading