Created
January 25, 2021 21:41
-
-
Save larrybradley/7659125d9f4db22162d4ae7337e548e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"id": "reverse-pittsburgh", | |
"metadata": { | |
"ExecuteTime": { | |
"end_time": "2021-01-25T21:39:02.133481Z", | |
"start_time": "2021-01-25T21:39:01.188986Z" | |
} | |
}, | |
"outputs": [ | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"WARNING: The fit may be unsuccessful; check fit_info['message'] for more information. [astropy.modeling.fitting]\n" | |
] | |
}, | |
{ | |
"data": { | |
"text/plain": [ | |
"<GriddedPSFModel(flux=340.83114543, x_0=235.62417096, y_0=246.30749559)>" | |
] | |
}, | |
"execution_count": 1, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"from astropy.modeling.fitting import LevMarLSQFitter\n", | |
"from astropy.io import fits\n", | |
"from photutils.psf import FittableImageModel\n", | |
"from varun_psfutils import make_models\n", | |
"#from psf_tools.PSFUtils import make_models # this suppresses the fit warning!\n", | |
"\n", | |
"data = fits.getdata('data_cutout.fits')\n", | |
"\n", | |
"psf_model, _ = make_models('PSFSTD_WFC3UV_F555W.fits')\n", | |
"psf_model.flux = 401.348652558488\n", | |
"psf_model.x_0 = 235.9156174534438 \n", | |
"psf_model.y_0 = 247.0110975634186\n", | |
"\n", | |
"yy, xx = np.mgrid[242:253, 231:242]\n", | |
"fitter = LevMarLSQFitter()\n", | |
"fit_psf = fitter(psf_model, xx, yy, data)\n", | |
"fit_psf" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"id": "therapeutic-billy", | |
"metadata": { | |
"ExecuteTime": { | |
"end_time": "2021-01-25T21:39:02.139457Z", | |
"start_time": "2021-01-25T21:39:02.135930Z" | |
} | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"'Number of calls to function has reached maxfev = 100.'" | |
] | |
}, | |
"execution_count": 2, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"fitter.fit_info['message']" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"id": "induced-aside", | |
"metadata": { | |
"ExecuteTime": { | |
"end_time": "2021-01-25T21:39:02.146893Z", | |
"start_time": "2021-01-25T21:39:02.143301Z" | |
} | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"True" | |
] | |
}, | |
"execution_count": 3, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"fitter.fit_info['param_cov'] is None" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "consecutive-thermal", | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.8.7" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 5 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment