ivis.io

Data I/O and preprocessing utilities for visibility and beam data.

This module defines the VisData dataclass and the DataProcessor class for handling Measurement Sets, extracting tar archives, and preparing input for imaging in the IViS pipeline.

Classes

DataProcessor(path_ms, path_beams, path_sd, ...)

Handles loading, extraction, and preprocessing of measurement set data, as well as beam grid reprojection.

VisData(uu, vv, ww, sigma, data, beam, ...)

Container for visibility data used in the imaging pipeline.

class ivis.io.DataProcessor(path_ms, path_beams, path_sd, pathout)[source]

Bases: object

Handles loading, extraction, and preprocessing of measurement set data, as well as beam grid reprojection.

Parameters:
  • path_ms (str) – Path to measurement sets (.ms or tar archives).

  • path_beams (str) – Path to beam FITS files.

  • path_sd (str) – Path to single-dish FITS file (optional, can be empty).

  • pathout (str) – Output directory for processed primary beams and grids.

compute_pb_and_grid(hdr, fitsname_pb=None, fitsname_grid=None)[source]

Reprojects and interpolates primary beams onto a common WCS grid.

Parameters:
  • hdr (dict) – FITS header of target WCS.

  • fitsname_pb (str) – Filename to store the reprojected primary beams.

  • fitsname_grid (str) – Filename to store the interpolation grids.

static concatenate_vis_data(vis_data_list)[source]

Concatenates a list of VisData objects into one sorted by beam index.

Parameters:

vis_data_list (list of VisData) – List of visibility datasets to merge.

Returns:

Combined and beam-sorted visibility data.

Return type:

VisData

extract_tar(tar_file, clear=False)[source]

Extracts a .tar file to its directory and optionally deletes it.

Parameters:
  • tar_file (str) – Path to .tar archive.

  • clear (bool, optional) – Whether to delete the archive after extraction.

Returns:

Path to the processed .tar file.

Return type:

str

fixms()[source]

Applies fix_ms_dir to all .ms files in the input path.

make_imaging_header(skycoord, fov_deg=10.0, pix_arcsec=7.0, projection='SIN')[source]

Create a FITS WCS header for 2D interferometric imaging.

Parameters:
  • skycoord (SkyCoord) – Sky coordinate of the phase center.

  • fov_deg (float, optional) – Total field of view [deg]. Default = 5 deg.

  • pix_arcsec (float, optional) – Pixel size in arcsec. Default = 7 arcsec.

  • projection (str, optional) – WCS projection (SIN, TAN, CAR…). Default = “SIN”.

Returns:

  • header (astropy.io.fits.Header)

  • wcs (astropy.wcs.WCS)

read_pb_and_grid(fitsname_pb, fitsname_grid)[source]

Loads precomputed primary beams and interpolation grids from disk.

Parameters:
  • fitsname_pb (str) – Filename of the primary beam FITS.

  • fitsname_grid (str) – Filename of the grid FITS.

Returns:

(primary beam array, interpolation grid array)

Return type:

tuple of np.ndarray

read_sd()[source]

Stub for reading single-dish data.

Returns:

(sd = 0, beam_sd = 0)

Return type:

tuple

read_vis_from_scratch(uvmin=0, uvmax=7000, chunks=10000000.0, target_frequency=None, target_channel=0, extension='.ms', blocks='single', max_workers=1, max_blocks=None)[source]

Reads visibilities from Measurement Sets in ‘single’ or ‘multiple’ block mode.

Parameters:
  • uvmin (float) – Minimum and maximum baseline lengths in lambda.

  • uvmax (float) – Minimum and maximum baseline lengths in lambda.

  • chunks (float) – Unused placeholder for chunk size.

  • target_frequency (float or None) – Target frequency for selecting channels.

  • target_channel (int) – Index of the desired frequency channel.

  • extension (str) – File extension to filter MS files.

  • blocks ({'single', 'multiple'}) – Whether to process a flat list or nested directory structure.

  • max_workers (int) – Number of workers for parallel loading.

  • max_blocks (int or None) – Optional limit on number of blocks when using ‘multiple’ mode.

Returns:

Concatenated visibility dataset.

Return type:

VisData

untardir(max_workers=4, clear=False)[source]

Recursively extracts all .tar files in path_ms using multithreading.

Parameters:
  • max_workers (int) – Number of threads for parallel extraction.

  • clear (bool) – Whether to delete the archives after extraction.

class ivis.io.VisData(uu, vv, ww, sigma, data, beam, coords, frequency)[source]

Bases: object

Container for visibility data used in the imaging pipeline.

beam: ndarray
coords: ndarray
data: ndarray
frequency: ndarray
sigma: ndarray
uu: ndarray
vv: ndarray
ww: ndarray