radarx.level1.iq.read_iq#

radarx.level1.iq.read_iq(path, *, shape=None, dtype='int16', layout='interleaved', offset=0, variables=('I', 'Q'), **kwargs)[source]#

Read an IQ time series file.

Three kinds of file are read:

  • a NumPy file (.npy) with a complex array, or a real array whose last axis has length 2 (I, Q);

  • a NetCDF file (.nc) or Zarr store (.zarr) with the variables variables (default I and Q) or one complex variable IQ; the dimension names of the file are kept and the data stay lazy for Zarr;

  • any other file is raw binary: shape samples of real dtype values after offset bytes, either interleaved (I0 Q0 I1 Q1 ...) or planar (all I, then all Q), the samples in C order of shape.

Parameters:
  • path (str or os.PathLike) – File or Zarr directory.

  • shape (tuple of int, optional) – Shape of the complex array of a raw file, for example (n_rays, n_pulses, n_gates). Required for raw files.

  • dtype (str or numpy.dtype, optional) – Sample type of a raw file, such as "int16", ">i2" or "float32". Default "int16".

  • layout ({"interleaved", "planar"}, optional) – Order of the I and Q samples in a raw file. Default "interleaved".

  • offset (int, optional) – Bytes to skip at the start of a raw file (a header). Default 0.

  • variables (tuple of str, optional) – Names of the in-phase and quadrature variables of a NetCDF or Zarr file.

  • **kwargs – dims, scale, wavelength, prt, range_start, gate_spacing and name as for as_iq().

Returns:

xarray.DataArray – The complex samples, see as_iq().

Raises:
  • FileNotFoundError – If the file does not exist.

  • ValueError – If a raw file is read without shape, is shorter than shape needs, or layout is unknown; or a NetCDF/Zarr file lacks the variables.