Skip to content

Commit 47aba72

Browse files
Jammy2211claude
authored andcommitted
docs(util): add module-level docstrings to util package
Add module-level docstrings to error_util.py (quantile error estimation for 1D profiles and 2D ellipses), shear_field.py (weak-lensing shear field data structures and their convention), and mock/mock_cosmology.py (explaining its role as a lightweight test stand-in for LensingCosmology). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent d99d74b commit 47aba72

3 files changed

Lines changed: 55 additions & 2 deletions

File tree

autogalaxy/util/error_util.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
"""
2+
Utility functions for computing posterior error estimates on 1D profiles and 2D ellipses.
3+
4+
These helpers operate on lists of sampled quantities (e.g. 1D light-profile intensity
5+
curves or 2D isophote coordinate arrays drawn from a ``PyAutoFit`` posterior PDF) and
6+
return the median value together with a lower/upper confidence interval computed from
7+
user-specified quantiles.
8+
9+
Key functions
10+
-------------
11+
- ``value_median_and_error_region_via_quantile`` — scalar median + credible interval.
12+
- ``profile_1d_median_and_error_region_via_quantile`` — per-radial-bin median + interval
13+
for 1D profiles (e.g. a convergence or surface-brightness radial profile).
14+
- ``quantile_profile_1d`` — low-level per-bin quantile computation, adapted from
15+
``corner.py``.
16+
- ``ellipse_median_and_error_region_via_quantile`` — Cartesian median + interval for 2D
17+
isophote coordinate arrays.
18+
- ``ellipse_median_and_error_region_in_polar`` — same but computed in polar coordinates
19+
so that the confidence region is expressed radially rather than in (y, x), which is
20+
more robust for highly elongated isophotes.
21+
"""
122
import numpy as np
223

324
from autofit.non_linear.samples.pdf import quantile

autogalaxy/util/mock/mock_cosmology.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1+
"""
2+
Mock cosmology object for use in unit tests.
3+
4+
``MockCosmology`` implements the same interface as the real ``LensingCosmology`` class
5+
(``autogalaxy/cosmology/model.py``) but returns hard-coded constant values rather than
6+
calling ``astropy.cosmology``. This makes unit tests fast and free of external
7+
dependencies while still exercising code paths that accept a cosmology argument.
8+
9+
The ``Value`` helper wraps a scalar so that ``.to(unit)`` calls (which real astropy
10+
``Quantity`` objects support) are accepted without error.
11+
"""
112
import math
213
import numpy as np
314

4-
# Mock Cosmology #
5-
615

716
class Value:
817
def __init__(self, value):

autogalaxy/util/shear_field.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
"""
2+
Weak-lensing shear field data structures.
3+
4+
This module extends **PyAutoArray**'s vector-field classes with properties specific to
5+
weak gravitational lensing. A *shear field* is a set of (γ₂, γ₁) complex shear
6+
components stored on a 2D grid; each vector encodes the shape distortion induced on a
7+
background source galaxy by the intervening mass distribution.
8+
9+
Convention
10+
----------
11+
The shear components are stored as ``[γ₂, γ₁]`` (``[:, 0]`` is γ₂, ``[:, 1]`` is γ₁),
12+
following the standard lensing sign convention where the position angle φ is measured
13+
counter-clockwise from the positive x-axis.
14+
15+
Two concrete classes are provided:
16+
17+
- ``ShearYX2D`` — regular grid variant (inherits ``aa.VectorYX2D``).
18+
- ``ShearYX2DIrregular`` — irregular grid variant (inherits ``aa.VectorYX2DIrregular``).
19+
20+
Both classes inherit the shared mixin ``AbstractShearField`` which provides derived
21+
quantities: ellipticities, semi-major/minor axes, position angles (``phis``), and
22+
``matplotlib`` ellipse patches for visualization.
23+
"""
124
import logging
225
import numpy as np
326
import typing

0 commit comments

Comments
 (0)