Skip to content
Merged
Show file tree
Hide file tree
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
120 changes: 87 additions & 33 deletions docs/api/galaxy.rst
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
===============
Galaxy / Tracer
===============

Galaxy / Tracer
---------------

``Galaxy`` and ``Galaxies`` model individual galaxies with light and mass profiles at a
given redshift. ``Tracer`` groups galaxies by redshift into planes and performs
multi-plane gravitational lensing ray-tracing, computing lensed images, convergence,
deflection angles, magnification, critical curves, and caustics.

``MassField`` holds the mass of everything *outside* the modelled system — an external
shear, a mass sheet, an external potential — at its own redshift and with no light of its
own; pass a list of them as ``Tracer(galaxies=..., fields=[field])`` and each is placed in
the plane at its redshift, contributing its mass to every lensing calculation while every
per-galaxy surface still sees galaxies alone. Attaching these components to a ``Galaxy``
instead remains fully supported. For one field, ``Tracer(galaxies=..., fields=field)``
is also accepted; ``tracer.fields`` is always stored as a list.
.. _galaxy-tracer:

Galaxies and ray tracing
========================

Build galaxies from light and mass profiles, then use a ``Tracer`` to calculate how their light is gravitationally lensed. The objects below separate individual galaxies, collections of galaxies and multi-plane ray tracing.

.. _id1:

Galaxies and collections
------------------------

``Galaxy`` holds components at a specified redshift. Component names such as ``bulge``, ``disk`` and ``mass`` let you identify their contributions. ``Galaxies`` evaluates a collection, combining its light or mass quantities as appropriate.

.. currentmodule:: autolens

Expand All @@ -27,35 +21,95 @@ is also accepted; ``tracer.fields`` is always stored as a list.

Galaxy
Galaxies
MassField

Use ``Tracer`` for lensing between redshift planes; a ``Galaxies`` collection alone does not perform multi-plane ray tracing.

Ray tracing
-----------

``Tracer`` groups galaxies into planes by redshift and propagates coordinates through those planes using the lensing cosmology. It provides lensed images and lensing quantities including deflections, convergence, magnification, critical curves and caustics.

.. code-block:: python

import autolens as al

lens = al.Galaxy(
redshift=0.5,
mass=al.mp.Isothermal(einstein_radius=1.0),
)
source = al.Galaxy(
redshift=1.0,
bulge=al.lp.Sersic(intensity=1.0, effective_radius=0.2),
)
tracer = al.Tracer(galaxies=[lens, source])

This constructs a model; it does not fit data. The `ray-tracing guide <https://github.com/PyAutoLabs/autolens_workspace/blob/main/notebooks/guides/tracer.ipynb>`_ shows how to evaluate and plot it.

.. currentmodule:: autolens

.. autosummary::
:toctree: _autosummary
:template: custom-class-template.rst
:recursive:

Tracer

To treat the redshift of a galaxy as a free parameter in a model, the ``Redshift`` object must
be used.
External mass fields
--------------------

``MassField`` holds mass components at their own redshift without assigning them galaxy light. Use it for environmental contributions such as external shear, a mass sheet or an external potential. It also accepts other mass profiles when they represent the environment.

This is because **PyAutoFit** (which handles model-fitting), requires all parameters to be a Python class.
Pass fields through ``Tracer(galaxies=..., fields=[field])``. Each field is placed at its redshift and contributes to the lensing calculations, while remaining separate from the galaxies. A single ``fields=field`` is also accepted; ``tracer.fields`` is stored as a list.

The ``Redshift`` object does not need to be used for general **PyAutoGalaxy** use.
Attaching external mass components directly to a ``Galaxy`` remains supported.

.. currentmodule:: autolens

.. autosummary::
:toctree: _autosummary
:template: custom-class-template.rst
:recursive:

Redshift
MassField

Fixed and fitted redshifts
--------------------------

For a known redshift, pass a number directly to ``Galaxy(redshift=...)``. When the redshift itself is to be inferred, ``Redshift`` provides a model component whose value can be assigned a prior.

.. code-block:: python

Galaxy Catalogues (CSV)
-----------------------
import autofit as af

Load many galaxies from a ``y, x, luminosity`` CSV catalogue — the input format of the
scaling-relation galaxy tier used at multi-galaxy, group and cluster scale (see the
``multi_galaxy``, ``group`` and ``cluster`` packages of the ``autolens_workspace``).
``galaxy_table_from_csv`` reads the catalogue; the two ``*_from_csv_tables`` functions
build instances or model components from it.
redshift = af.Model(al.Redshift)
redshift.redshift = af.UniformPrior(lower_limit=0.8, upper_limit=1.2)
galaxy_model = af.Model(al.Galaxy, redshift=redshift)

The prior limits are illustrative, not a default recommendation. For lensing, choose redshifts and priors consistent with the intended ordering of lens and source planes. Add the light or mass components required by your model before fitting.

.. currentmodule:: autolens

.. autosummary::
:toctree: _autosummary
:template: custom-class-template.rst
:recursive:

Redshift

.. _galaxy-catalogues-csv:

Galaxy catalogues
-----------------

Load catalogue entries with ``y``, ``x`` and ``luminosity`` columns to construct populations of galaxies. ``galaxy_table_from_csv`` reads a table; ``galaxies_from_csv_tables`` and ``galaxy_af_models_from_csv_tables`` build galaxy instances or model components from the supplied tables.

The `scaling-relation examples <https://github.com/PyAutoLabs/autolens_workspace/blob/main/notebooks/imaging/features/scaling_relation/start_here.ipynb>`_ explain how measured luminosities can constrain the mass model of a companion population. The `multi-galaxy <https://github.com/PyAutoLabs/autolens_workspace/blob/main/notebooks/multi_galaxy/start_here.ipynb>`_, `group <https://github.com/PyAutoLabs/autolens_workspace/blob/main/notebooks/group/start_here.ipynb>`_ and `cluster <https://github.com/PyAutoLabs/autolens_workspace/blob/main/notebooks/cluster/start_here.ipynb>`_ introductions show the different modelling workflows.

.. currentmodule:: autolens

.. autosummary::
:toctree: _autosummary

galaxy_table_from_csv
galaxies_from_csv_tables
galaxy_af_models_from_csv_tables
galaxy_af_models_from_csv_tables
84 changes: 61 additions & 23 deletions docs/api/pixelization.rst
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
=============
Pixelizations
=============

Pixelization
------------
Reconstruct the extended background source on a mesh when a small set of analytic light profiles cannot describe its structure. The lens model maps image-plane coordinates to the source plane, where the reconstruction is defined.

The reconstruction values are solved by a linear inversion for each proposed model. Regularization constrains their variation, balancing the fit to the data against the smoothness of the reconstruction.

.. _pixelization:

Build a pixelization
--------------------

A ``Pixelization`` combines a ``mesh`` with a ``regularization`` scheme. This example constructs an adaptive rectangular mesh with constant regularization; it does not run a fit.

Groups all of the individual components used to reconstruct a galaxy via a
pixelization (an ``ImageMesh``, ``Mesh`` and ``Regularization``)
.. code-block:: python

The ``Pixelization`` API documentation provides a comprehensive description of how pixelizaiton objects work and
their associated API.
import autolens as al

**It is recommended you read this documentation before using pixelizations**.
pixelization = al.Pixelization(
mesh=al.mesh.RectangularBilinearAdaptDensity(shape=(20, 20)),
regularization=al.reg.Constant(coefficient=1.0),
)

The shape and regularization coefficient are illustrative choices. Their suitable values depend on the data and model. Attach the pixelization to the source galaxy and use the `worked pixelization examples <https://github.com/PyAutoLabs/autolens_workspace/blob/main/notebooks/imaging/features/pixelization/start_here.ipynb>`_ for the complete fitting workflow.

The detailed ``Pixelization`` reference below explains the coordinate mappings, masking and image-plane versus source-plane reconstruction with diagrams.

.. currentmodule:: autolens

Expand All @@ -22,22 +34,18 @@ their associated API.

Pixelization

Image Mesh [ag.image_mesh]
--------------------------
.. _mesh-ag-mesh:

.. currentmodule:: autoarray.inversion.mesh.image_mesh
Choose a mesh
-------------

.. autosummary::
:toctree: _autosummary
:template: custom-class-template.rst
:recursive:
Access these classes through ``al.mesh``. The generated pages show their implementation in **PyAutoArray**, which supplies the mesh classes to both libraries.

Overlay
Hilbert
KMeans
- **Density-adaptive rectangular meshes** allocate resolution according to the spatial density of the coordinates used for reconstruction, after ray tracing in a lens model.
- **Image-adaptive rectangular meshes** use an adapt image to concentrate resolution according to the estimated light distribution. Supply the adapt-image information required by the fitting workflow.
- **Delaunay** uses a triangular mesh and barycentric interpolation between its vertices. Its adaptive setup requires an image-plane mesh grid.

Mesh [ag.mesh]
--------------
The Bilinear and RTU rectangular families use different coordinate transforms. RTU uses a smooth kernel-based transform; Bilinear uses ranks of the sampled coordinates. This distinction matters for gradient-based fitting. Consult the class-specific gradient and over-sampling notes before choosing a mesh for a JAX analysis.

.. currentmodule:: autoarray.inversion.mesh.mesh

Expand All @@ -52,8 +60,16 @@ Mesh [ag.mesh]
RectangularRTUAdaptImage
Delaunay

Regularization [ag.reg]
-----------------------
.. _regularization-ag-reg:

Choose regularization
---------------------

Access these classes through ``al.reg``. Regularization controls how strongly the reconstruction is smoothed; it does not set the mesh resolution.

``Constant`` applies a shared coefficient, while adaptive schemes vary the smoothing using estimated signal. The ``Split`` variants use a different construction of the regularization constraints. Choose a scheme compatible with the mesh, as described in the detailed references.

``AdaptPower`` and ``AdaptSplitPower`` expose a coefficient-power convention that differs from the legacy adaptive classes. Coefficients and their priors are therefore not interchangeable across these families; check the definitions when changing scheme.

.. currentmodule:: autoarray.inversion.regularization

Expand All @@ -69,9 +85,29 @@ Regularization [ag.reg]
AdaptPower
AdaptSplitPower

.. _image-mesh-ag-image-mesh:

Image-mesh utilities
--------------------

These lower-level utilities place sampling points in the image plane for workflows that require an image-plane mesh. They are not a third argument to ``Pixelization``: its constructor takes ``mesh`` and ``regularization``. Follow the selected mesh’s setup and adapt-image requirements.

.. currentmodule:: autoarray.inversion.mesh.image_mesh

.. autosummary::
:toctree: _autosummary
:template: custom-class-template.rst
:recursive:

Overlay
Hilbert
KMeans

Settings
--------

``Settings`` controls numerical choices used when constructing and solving an inversion. Keep the defaults unless your analysis needs a particular option, and consult the parameter descriptions before changing them.

.. currentmodule:: autolens

.. autosummary::
Expand All @@ -84,11 +120,13 @@ Settings
Mapper
------

A ``Mapper`` describes how reconstruction values contribute at the sampled coordinates. For lensing, those coordinates have been traced to the source plane. Mappers are normally built by the fitting machinery; their reference is useful when inspecting mappings or developing a custom calculation.

.. currentmodule:: autolens

.. autosummary::
:toctree: _autosummary
:template: custom-class-template.rst
:recursive:

Mapper
Mapper
Loading
Loading