Package: autogalaxy
Installation Guide|readthedocs|Introduction on Binder|HowToGalaxyThe study of a galaxy’s structure and morphology is at the heart of modern day Astrophysical research.PyAutoGalaxymakes it simple to model galaxies, for example this Hubble Space Telescope imaging of a spiral
galaxy:PyAutoGalaxyalso fits interferometer data from observatories such as ALMA:Getting StartedThe following links are useful for new starters:The PyAutoGalaxy readthedocs, which includesan installation guideandan overview of PyAutoGalaxy’s core features.The introduction Jupyter Notebook on Binder, where you can tryPyAutoGalaxyin a web browser (without installation).The autogalaxy_workspace GitHub repository, which includes example scripts and theHowToGalaxy Jupyter notebook lectureswhich give new users a step-by-step introduction toPyAutoGalaxy.API OverviewGalaxy morphology calculations are performed inPyAutoGalaaxyby building aPlaneobject fromLightProfileandGalaxyobjects. Below, we create a simple galaxy system where a redshift 0.5Galaxywith anSersicLightProfilerepresenting a bulge and anExponentialLightProfilerepresenting a disk.importautogalaxyasagimportautogalaxy.plotasaplt"""
To describe the galaxy emission two-dimensional grids of (y,x) Cartesian
coordinates are used.
"""grid=ag.Grid2D.uniform(shape_native=(50,50),pixel_scales=0.05,# <- Conversion from pixel units to arc-seconds.)"""
The galaxy has an elliptical sersic light profile representing its bulge.
"""bulge=ag.lp.Sersic(centre=(0.0,0.0),ell_comps=ag.convert.ell_comps_from(axis_ratio=0.9,angle=45.0),intensity=1.0,effective_radius=0.6,sersic_index=3.0,)"""
The galaxy also has an elliptical exponential disk
"""disk=ag.lp.Exponential(centre=(0.0,0.0),ell_comps=ag.convert.ell_comps_from(axis_ratio=0.7,angle=30.0),intensity=0.5,effective_radius=1.6,)"""
We combine the above light profiles to compose a galaxy at redshift 1.0.
"""galaxy=ag.Galaxy(redshift=1.0,bulge=bulge,disk=disk)"""
We create a Plane, which in this example has just one galaxy but can
be extended for datasets with many galaxies.
"""plane=ag.Plane(galaxies=[galaxy],)"""
We can use the Grid2D and Plane to perform many calculations, for example
plotting the image of the galaxyed source.
"""plane_plotter=aplt.PlanePlotter(plane=plane,grid=grid)plane_plotter.figures_2d(image=True)WithPyAutoGalaxy, you can begin modeling a galaxy in just a couple of minutes. The example below demonstrates a
simple analysis which fits a galaxy’s light.importautofitasafimportautogalaxyasagimportos"""
Load Imaging data of the strong galaxy from the dataset folder of the workspace.
"""dataset=ag.Imaging.from_fits(data_path="/path/to/dataset/image.fits",noise_map_path="/path/to/dataset/noise_map.fits",psf_path="/path/to/dataset/psf.fits",pixel_scales=0.1,)"""
Create a mask for the data, which we setup as a 3.0" circle.
"""mask=ag.Mask2D.circular(shape_native=dataset.shape_native,pixel_scales=dataset.pixel_scales,radius=3.0)"""
We model the galaxy using an Sersic LightProfile.
"""light_profile=ag.lp.Sersic"""
We next setup this profile as model components whose parameters are free & fitted for
by setting up a Galaxy as a Model.
"""galaxy_model=af.Model(ag.Galaxy,redshift=1.0,light=light_profile)model=af.Collection(galaxy=galaxy_model)"""
We define the non-linear search used to fit the model to the data (in this case, Dynesty).
"""search=af.Nautilus(name="search[example]",n_live=50)"""
We next set up the `Analysis`, which contains the `log likelihood function` that the
non-linear search calls to fit the galaxy model to the data.
"""analysis=ag.AnalysisImaging(dataset=masked_dataset)"""
To perform the model-fit we pass the model and analysis to the search's fit method. This will
output results (e.g., dynesty samples, model parameters, visualization) to hard-disk.
"""result=search.fit(model=model,analysis=analysis)"""
The results contain information on the fit, for example the maximum likelihood
model from the Dynesty parameter space search.
"""print(result.samples.max_log_likelihood())SupportSupport for installation issues, help with galaxy modeling and usingPyAutoGalaxyis available byraising an issue on the GitHub issues page.We also offer support on thePyAutoGalaxySlack channel, where we also provide the
latest updates onPyAutoGalaxy. Slack is invitation-only, so if you’d like to join send
anemailrequesting an invite.