hyri.interface.load_data#
Load RI measurement data and convert them to torch tensors.
This file reads channel-wise measurement files, applies channel partitioning and optional weighting logic, and returns tensors ready for measurement operator and optimiser initialisation.
Functions
Load channel-wise RI measurements and convert them into torch tensors. |
- hyri.interface.load_data.load_data_to_tensor(uv_file_path: str, super_resolution: float | None = None, image_pixel_size: float | None = None, data_weighting: bool = True, load_weight: bool = False, img_size: tuple[int, int] = (512, 512), weight_type: str = 'briggs', weight_gridsize: float = 2.0, weight_robustness: float = 0.0, precond_weighting: bool = False, precond_weight_gridsize: float = 2.0, precond_weight_type: str = 'uniform', dtype: dtype = torch.float64, device: device = device(type='cpu'), data: dict | None = None, uvw_flag: tuple | None = None, invert_uvw_flag: bool = False, ch_start: int = 1, ch_last: int | None = None, ch_effctive: int | None = None, ch_partition: list[int] | None = None, verbose: bool = True) dict#
Load channel-wise RI measurements and convert them into torch tensors.
The input directory is expected to contain one
msSpecs.matfile with global metadata (includingfreqsanduvw), plus per-channel files matching*data_ch_<index>.mat.- Parameters:
uv_file_path (str) – Path to the input data directory.
super_resolution (float, optional) – Super-resolution factor used when pixel size is not explicitly provided. If None, use the
super_resolutionvalue frommsSpecs.mat, or 1.5 when that metadata is absent. Default: None.image_pixel_size (float, optional) – Image pixel size in arcsec. Default: None.
data_weighting (bool, optional) – Whether to apply imaging weights. Default: True.
load_weight (bool, optional) – Whether to load imaging weights from the channel files. If False and
data_weightingis True, imaging weights are generated. Default: False.img_size (Tuple[int, int], optional) – Image size used by weighting generation. Default: (512, 512).
weight_type (str, optional) – Imaging-weight type. Default: “briggs”.
weight_gridsize (float, optional) – Weight-grid size factor. Default: 2.0.
weight_robustness (float, optional) – Briggs robustness parameter. Default: 0.0.
precond_weighting (bool, optional) – Whether to generate preconditioning weights. Default: False.
precond_weight_gridsize (float, optional) – Grid size for preconditioning-weight generation. Default: 2.0.
precond_weight_type (str, optional) – Preconditioning-weight type. Default: “uniform”.
dtype (torch.dtype, optional) – Real dtype for stored tensors. Default:
torch.float64.device (torch.device, optional) – Target tensor device. Default:
torch.device("cpu").data (dict, optional) – Existing data dictionary to populate. If None, a new dictionary is created. Default: None.
uvw_flag (tuple, optional) – Optional per-channel flag arrays. If None, flags are read from channel files when available. Default: None.
invert_uvw_flag (bool, optional) – Whether to invert the loaded/provided UVW flags before filtering samples. Default: False.
ch_start (int, optional) – First physical channel index (1-based). Default: 1.
ch_last (int, optional) – Last physical channel index (1-based, inclusive). If None, all available channels are considered. Default: None.
ch_effctive (int, optional) – Number of effective channels after grouping. If None, all selected channels are used. Default: None.
ch_partition (List[int], optional) – Channel-group sizes used to map physical channels into effective channels. Default: None.
verbose (bool, optional) – Whether to print progress information. Default: True.
- Returns:
Data dictionary used by downstream operators/optimisers. Key entries include
u,v,w,natural_weight,imaging_weight,precond_weight, optionaly,freqs,image_pixel_size,super_resolution,max_proj_baseline, andrank_eff_ch_start.- Return type:
- Raises:
ValueError – If the provided channel partition does not match the number of selected physical channels.
Note
Tensor containers
u,v,w,natural_weight,imaging_weight,precond_weight, and optionalyare stored per effective channel, with each tensor shaped as(1, 1, N).In distributed mode, each rank loads only its assigned physical/effective channel slice. The returned
rank_eff_ch_startgives the global effective-channel offset for the current rank.If
datais provided, this function populates and updates it in place. If channel files do not containdata_I, visibility tensors remain empty.Expected file content:
msSpecs.matshould providefreqsanduvw.data_ch_*.matmay provideflag,weightsNat,weightsImg, anddata_I.
Examples
Load all channels with default weighting options:
>>> data = load_data_to_tensor("./data/measurement_set") >>> data["freqs"].shape[1] > 0 True
Load a channel range and aggregate into four effective channels:
>>> data = load_data_to_tensor( ... "./data/measurement_set", ... ch_start=1, ... ch_last=16, ... ch_effctive=4, ... ch_partition=[4, 4, 4, 4], ... load_weight=False, ... ) >>> len(data["u"]) 4