autogalaxy.Interferometer#

class Interferometer[source]#

Bases: AbstractDataset

An interferometer dataset, containing the visibilities data, noise-map, real-space msk, Fourier transformer and associated quantities for calculations like the grid.

This object is the input to the FitInterferometer object, which fits the dataset with model visibilities and quantifies the goodness-of-fit via a residual map, likelihood, chi-squared and other quantities.

The following quantities of the interferometer data are available and used for the following tasks:

  • data: The visibilities data, which shows the signal that is analysed and fitted with model visibilities.

  • noise_map: The RMS standard deviation error in every visibility, which is used to compute the chi-squared

value and likelihood of a fit.

  • uv_wavelengths: The baselines of the interferometer which are used to Fourier transform a real space

image to the uv-plane.

real_space_mask: Defines in real space where the signal is present. This mask is used to transform images to Fourier space via the Fourier transform. The grids contained in the settings are aligned with this mask.

The dataset also has a number of (y,x) grids of coordinates associated with it, which map to the centres of its image pixels. They are used for performing calculations which map directly to the data and have over sampling calculations built in which approximate the 2D line integral of these calculations within a pixel. This is explained in more detail in the GridsDataset class.

Parameters:
  • data (Visibilities) – The array of the visibilities data containing the signal that is fitted.

  • noise_map (VisibilitiesNoiseMap) – An array describing the RMS standard deviation error in each visibility used for computing quantities like the chi-squared in a fit.

  • uv_wavelengths (ndarray) – The baselines of the interferometer which are used to Fourier transform a real space image to the uv-plane.

  • real_space_mask (Mask2D) – Defines in real space where the signal is present. This mask is used to transform images to Fourier space via the Fourier transform. The grids contained in the settings are aligned with this mask.

  • noise_covariance_matrix – A noise-map covariance matrix representing the covariance between noise in every data value, which can be used via a bespoke fit to account for correlated noise in the data.

  • transformer_class – The class of the Fourier Transform which maps images from real space to Fourier space visibilities and the uv-plane.

  • sparse_operator (Optional[InterferometerSparseOperator]) – A precomputed InterferometerSparseOperator containing the NUFFT precision matrix for efficient pixelized source reconstruction. This is computed via apply_sparse_operator() and can be passed here directly to avoid recomputing it (e.g. when loading a cached result from disk).

  • raise_error_dft_visibilities_limit (bool) – If True, an exception is raised if the dataset has more than 10,000 visibilities and transformer_class=TransformerDFT. The DFT is too slow for large datasets and TransformerNUFFT should be used instead. Set to False to suppress this check.

__init__(data, noise_map, uv_wavelengths, real_space_mask, transformer_class=<class 'autoarray.operators.transformer.TransformerNUFFT'>, sparse_operator=None, raise_error_dft_visibilities_limit=True)[source]#

An interferometer dataset, containing the visibilities data, noise-map, real-space msk, Fourier transformer and associated quantities for calculations like the grid.

This object is the input to the FitInterferometer object, which fits the dataset with model visibilities and quantifies the goodness-of-fit via a residual map, likelihood, chi-squared and other quantities.

The following quantities of the interferometer data are available and used for the following tasks:

  • data: The visibilities data, which shows the signal that is analysed and fitted with model visibilities.

  • noise_map: The RMS standard deviation error in every visibility, which is used to compute the chi-squared

value and likelihood of a fit.

  • uv_wavelengths: The baselines of the interferometer which are used to Fourier transform a real space

image to the uv-plane.

real_space_mask: Defines in real space where the signal is present. This mask is used to transform images to Fourier space via the Fourier transform. The grids contained in the settings are aligned with this mask.

The dataset also has a number of (y,x) grids of coordinates associated with it, which map to the centres of its image pixels. They are used for performing calculations which map directly to the data and have over sampling calculations built in which approximate the 2D line integral of these calculations within a pixel. This is explained in more detail in the GridsDataset class.

Parameters:
  • data (Visibilities) – The array of the visibilities data containing the signal that is fitted.

  • noise_map (VisibilitiesNoiseMap) – An array describing the RMS standard deviation error in each visibility used for computing quantities like the chi-squared in a fit.

  • uv_wavelengths (ndarray) – The baselines of the interferometer which are used to Fourier transform a real space image to the uv-plane.

  • real_space_mask (Mask2D) – Defines in real space where the signal is present. This mask is used to transform images to Fourier space via the Fourier transform. The grids contained in the settings are aligned with this mask.

  • noise_covariance_matrix – A noise-map covariance matrix representing the covariance between noise in every data value, which can be used via a bespoke fit to account for correlated noise in the data.

  • transformer_class – The class of the Fourier Transform which maps images from real space to Fourier space visibilities and the uv-plane.

  • sparse_operator (Optional[InterferometerSparseOperator]) – A precomputed InterferometerSparseOperator containing the NUFFT precision matrix for efficient pixelized source reconstruction. This is computed via apply_sparse_operator() and can be passed here directly to avoid recomputing it (e.g. when loading a cached result from disk).

  • raise_error_dft_visibilities_limit (bool) – If True, an exception is raised if the dataset has more than 10,000 visibilities and transformer_class=TransformerDFT. The DFT is too slow for large datasets and TransformerNUFFT should be used instead. Set to False to suppress this check.

Methods

__init__(data, noise_map, uv_wavelengths, ...)

An interferometer dataset, containing the visibilities data, noise-map, real-space msk, Fourier transformer and associated quantities for calculations like the grid.

apply_over_sampling()

Apply new over-sampling sizes to the dataset grids.

apply_sparse_operator([...])

Precompute the NUFFT precision operator for efficient pixelized source reconstruction.

from_fits(data_path, noise_map_path, ...[, ...])

Load an interferometer dataset from multiple .fits files.

psf_precision_operator_from([chunk_k, ...])

Compute the NUFFT precision matrix for this interferometer dataset.

trimmed_after_convolution_from(kernel_shape)

Return a copy of the dataset with all arrays trimmed to remove the border pixels affected by PSF convolution edge effects.

Attributes

amplitudes

The amplitudes of the complex visibilities, defined as the absolute value of each visibility: amplitude = sqrt(real^2 + imag^2).

dirty_image

The dirty image, computed as the inverse Fourier transform of the observed visibilities.

dirty_noise_map

The dirty noise map, computed as the inverse Fourier transform of the noise map visibilities.

dirty_signal_to_noise_map

The dirty signal-to-noise map, computed as the inverse Fourier transform of the complex signal-to-noise visibility map.

grid

The primary coordinate grid of the dataset, equivalent to grids.lp.

mask

The real-space mask of the interferometer dataset.

noise_covariance_matrix_inv

Returns the inverse of the noise covariance matrix, which is used when computing a chi-squared which accounts for covariance via a fit.

phases

The phases of the complex visibilities in radians, defined as arctan(imag / real) for each visibility.

pixel_scales

The (y, x) arcsecond-to-pixel conversion factor of the dataset, as a (float, float) tuple.

psf

Returns None for interferometer datasets.

shape_native

The 2D shape of the dataset image in its native (unmasked) dimensions, e.g. (rows, columns).

shape_slim

The 1D size of the dataset data array after masking, i.e. the number of unmasked pixels.

signal_to_noise_map

The complex signal-to-noise map of the visibilities.

signal_to_noise_max

The maximum signal-to-noise value across all unmasked pixels in the dataset.

uv_distances

The radial distance of each visibility baseline from the origin of the UV-plane, in units of wavelengths.

__init__(data, noise_map, uv_wavelengths, real_space_mask, transformer_class=<class 'autoarray.operators.transformer.TransformerNUFFT'>, sparse_operator=None, raise_error_dft_visibilities_limit=True)[source]#

An interferometer dataset, containing the visibilities data, noise-map, real-space msk, Fourier transformer and associated quantities for calculations like the grid.

This object is the input to the FitInterferometer object, which fits the dataset with model visibilities and quantifies the goodness-of-fit via a residual map, likelihood, chi-squared and other quantities.

The following quantities of the interferometer data are available and used for the following tasks:

  • data: The visibilities data, which shows the signal that is analysed and fitted with model visibilities.

  • noise_map: The RMS standard deviation error in every visibility, which is used to compute the chi-squared

value and likelihood of a fit.

  • uv_wavelengths: The baselines of the interferometer which are used to Fourier transform a real space

image to the uv-plane.

real_space_mask: Defines in real space where the signal is present. This mask is used to transform images to Fourier space via the Fourier transform. The grids contained in the settings are aligned with this mask.

The dataset also has a number of (y,x) grids of coordinates associated with it, which map to the centres of its image pixels. They are used for performing calculations which map directly to the data and have over sampling calculations built in which approximate the 2D line integral of these calculations within a pixel. This is explained in more detail in the GridsDataset class.

Parameters:
  • data (Visibilities) – The array of the visibilities data containing the signal that is fitted.

  • noise_map (VisibilitiesNoiseMap) – An array describing the RMS standard deviation error in each visibility used for computing quantities like the chi-squared in a fit.

  • uv_wavelengths (ndarray) – The baselines of the interferometer which are used to Fourier transform a real space image to the uv-plane.

  • real_space_mask (Mask2D) – Defines in real space where the signal is present. This mask is used to transform images to Fourier space via the Fourier transform. The grids contained in the settings are aligned with this mask.

  • noise_covariance_matrix – A noise-map covariance matrix representing the covariance between noise in every data value, which can be used via a bespoke fit to account for correlated noise in the data.

  • transformer_class – The class of the Fourier Transform which maps images from real space to Fourier space visibilities and the uv-plane.

  • sparse_operator (Optional[InterferometerSparseOperator]) – A precomputed InterferometerSparseOperator containing the NUFFT precision matrix for efficient pixelized source reconstruction. This is computed via apply_sparse_operator() and can be passed here directly to avoid recomputing it (e.g. when loading a cached result from disk).

  • raise_error_dft_visibilities_limit (bool) – If True, an exception is raised if the dataset has more than 10,000 visibilities and transformer_class=TransformerDFT. The DFT is too slow for large datasets and TransformerNUFFT should be used instead. Set to False to suppress this check.

classmethod from_fits(data_path, noise_map_path, uv_wavelengths_path, real_space_mask, visibilities_hdu=0, noise_map_hdu=0, uv_wavelengths_hdu=0, transformer_class=<class 'autoarray.operators.transformer.TransformerNUFFT'>, raise_error_dft_visibilities_limit=True)[source]#

Load an interferometer dataset from multiple .fits files.

The visibilities (complex-valued Fourier-space data), noise map and uv_wavelengths (baseline coordinates) are each loaded from separate .fits files. A real-space mask defining the sky region used for Fourier transforms must be supplied separately.

The visibilities are assumed to be stored as a 2D array of shape (total_visibilities, 2) where column 0 is the real component and column 1 is the imaginary component. The noise map has the same shape. The uv_wavelengths are a 2D array of shape (total_visibilities, 2) with columns corresponding to the (u, v) baseline coordinates in units of wavelengths.

Parameters:
  • data_path – The path to the .fits file containing the visibility data (e.g. ‘/path/to/visibilities.fits’).

  • noise_map_path – The path to the .fits file containing the visibility noise map (e.g. ‘/path/to/noise_map.fits’).

  • uv_wavelengths_path – The path to the .fits file containing the (u, v) baseline coordinates in units of wavelengths (e.g. ‘/path/to/uv_wavelengths.fits’).

  • real_space_mask – A Mask2D defining the real-space region of the sky that contains signal. This mask determines the pixel grid used by the Fourier transformer and the coordinate grids associated with the dataset.

  • visibilities_hdu – The HDU index in the visibilities .fits file from which data is loaded.

  • noise_map_hdu – The HDU index in the noise map .fits file from which data is loaded.

  • uv_wavelengths_hdu – The HDU index in the uv_wavelengths .fits file from which data is loaded.

  • transformer_class – The class of the Fourier Transform which maps images from real space to Fourier space visibilities. Defaults to TransformerNUFFT for efficiency with large datasets.

  • raise_error_dft_visibilities_limit (bool) – If True (default), raise a DatasetException when transformer_class is TransformerDFT and the dataset has more than 10,000 visibilities. Set to False to opt into the slow DFT path at ALMA-scale (e.g. when profiling the JAX-traceable DFT path before a JIT-friendly NUFFT is available).

Returns:

The interferometer dataset loaded from the .fits files.

Return type:

Interferometer

apply_sparse_operator(nufft_precision_operator=None, batch_size=128, chunk_k=2048, show_progress=False, show_memory=False, use_jax=False)[source]#

Precompute the NUFFT precision operator for efficient pixelized source reconstruction.

The sparse linear algebra formalism precomputes the Fourier Transform response matrix for all visibility baselines, enabling fast repeated evaluation during model fitting. This avoids recomputing the full NUFFT on every likelihood call.

The resulting InterferometerSparseOperator is stored on the returned Interferometer dataset and is used automatically by FitInterferometer when performing pixelized reconstructions via the inversion module.

Computing the NUFFT precision matrix from scratch can be very slow (runtime scales with both the number of visibilities and the real-space mask resolution — potentially hours for large datasets). The result can be cached to disk and reloaded to avoid recomputation.

Parameters:
  • nufft_precision_operator – An already computed NUFFT precision matrix for this dataset (e.g. loaded from disk via np.load) to avoid an expensive recomputation. If None it is computed from scratch by calling psf_precision_operator_from().

  • batch_size (int) – The number of real-space pixels processed per batch when building the sparse operator. Reducing this lowers peak memory usage at the cost of speed.

  • chunk_k (int) – The number of visibilities processed per chunk when computing the NUFFT precision matrix inside psf_precision_operator_from(). Reducing this lowers peak memory usage.

  • show_progress (bool) – If True, a progress bar is displayed while computing the NUFFT precision matrix.

  • show_memory (bool) – If True, memory usage statistics are printed while computing the NUFFT precision matrix.

  • use_jax (bool) – If True, JAX is used to accelerate the NUFFT precision matrix computation.

Returns:

A new Interferometer dataset with the precomputed InterferometerSparseOperator attached, enabling efficient pixelized source reconstruction via the sparse linear algebra formalism.

Return type:

Interferometer

psf_precision_operator_from(chunk_k=2048, show_progress=False, show_memory=False, use_jax=False)[source]#

Compute the NUFFT precision matrix for this interferometer dataset.

The precision matrix encodes the response of every real-space pixel to every visibility baseline, weighted by the noise map. It is the core precomputed quantity required for efficient pixelized source reconstruction via the sparse linear algebra formalism.

This computation can be very slow for large datasets (runtime scales with the number of visibilities multiplied by the number of unmasked real-space pixels). For datasets with tens of thousands of visibilities and high-resolution masks, computation can take hours on a CPU. The result should be saved to disk and reloaded rather than recomputed on each run. Use apply_sparse_operator(nufft_precision_operator=…) to attach a cached result.

Parameters:
  • chunk_k (int) – The number of visibilities processed per chunk. Reducing this lowers peak memory usage during computation at the cost of speed.

  • show_progress (bool) – If True, a progress bar is shown during computation.

  • show_memory (bool) – If True, memory usage statistics are printed during computation.

  • use_jax (bool) – If True, JAX is used to accelerate the computation.

Returns:

The NUFFT precision matrix of shape (total_pixels, total_pixels) where total_pixels is the number of unmasked real-space pixels.

Return type:

np.ndarray

property mask#

The real-space mask of the interferometer dataset.

For an interferometer, this is the real_space_mask which defines the region of sky that contains signal. It is used as the spatial domain for the Fourier transform, determining the pixel grid size and coordinate grids.

property amplitudes#

The amplitudes of the complex visibilities, defined as the absolute value of each visibility: amplitude = sqrt(real^2 + imag^2).

property phases#

The phases of the complex visibilities in radians, defined as arctan(imag / real) for each visibility.

property uv_distances#

The radial distance of each visibility baseline from the origin of the UV-plane, in units of wavelengths. Computed as sqrt(u^2 + v^2) for each (u, v) baseline pair.

property dirty_image#

The dirty image, computed as the inverse Fourier transform of the observed visibilities.

This is the raw image obtained by back-projecting the visibilities without any deconvolution. It provides a quick visual representation of the data but is convolved with the synthesized beam (the Fourier transform of the UV-plane sampling function).

property dirty_noise_map#

The dirty noise map, computed as the inverse Fourier transform of the noise map visibilities.

Provides a real-space representation of the noise levels in the dirty image.

property dirty_signal_to_noise_map#

The dirty signal-to-noise map, computed as the inverse Fourier transform of the complex signal-to-noise visibility map.

property signal_to_noise_map#

The complex signal-to-noise map of the visibilities.

Computed separately for the real and imaginary components as data / noise_map. Values below zero are clamped to zero, as negative signal-to-noise is not physically meaningful.

Unlike the base class implementation (which operates on real-valued data), this override handles the complex nature of interferometric visibilities by treating the real and imaginary parts independently.

property psf#

Returns None for interferometer datasets.

Interferometers do not have a Point Spread Function in the same sense as imaging datasets. The equivalent quantity is the synthesized beam, which is determined by the UV-plane coverage and is not stored explicitly. This property exists to satisfy the AbstractDataset interface.