Skip to main content

Open-Source Multi Wavelength Galaxy Structure & Morphology

Project description

https://mybinder.org/badge_logo.svg Documentation Status https://github.com/Jammy2211/PyAutoGalaxy/actions/workflows/main.yml/badge.svg https://github.com/Jammy2211/PyAutoBuild/actions/workflows/release.yml/badge.svg https://img.shields.io/badge/code%20style-black-000000.svg https://joss.theoj.org/papers/10.21105/joss.04475/status.svg

Installation Guide | readthedocs | Introduction on Binder | HowToGalaxy

PyAutoGalaxy is software for analysing the morphologies and structures of galaxies:

https://github.com/Jammy2211/PyAutoGalaxy/blob/main/paper/hstcombined.png?raw=true

PyAutoGalaxy also fits interferometer data from observatories such as ALMA:

https://github.com/Jammy2211/PyAutoGalaxy/blob/main/paper/almacombined.png?raw=true

Getting Started

The following links are useful for new starters:

Core Aims

PyAutoGalaxy has three core aims:

  • Model Complexity: Fitting complex galaxy morphology models (e.g. Multi Gaussian Expansion, Shapelets, Ellipse Fitting, Irregular Meshes) that go beyond just simple Sersic fitting (which is supported too!).

  • Data Variety: Support for many data types (e.g. CCD imaging, interferometry, multi-band imaging) which can be fitted independently or simultaneously.

  • Big Data: Scaling automated analysis to extremely large datasets, using tools like an SQL database to build a scalable scientific workflow.

A complete overview of the software’s aims is provided in our Journal of Open Source Software paper.

API Overview

Galaxy morphology calculations are performed in PyAutoGalaaxy by building a Plane object from LightProfile and Galaxy objects. Below, we create a simple galaxy system where a redshift 0.5 Galaxy with an Sersic LightProfile representing a bulge and an Exponential LightProfile representing a disk.

import autogalaxy as ag
import autogalaxy.plot as aplt

"""
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.GalaxiesPlotter(plane=plane, grid=grid)
plane_plotter.figures_2d(image=True)

With PyAutoGalaxy, 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.

import autofit as af
import autogalaxy as ag

import os

"""
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())

Support

Support for installation issues, help with galaxy modeling and using PyAutoGalaxy is available by raising an issue on the GitHub issues page.

We also offer support on the PyAutoGalaxy Slack channel, where we also provide the latest updates on PyAutoGalaxy. Slack is invitation-only, so if you’d like to join send an email requesting an invite.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

autogalaxy-2024.11.13.2.tar.gz (205.6 kB view details)

Uploaded Source

Built Distribution

autogalaxy-2024.11.13.2-py3-none-any.whl (351.7 kB view details)

Uploaded Python 3

File details

Details for the file autogalaxy-2024.11.13.2.tar.gz.

File metadata

  • Download URL: autogalaxy-2024.11.13.2.tar.gz
  • Upload date:
  • Size: 205.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for autogalaxy-2024.11.13.2.tar.gz
Algorithm Hash digest
SHA256 d3c08896cecc0826edfa654410812a780aa568b1d97b47e8238509d6b00fac3f
MD5 6e5568e4754eca648052e40508d4fc72
BLAKE2b-256 5a8f079d7ad004dcc285a10fdd13f8d9b3bccf58f9ab5d63105bed6ef89ebf0a

See more details on using hashes here.

File details

Details for the file autogalaxy-2024.11.13.2-py3-none-any.whl.

File metadata

File hashes

Hashes for autogalaxy-2024.11.13.2-py3-none-any.whl
Algorithm Hash digest
SHA256 15bdfe740b77a5ec1fbc370149d0984815a764efaea998f125e3868c8c388df2
MD5 911b09d90e43511719db823743241e1e
BLAKE2b-256 945cf12a01faaee7c4ad8cb30fcbe407de69f873ec2a7dfe4744615e83e61d80

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page