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
47 changes: 46 additions & 1 deletion GALLERY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<!-- Generated by gallery/gallery_build.py from scripts/<domain>/images/. Do not edit by hand: rerun `bash gallery/gallery_run.sh --all`. -->

Rendered with PyAutoLens `2026.8.17.1` · 97 figures.
Rendered with PyAutoLens `2026.8.17.1` · 106 figures.

Most figures are outputs that the PyAutoLens visualizers (`VisualizerImaging`, `VisualizerInterferometer`, `VisualizerPoint`, `VisualizerWeak`) write to a model-fit's `image/` folder. Pandora shows 24 observed images across seven families with source-plane diagnostics from a fixed starting model. For the Simple cluster, the first point source is offset by 0.003 arcsec in y. See [README.md](README.md) for how to improve one.

Expand All @@ -13,6 +13,9 @@ Most figures are outputs that the PyAutoLens visualizers (`VisualizerImaging`, `
- [top level](#cluster--visualization--top-level)
- [point_0/](#cluster--visualization--point_0)
- [point_1/](#cluster--visualization--point_1)
- [cluster_macs_j0416](#cluster_macs_j0416)
- [visualization](#cluster_macs_j0416--visualization) (9 figures)
- [top level](#cluster_macs_j0416--visualization--top-level)
- [cluster_pandora](#cluster_pandora)
- [visualization](#cluster_pandora--visualization) (11 figures)
- [top level](#cluster_pandora--visualization--top-level)
Expand Down Expand Up @@ -141,6 +144,48 @@ Most figures are outputs that the PyAutoLens visualizers (`VisualizerImaging`, `

![point_solver](scripts/cluster/images/visualization/point_1/point_solver.png)

## cluster_macs_j0416

### cluster_macs_j0416 / visualization

#### cluster_macs_j0416 / visualization / top level

##### 210.4c_zoom

![210.4c_zoom](scripts/cluster_macs_j0416/images/visualization/210.4c_zoom.png)

##### all_back_traced_images

![all_back_traced_images](scripts/cluster_macs_j0416/images/visualization/all_back_traced_images.png)

##### overview

![overview](scripts/cluster_macs_j0416/images/visualization/overview.png)

##### published_101

![published_101](scripts/cluster_macs_j0416/images/visualization/published_101.png)

##### published_14.1

![published_14.1](scripts/cluster_macs_j0416/images/visualization/published_14.1.png)

##### ranking

![ranking](scripts/cluster_macs_j0416/images/visualization/ranking.png)

##### source_101

![source_101](scripts/cluster_macs_j0416/images/visualization/source_101.png)

##### source_14.1

![source_14.1](scripts/cluster_macs_j0416/images/visualization/source_14.1.png)

##### source_210.4

![source_210.4](scripts/cluster_macs_j0416/images/visualization/source_210.4.png)

## cluster_pandora

### cluster_pandora / visualization
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ mirroring `autolens_workspace` (a variant gets its own folder):
| `group` | `visualization.py` | `dataset.png` + `fit.png` |
| `cluster` | `visualization.py` | Combined cluster figures and per-source figures, including `fit.png` (source-plane family fit), `fit_image_plane.png` and `point_solver.png` |
| `cluster_pandora` | `visualization.py` | Four cluster overviews and seven source-plane family fits on the registered [Abell 2744 HST cutout](dataset/cluster/a2744/README.md) |
| `cluster_macs_j0416` | `visualization.py` | Nine [MACS J0416 family diagnostics](scripts/cluster_macs_j0416/README.md), including catalogue-labelled source-plane fits and published image-plane offsets |
| `multi_dataset` | `visualization.py` | `dataset.png` + `fit.png` per band |
| `weak` | `visualization.py` | `dataset.png` + `fit.png` |

Expand Down
58 changes: 56 additions & 2 deletions gallery/viz_manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
# the PyAutoEyes dashboard. Do not edit by hand: rerun
# `bash gallery/gallery_run.sh --all` (or `python gallery/gallery_build.py`).
schema: 1
generated: '2026-11-24'
generated: '2026-11-25'
rendered_with:
autolens: 2026.8.17.1
autogalaxy: 2026.8.17.1
autoarray: 2026.8.17.1
autofit: 2026.8.17.1
figure_count: 97
figure_count: 106
figures:
- file: scripts/cluster/images/visualization/dataset.png
producer: scripts/cluster/visualization.py
Expand Down Expand Up @@ -118,6 +118,60 @@ figures:
source: point_1
bytes: 499370
sha256: 482ad6ee947511074f0573140c502557c615964c4b6651b8c27d9f8a1f2edc76
- file: scripts/cluster_macs_j0416/images/visualization/210.4c_zoom.png
producer: scripts/cluster_macs_j0416/visualization.py
domain: cluster_macs_j0416
source: ''
bytes: 35145
sha256: e7d541f87ae5dd576bef4c376f3aacfbbef9dae9a3cbda92f2716ae900f4f36e
- file: scripts/cluster_macs_j0416/images/visualization/all_back_traced_images.png
producer: scripts/cluster_macs_j0416/visualization.py
domain: cluster_macs_j0416
source: ''
bytes: 28212
sha256: 54ea940b55b2757441377b8a53f3da11cd91a0ce6b9906d8f32188ac2244cbfc
- file: scripts/cluster_macs_j0416/images/visualization/overview.png
producer: scripts/cluster_macs_j0416/visualization.py
domain: cluster_macs_j0416
source: ''
bytes: 383908
sha256: 2a4ca482bff330f617764781da829ce4bf351b68b7b27614ffd95c98d6f58def
- file: scripts/cluster_macs_j0416/images/visualization/published_101.png
producer: scripts/cluster_macs_j0416/visualization.py
domain: cluster_macs_j0416
source: ''
bytes: 368352
sha256: e6aa1a688132b34d95417e23102af8c563cf2e72ea67435f2e1e5b50ae651011
- file: scripts/cluster_macs_j0416/images/visualization/published_14.1.png
producer: scripts/cluster_macs_j0416/visualization.py
domain: cluster_macs_j0416
source: ''
bytes: 422099
sha256: 48f5510b1d14041e4ef2e036492d58eb6f527c59cb2c0fe56dab8c65e72d11a3
- file: scripts/cluster_macs_j0416/images/visualization/ranking.png
producer: scripts/cluster_macs_j0416/visualization.py
domain: cluster_macs_j0416
source: ''
bytes: 23285
sha256: 6565c51e7a54552c8937f44f67f65e69e1c2e1e17853c2e9bda5aecffd453c45
- file: scripts/cluster_macs_j0416/images/visualization/source_101.png
producer: scripts/cluster_macs_j0416/visualization.py
domain: cluster_macs_j0416
source: ''
bytes: 331982
sha256: 454049bc4e2f3a3dece25ccaf13fc24c5b5161ffa458a08ff58661335acf5ef7
- file: scripts/cluster_macs_j0416/images/visualization/source_14.1.png
producer: scripts/cluster_macs_j0416/visualization.py
domain: cluster_macs_j0416
source: ''
bytes: 448924
sha256: dfa644d221ddbd0f8a7606813dd06ed7ccc5aa2a39ee3bd8f6403f0be67fbc55
- file: scripts/cluster_macs_j0416/images/visualization/source_210.4.png
producer: scripts/cluster_macs_j0416/visualization.py
domain: cluster_macs_j0416
source: ''
bytes: 319794
sha256: 0ef32202e8f9b0d73b249771195cd683e0b4c07a0d4cc33b8f9dc490c8d3b5d5
- file: scripts/cluster_pandora/images/visualization/dataset.png
producer: scripts/cluster_pandora/visualization.py
domain: cluster_pandora
Expand Down
8 changes: 8 additions & 0 deletions scripts/cluster_macs_j0416/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# MACS J0416 family fits

Run `bash gallery/gallery_run.sh cluster_macs_j0416` from the gallery root. On first use the producer downloads the expanded mass model, multiple-image catalogue, residual table and HST F160W mosaic. It verifies their SHA-256 digests before rendering and caches the inputs in `output/macs_j0416_inputs/`. The source URLs and digests are recorded in [inputs.py](inputs.py).

The field contains 237 observed images from 88 knot families. The model holds the 222 published dPIE mass components fixed and solves a source centre for each selected family. The catalogue uses arcsecond offsets increasing west and north from RA 64.038142°, Dec −24.067472°. Each HST cutout is sampled through the mosaic’s sky WCS. [Bergamini et al. (2023)](https://arxiv.org/abs/2208.14020) · [Published model](https://www.fe.infn.it/astro/lensing/M0416_Bergamini22/) · [Hubble Frontier Fields F160W, epoch 2](https://archive.stsci.edu/pub/hlsp/frontier/macs0416/images/hst/v1.0-epoch2/)

- The three source-plane subplots follow the two images of family 210.4, the three images of 101, and the six images of 14.1. For 210.4 the overview, contribution ranking, 210.4c zoom and all back-traced images are also available individually. Image 210.4c contributes 9.49 of the family’s 11.70 source-plane χ².
- The two published-offset figures use the image matches and rounded residuals in `chires.dat`. The bars show separations in arcseconds. For family 101, image 101c has a 1.75″ offset and the family RMS is 1.08″. The lower-right panel shows the observed images back-traced by the fixed PyAutoLens model. Family 14.1 uses the same comparison for all six images.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
149 changes: 149 additions & 0 deletions scripts/cluster_macs_j0416/inputs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
"""Pinned Lenstool catalogue and mass model, and HFF F160W sky registration."""

import hashlib
import re
import shutil
from collections import defaultdict
from pathlib import Path
from tempfile import NamedTemporaryFile
from urllib.request import urlopen

import autolens as al
import numpy as np
from astropy.io import fits
from astropy.wcs import WCS
from scipy.ndimage import map_coordinates

CACHE = Path(__file__).resolve().parents[2] / "output" / "macs_j0416_inputs"
BASE = "https://www.fe.infn.it/astro/lensing/M0416_Bergamini22/"
FITS = "hlsp_frontier_hst_wfc3-60mas_macs0416_f160w_v1.0-epoch2_drz.fits"
SOURCES = {
"best.par": (
BASE + "best.par",
"16df3edf1ccc5a1edc17205fbdaacd2f36b37f91102124afea2e96b75c98041f",
),
"obs_arcs.cat": (
BASE + "obs_arcs.cat",
"bb70861cd29ab1b768755311375a633891d54cf2164207e54b7ad6d79732b60e",
),
"chires.dat": (
BASE + "chires.dat",
"0af67a6765ba3af324243886bc32d513cd3d3718e746bcb3728f41f572bb0d53",
),
FITS: (
"https://archive.stsci.edu/pub/hlsp/frontier/macs0416/images/hst/v1.0-epoch2/" + FITS,
"5c974843f9e66400000c724401249de0ef42f1a988eb199fd04abf697b3327b1",
),
}
FIELD = (-52, 63, -77, 38)


def verified_input(name):
url, expected = SOURCES[name]
path = CACHE / name

def verify(candidate):
with candidate.open("rb") as stream:
if hashlib.file_digest(stream, "sha256").hexdigest() != expected:
raise ValueError(f"Checksum mismatch for {name} from {url}")

if path.exists():
verify(path)
return path
CACHE.mkdir(exist_ok=True, parents=True)
with NamedTemporaryFile(dir=CACHE, delete=False) as f:
temporary = Path(f.name)
try:
with urlopen(url, timeout=120) as response, temporary.open("wb") as stream:
shutil.copyfileobj(response, stream)
verify(temporary)
temporary.replace(path)
finally:
temporary.unlink(missing_ok=True)
return path


def load_model():
text = verified_input("best.par").read_text()
ra0, dec0 = map(float, re.search(r"reference\s+3\s+([\d.]+)\s+([-\d.]+)", text).groups())
families = defaultdict(list)
for line in verified_input("obs_arcs.cat").read_text().splitlines():
if not line.strip() or line.lstrip().startswith("#"):
continue
ident, ra, dec, a, b, _, z, _ = line.split()
m = re.fullmatch(r"(\d+(?:\.\d+)?)[a-z]", ident)
if not m or float(a) != float(b):
raise ValueError(f"Unexpected observed image: {line}")
y = (float(dec) - dec0) * 3600
x = -(float(ra) - ra0) * np.cos(np.deg2rad(dec0)) * 3600
families[m[1]].append((ident, y, x, float(a), float(z)))
zmax = max(rows[0][4] for rows in families.values())
cosmology = dict(H0=70.0, Om0=0.3)
lenses = []
for block in re.findall(r"potentiel\s+\S+\s*\n(.*?)\bend\b", text, re.S):
v = {row[0]: float(row[1]) for line in block.splitlines() if len(row := line.split()) == 2}
if v["profil"] != 81:
raise ValueError("Expected Lenstool dPIE profile 81")
z = v["z_lens"]
mass = al.mp.dPIEMass(
centre=(v["y_centre"], v["x_centre"]),
ellipticity=v["ellipticite"],
angle_pos=v["angle_pos"],
sigma=v["v_disp"],
r_core=v["core_radius"],
r_cut=v["cut_radius"],
redshift_object=z,
redshift_source=zmax,
**cosmology,
)
lenses.append(al.Galaxy(redshift=z, mass=mass))
datasets = {}
sources = []
for name, rows in families.items():
ids, y, x, sigma, z = zip(*rows, strict=True)
datasets[name] = al.PointDataset(
name=name,
positions=list(zip(y, x)),
positions_noise_map=list(sigma),
redshift=z[0],
image_ids=list(ids),
)
sources.append(al.Galaxy(redshift=z[0], **{name: al.ps.PointSolved()}))
offsets = {}
for line in verified_input("chires.dat").read_text().splitlines():
row = line.split()
if len(row) == 13 and row[0].isdigit() and row[3] == "1":
if row[1] in offsets:
raise ValueError(f"Duplicate residual for {row[1]}")
offsets[row[1]] = (float(row[11]), -float(row[10]))
ids = [i for ds in datasets.values() for i in ds.image_ids]
if (len(lenses), len(sources), len(ids)) != (222, 88, 237) or set(ids) != set(offsets):
raise ValueError("Unexpected coverage in MACS J0416 tables")
return (
datasets,
al.Tracer(galaxies=lenses + sources, cosmology=al.cosmo.FlatLambdaCDM(**cosmology)),
offsets,
(ra0, dec0),
)


class Mosaic:
def __init__(self, reference):
self.pixels, header = fits.getdata(verified_input(FITS), header=True)
self.wcs = WCS(header).celestial
self.ra, self.dec = reference

def raster(self, bounds, step):
x0, x1, y0, y1 = bounds
ny, nx = int(np.ceil((y1 - y0) / step)), int(np.ceil((x1 - x0) / step))
y, x = np.meshgrid(
y0 + (np.arange(ny) + 0.5) * (y1 - y0) / ny,
x0 + (np.arange(nx) + 0.5) * (x1 - x0) / nx,
indexing="ij",
)
px, py = self.wcs.world_to_pixel_values(
self.ra - x / (3600 * np.cos(np.radians(self.dec))), self.dec + y / 3600
)
return map_coordinates(
self.pixels, [py, px], order=1, mode="constant", cval=np.nan, prefilter=False
)
Loading
Loading