mao_merge_45m.correlator module#
- convert(path_raw_zarr: Path, path_fmt_zarr: Optional[Path] = None, *, bin_width: int = 8, overwrite: bool = False, progress: bool = False) Path [source]#
Convert a raw Zarr file to a formatted Zarr file.
This function will make a two-dimensional correlator output with time and freq metadata derived from the raw Zarr file. It will also average the output in frequency to reduce the size.
- Parameters
path_raw_vdif – Path of the raw VDIF file.
path_fmt_zarr (Optional[Path]) – Path of the formatted Zarr file (optional).
bin_width (int) – Bin width for averaging the output in frequency.
overwrite (bool) – Whether to overwrite the formatted Zarr file if exists.
progress (bool) – Whether to show a progress bar.
path_raw_zarr (Path) –
- Returns
Path of the formatted Zarr file.
- Raises
FileExistsError – Raised if the formatted Zarr file exists and overwriting is not allowed (default).
- Return type
Path
- to_zarr(path_vdif: Path, path_zarr: Optional[Path] = None, *, seconds_per_chunk: int = 60, overwrite: bool = False, progress: bool = False) Path [source]#
Convert a VDIF file to a Zarr file losslessly.
This function focuses on the conversion between formats. The formatted Zarr file with metadata will be made by another function (convert).
The output Zarr file from the function has three arrays.
vdif_head: 4-byte data (uint32) * 8.
corr_head: 4-byte data (uint32) * 64.
corr_data: 2-byte data (int16) * 512 (256 re/im values).
- Parameters
path_vdif (Path) – Path of the VDIF file.
path_zarr (Optional[Path]) – Path of the Zarr file (optional).
seconds_per_chunk (int) – Time length per chunk in the Zarr file.
overwrite (bool) – Whether to overwrite the Zarr file if exists.
progress (bool) – Whether to show a progress bar.
- Returns
Path of the Zarr file.
- Raises
RuntimeError – Raised if the VDIF file is truncated.
FileExistsError – Raised if the Zarr file exists and overwriting is not allowed (default).
- Return type
Path