@@ -68,6 +68,10 @@ def __init__(
6868 psf
6969 The Point Spread Function kernel of the image which accounts for diffraction due to the telescope optics
7070 via 2D convolution.
71+ psf_setup_state
72+ If `True`, a `ConvolverState` is precomputed from the PSF kernel and mask, storing the
73+ convolution pair indices required for efficient 2D convolution. This is set automatically
74+ to `True` when a mask is applied via `apply_mask()` and should not normally be set by hand.
7175 noise_covariance_matrix
7276 A noise-map covariance matrix representing the covariance between noise in every `data` value, which
7377 can be used via a bespoke fit to account for correlated noise in the data.
@@ -236,13 +240,25 @@ def apply_mask(self, mask: Mask2D) -> "Imaging":
236240 Apply a mask to the imaging dataset, whereby the mask is applied to the image data, noise-map and other
237241 quantities one-by-one.
238242
239- The `apply_mask` function cannot be called multiple times, if it is a mask may remove data, therefore
240- an exception is raised. If you wish to apply a new mask, reload the dataset from .fits files.
243+ The mask is applied to the `data`, `noise_map`, `over_sample_size_lp` and
244+ `over_sample_size_pixelization` arrays. If a `noise_covariance_matrix` is present, the rows
245+ and columns corresponding to masked pixels are removed so it stays consistent with the
246+ remaining unmasked pixels. The PSF `ConvolverState` is recomputed for the new mask.
247+
248+ The `apply_mask` function cannot be called multiple times — a new mask cannot expand the
249+ unmasked region beyond what was already unmasked, as the underlying data has already been
250+ trimmed. An exception is raised if this is attempted. If you wish to apply a different mask,
251+ reload the dataset from .fits files.
241252
242253 Parameters
243254 ----------
244255 mask
245256 The 2D mask that is applied to the image.
257+
258+ Returns
259+ -------
260+ Imaging
261+ A new `Imaging` dataset with the mask applied to all arrays.
246262 """
247263 invalid = np .logical_and (self .data .mask , np .logical_not (mask ))
248264
@@ -413,22 +429,27 @@ def apply_sparse_operator(
413429 batch_size : int = 128 ,
414430 ):
415431 """
432+ Precompute the PSF precision operator for efficient pixelized source reconstruction.
433+
416434 The sparse linear algebra formalism precomputes the convolution of every pair of masked
417- noise-map values given the PSF (see `inversion.inversion_util`).
435+ noise-map values given the PSF (see `inversion.inversion_util`). This is the imaging
436+ equivalent of the interferometer NUFFT precision matrix.
418437
419- The `WTilde` object stores these precomputed values in the imaging dataset ensuring they are only computed once
420- per analysis.
438+ The `ImagingSparseOperator` stores these precomputed values in the imaging dataset ensuring
439+ they are only computed once per analysis, enabling fast repeated likelihood evaluations during
440+ model fitting.
421441
422- This uses lazy allocation such that the calculation is only performed when the wtilde matrices are used,
423- ensuring efficient set up of the `Imaging` class.
442+ Parameters
443+ ----------
444+ batch_size
445+ The number of image pixels processed per batch when computing the sparse operator via
446+ FFT-based convolution. Reducing this lowers peak memory usage at the cost of speed.
424447
425448 Returns
426449 -------
427- batch_size
428- The size of batches used to compute the w-tilde curvature matrix via FFT-based convolution,
429- which can be reduced to produce lower memory usage at the cost of speed
430- use_jax
431- Whether to use JAX to compute W-Tilde. This requires JAX to be installed.
450+ Imaging
451+ A new `Imaging` dataset with the precomputed `ImagingSparseOperator` attached, enabling
452+ efficient pixelized source reconstruction via the sparse linear algebra formalism.
432453 """
433454
434455 logger .info (
@@ -459,22 +480,20 @@ def apply_sparse_operator_cpu(
459480 self ,
460481 ):
461482 """
462- The sparse linear algebra formalism precomputes the convolution of every pair of masked
463- noise-map values given the PSF (see `inversion.inversion_util`).
483+ Precompute the PSF precision operator using a CPU-only Numba implementation.
464484
465- The `WTilde` object stores these precomputed values in the imaging dataset ensuring they are only computed once
466- per analysis.
485+ This is the CPU alternative to `apply_sparse_operator()`, using Numba JIT compilation
486+ for the convolution loop rather than JAX. It requires `numba` to be installed; an
487+ `InversionException` is raised if it is not available.
467488
468- This uses lazy allocation such that the calculation is only performed when the wtilde matrices are used,
469- ensuring efficient set up of the `Imaging` class .
489+ The resulting `SparseLinAlgImagingNumba` operator is stored on the returned `Imaging`
490+ dataset and used by `FitImaging` when performing pixelized source reconstructions .
470491
471492 Returns
472493 -------
473- batch_size
474- The size of batches used to compute the w-tilde curvature matrix via FFT-based convolution,
475- which can be reduced to produce lower memory usage at the cost of speed.
476- use_jax
477- Whether to use JAX to compute W-Tilde. This requires JAX to be installed.
494+ Imaging
495+ A new `Imaging` dataset with a precomputed Numba-based sparse operator attached,
496+ enabling efficient pixelized source reconstruction on CPU hardware.
478497 """
479498 try :
480499 import numba
0 commit comments