Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update galaxy shapes for covariance info #93

Merged
merged 1 commit into from
Jan 10, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@
"metadata": {},
"outputs": [],
"source": [
"err_img = file.err[ymin:ymax, xmin:xmax].value.flatten()"
"err_img = file.err[ymin:ymax, xmin:xmax].flatten()"
]
},
{
Expand Down Expand Up @@ -741,7 +741,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Our fit looks really good. In fact, despite the presence of another bright source in the cutout, `scipy.curve_fit` did a good job of fitting the model to the data. Let's take a quick look at the statistics of the fit residuals:"
"Our fit looks really good. Let's take a quick look at the statistics of the fit residuals:"
]
},
{
Expand Down Expand Up @@ -894,7 +894,37 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Comparing these values with our earlier fit, we find that the median and standard deviation of the residuals of both fits are identical to within four decimal places despite differences in the input and best-fit model parameters. "
"Comparing these values with our earlier fit, we find that the median and standard deviation of the residuals of both fits are identical to within four decimal places despite differences in the input and best-fit model parameters.\n",
"\n",
"From `scipy.optimize.curve_fit()`, we also have the estimated approximate covariance information for each of the fitted parameters. From the `scipy` [documentation](https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.curve_fit.html), we can use that information to compute the 1-$\\sigma$ uncertainties on the fitted parameters:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"perr = np.sqrt(np.diag(pcov))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"where `pcov` is the covariance of the fit (recall that `pout` is the fitted values above). Now we can print the fitted values with the uncertainties:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"labels = ('n', 'hlr', 'flux', 'pa', 'x0', 'y0', 'q')\n",
"\n",
"for i, _ in enumerate(p0):\n",
" print(f'{labels[i]} = {pout[i]:.5f} +/- {perr[i]:.5f}')"
]
},
{
Expand Down
Loading