Radar Data IO#

Xarray Backends#

CfRadial1#

This sub-module contains the CfRadial1 xarray backend for reading CfRadial1-based radar data into Xarray structures as well as a reader to create a complete datatree.Datatree.

Code ported from wradlib.

Example:

import xradar as xd
dtree = xd.io.open_cfradial1_datatree(filename)

CfRadial1BackendEntrypoint

Xarray BackendEntrypoint for CfRadial1 data.

open_cfradial1_datatree

Open CfRadial1 dataset as xarray.DataTree.

class xradar.io.backends.cfradial1.CfRadial1BackendEntrypoint[source]#

Bases: BackendEntrypoint

Xarray BackendEntrypoint for CfRadial1 data.

Keyword Arguments:
  • first_dim (str) – Can be time or auto first dimension. If set to auto, first dimension will be either azimuth or elevation depending on type of sweep. Defaults to auto.

  • reindex_coord (dict, optional) – Defaults to None, no reindexing. Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked if decode_coords=True.

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool) – For PPI only. If True, fixes erroneous second angle data. Defaults to False.

  • site_as_coords (bool) – Attach radar site-coordinates to Dataset, defaults to True.

  • kwargs (dict) – Additional kwargs are fed to xarray.open_dataset().

description: ClassVar[str] = 'Open CfRadial1 (.nc, .nc4) using netCDF4 in Xarray'#
guess_can_open(filename_or_obj)[source]#

CfRadial1 file (netCDF with sweep_start_ray_index and a Conventions or version mentioning CF/Radial).

open_dataset(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=False, format=None, group='/', first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_as_coords=True, optional=True)[source]#

Backend open_dataset method used by Xarray in open_dataset().

open_datatree(filename_or_obj, **kwargs)[source]#

Open a CfRadial1 file as xarray.DataTree. See open_groups_as_dict() for keyword arguments.

open_groups_as_dict(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=False, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_coords=True, optional=True, optional_groups=False, sweep=None, netcdf_engine='netcdf4')[source]#

Open a CfRadial1 file as a CfRadial2-shaped dict of group datasets.

Parameters:
  • filename_or_obj (str, Path, or file-like) – Path or file-like object understood by the underlying reader.

  • mask_and_scale (bool or dict-like, optional) – Replace fill values with NA and apply scale_factor/add_offset decoding. See xarray.open_dataset(). Defaults to True.

  • decode_times (bool or dict-like, optional) – Decode CF time variables (calendar, units) into np.datetime64. Defaults to True.

  • concat_characters (bool or dict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults to True.

  • decode_coords (bool or {"coordinates", "all"}, optional) – Decode the CF coordinates attribute. Defaults to True (equivalent to "coordinates").

  • drop_variables (str or iterable of str, optional) – Names of variables to drop before processing.

  • use_cftime (bool, optional) – Force cftime decoding for time variables (instead of np.datetime64). Defaults to None (auto).

  • decode_timedelta (bool, optional) – Decode CF timedelta variables. Default mirrors decode_times unless the backend overrides it (cfradial1, cfradial2, and imd default to False).

  • sweep (int, str, or list of int/str, optional) – Sweep selection. None (default) returns all sweeps. An int or "sweep_N" string returns one sweep; a list returns the named subset.

  • first_dim ({"auto", "time"}, optional) – Leading dimension of each sweep dataset. "auto" picks azimuth (PPI) or elevation (RHI); "time" keeps the raw time axis. Default "auto" ("time" for cfradial2).

  • optional (bool, optional) – Include optional root variables when available. Defaults to True.

  • optional_groups (bool, optional) – Include the /radar_parameters, /georeferencing_correction, and /radar_calibration metadata subgroups under the root. Defaults to False.

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked when decode_coords=True. Defaults to None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective with first_dim="auto". Defaults to False.

  • site_coords (bool, optional) – Attach latitude/longitude/altitude as coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults to True.

  • netcdf_engine ({"netcdf4", "h5netcdf"}, optional) – Underlying NetCDF engine used by xr.open_dataset to read the CfRadial1 file. Defaults to "netcdf4".

Returns:

dict[str, xarray.Dataset] – CfRadial2 group paths (/, /sweep_N, optional /radar_parameters etc.) mapped to their datasets, ready for xarray.DataTree.from_dict().

supports_groups: ClassVar[bool] = True#
url: ClassVar[str] = 'https://xradar.rtfd.io/en/latest/io.html#cfradial1'#
xradar.io.backends.cfradial1.open_cfradial1_datatree(filename_or_obj, **kwargs)[source]#

Open CfRadial1 dataset as xarray.DataTree.

Deprecated since version Use: xd.open_datatree(file, engine="cfradial1") or xr.open_datatree(file, engine="cfradial1") instead.

Parameters:

filename_or_obj (str, Path, file-like or xarray.DataStore) – Strings and Path objects are interpreted as a path to a local or remote radar file

Keyword Arguments:
  • sweep (int, list of int, optional) – Sweep number(s) to extract, default to first sweep. If None, all sweeps are extracted into a list.

  • first_dim (str) – Can be time or auto first dimension. If set to auto, first dimension will be either azimuth or elevation depending on type of sweep. Defaults to auto.

  • reindex_coord (dict, optional) – Defaults to None, no reindexing. Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked if decode_coords=True.

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool) – If True, fixes erroneous second angle data. Defaults to False.

  • optional (bool) – Import optional mandatory data and metadata, defaults to True.

  • site_as_coords (bool) – Attach radar site-coordinates to Dataset, defaults to True.

  • engine (str) – Engine that will be passed to Xarray.open_dataset, defaults to “netcdf4”

Returns:

dtree (xarray.DataTree) – DataTree with CfRadial2 groups.

CfRadial2#

This sub-module contains the CfRadial2 reader for hierarchical radar datasets.

The reader opens a grouped dataset via xarray.open_datatree() and applies best-effort compatibility normalization to common institutional variations so the result better matches xradar’s FM301-oriented DataTree layout. Full FM301 validation is not currently performed.

Example:

import xradar as xd
dtree = xd.io.open_cfradial2_datatree(filename)

CfRadial2BackendEntrypoint

Xarray BackendEntrypoint for CfRadial2/FM301 grouped datasets.

open_cfradial2_datatree

Open a CfRadial2-like grouped dataset as xarray.DataTree.

class xradar.io.backends.cfradial2.CfRadial2BackendEntrypoint[source]#

Bases: BackendEntrypoint

Xarray BackendEntrypoint for CfRadial2/FM301 grouped datasets.

Keyword Arguments:
  • sweep (int, str, iterable, optional) – Sweep selection. Defaults to all available sweeps.

  • first_dim (str) – Can be time or auto. Defaults to time.

  • optional (bool) – Keep optional root variables when available. Defaults to True.

  • optional_groups (bool) – Include root metadata subgroups if present. Defaults to False.

  • kwargs (dict) – Additional kwargs are fed to xarray.open_datatree().

description: ClassVar[str] = 'Open CfRadial2/FM301 grouped datasets in Xarray'#
guess_can_open(filename_or_obj)[source]#

CfRadial2 file (netCDF/HDF5 with sweep groups, whose Conventions mention CF/Radial and whose root has sweep_group_name and time_coverage_start).

Files with sweep_start_ray_index (CfRadial1) and vendor files which use the CfRadial2 layout without the time coverage (e.g. WindCube) are not claimed.

open_dataset(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=False, group='sweep_0', first_dim='time', optional=True)[source]#

Backend open_dataset method used by Xarray in open_dataset().

open_datatree(filename_or_obj, **kwargs)[source]#

Open a CfRadial2/FM301 grouped file as xarray.DataTree. See open_groups_as_dict() for keyword arguments.

open_groups_as_dict(filename_or_obj, *, sweep=None, first_dim='time', optional=True, optional_groups=False, site_coords=True, netcdf_engine=None, **kwargs)[source]#

Open a CfRadial2/FM301 grouped file as a dict of normalized group datasets. Best-effort normalization of common institutional variations is applied so the result matches xradar’s FM301-oriented layout.

Parameters:
  • filename_or_obj (str, Path, or file-like) – Path or file-like object understood by the underlying reader.

  • mask_and_scale (bool or dict-like, optional) – Replace fill values with NA and apply scale_factor/add_offset decoding. See xarray.open_dataset(). Defaults to True.

  • decode_times (bool or dict-like, optional) – Decode CF time variables (calendar, units) into np.datetime64. Defaults to True.

  • concat_characters (bool or dict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults to True.

  • decode_coords (bool or {"coordinates", "all"}, optional) – Decode the CF coordinates attribute. Defaults to True (equivalent to "coordinates").

  • drop_variables (str or iterable of str, optional) – Names of variables to drop before processing.

  • use_cftime (bool, optional) – Force cftime decoding for time variables (instead of np.datetime64). Defaults to None (auto).

  • decode_timedelta (bool, optional) – Decode CF timedelta variables. Default mirrors decode_times unless the backend overrides it (cfradial1, cfradial2, and imd default to False).

  • sweep (int, str, or list of int/str, optional) – Sweep selection. None (default) returns all sweeps. An int or "sweep_N" string returns one sweep; a list returns the named subset.

  • first_dim ({"auto", "time"}, optional) – Leading dimension of each sweep dataset. "auto" picks azimuth (PPI) or elevation (RHI); "time" keeps the raw time axis. Default "auto" ("time" for cfradial2).

  • optional (bool, optional) – Include optional root variables when available. Defaults to True.

  • optional_groups (bool, optional) – Include the /radar_parameters, /georeferencing_correction, and /radar_calibration metadata subgroups under the root. Defaults to False.

  • site_coords (bool, optional) – Keep latitude/longitude/altitude as coordinates on the root dataset. CfRadial2 stores station coords at root by default; pass False to drop them. Defaults to True.

  • netcdf_engine (str, optional) – netCDF engine used to read the file (e.g. "netcdf4" or "h5netcdf"). Defaults to None (xarray’s choice).

Returns:

dict[str, xarray.Dataset] – CfRadial2 group paths (/, /sweep_N, optional /radar_parameters etc.) mapped to their datasets, ready for xarray.DataTree.from_dict().

supports_groups: ClassVar[bool] = True#
url: ClassVar[str] = 'https://xradar.rtfd.io/en/latest/io.html#cfradial2'#
xradar.io.backends.cfradial2.open_cfradial2_datatree(filename_or_obj: str | PathLike[str], **kwargs: Any) → DataTree[source]#

Open a CfRadial2-like grouped dataset as xarray.DataTree.

Deprecated since version Use: xd.open_datatree(file, engine="cfradial2") or xr.open_datatree(file, engine="cfradial2") instead.

Parameters:

filename_or_obj (str or PathLike) – Path or object understood by xarray.open_datatree().

Keyword Arguments:
  • sweep (int, str, iterable, optional) – Sweep selection. Defaults to all available sweeps.

  • first_dim (str) – Can be time or auto. Defaults to time.

  • optional (bool) – Keep optional root variables when available. Defaults to True.

  • optional_groups (bool) – Include root metadata subgroups if present. Defaults to False.

  • **kwargs (dict) – Additional keyword arguments passed to xarray.open_datatree().

Returns:

xarray.DataTree – Normalized DataTree containing root metadata and sweep groups.

GAMIC HDF5#

This sub-module contains the GAMIC HDF5 xarray backend for reading GAMIC HDF5-based radar data into Xarray structures as well as a reader to create a complete datatree.Datatree.

Code ported from wradlib.

Example:

import xradar as xd
dtree = xd.io.open_gamic_datatree(filename)

GamicBackendEntrypoint

Xarray BackendEntrypoint for GAMIC data.

open_gamic_datatree

Open GAMIC HDF5 dataset as xarray.DataTree.

class xradar.io.backends.gamic.GamicBackendEntrypoint[source]#

Bases: BackendEntrypoint

Xarray BackendEntrypoint for GAMIC data.

Keyword Arguments:
  • first_dim (str) – Can be time or auto first dimension. If set to auto, first dimension will be either azimuth or elevation depending on type of sweep. Defaults to auto.

  • reindex_coord (dict, optional) – Defaults to None, no reindexing. Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked if decode_coords=True.

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool) – For PPI only. If True, fixes erroneous second angle data. Defaults to False.

  • site_as_coords (bool) – Attach radar site-coordinates to Dataset, defaults to True.

  • kwargs (dict) – Additional kwargs are fed to xarray.open_dataset().

description: ClassVar[str] = 'Open GAMIC HDF5 (.h5, .hdf5, .mvol) using h5netcdf in Xarray'#
guess_can_open(filename_or_obj)[source]#

GAMIC HDF5 file (what and scan0 groups).

open_dataset(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, format=None, group='sweep_0', invalid_netcdf=None, phony_dims='access', decode_vlen_strings=True, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_as_coords=True)[source]#

Backend open_dataset method used by Xarray in open_dataset().

open_datatree(filename_or_obj, **kwargs)[source]#

Open a GAMIC HDF5 file as xarray.DataTree. See open_groups_as_dict() for keyword arguments.

open_groups_as_dict(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, format=None, invalid_netcdf=None, phony_dims='access', decode_vlen_strings=True, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_coords=True, sweep=None, optional=True, optional_groups=False)[source]#

Open a GAMIC HDF5 file as a CfRadial2-shaped dict of group datasets.

Parameters:
  • filename_or_obj (str, Path, or file-like) – Path or file-like object understood by the underlying reader.

  • mask_and_scale (bool or dict-like, optional) – Replace fill values with NA and apply scale_factor/add_offset decoding. See xarray.open_dataset(). Defaults to True.

  • decode_times (bool or dict-like, optional) – Decode CF time variables (calendar, units) into np.datetime64. Defaults to True.

  • concat_characters (bool or dict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults to True.

  • decode_coords (bool or {"coordinates", "all"}, optional) – Decode the CF coordinates attribute. Defaults to True (equivalent to "coordinates").

  • drop_variables (str or iterable of str, optional) – Names of variables to drop before processing.

  • use_cftime (bool, optional) – Force cftime decoding for time variables (instead of np.datetime64). Defaults to None (auto).

  • decode_timedelta (bool, optional) – Decode CF timedelta variables. Default mirrors decode_times unless the backend overrides it (cfradial1, cfradial2, and imd default to False).

  • sweep (int, str, or list of int/str, optional) – Sweep selection. None (default) returns all sweeps. An int or "sweep_N" string returns one sweep; a list returns the named subset.

  • first_dim ({"auto", "time"}, optional) – Leading dimension of each sweep dataset. "auto" picks azimuth (PPI) or elevation (RHI); "time" keeps the raw time axis. Default "auto" ("time" for cfradial2).

  • optional (bool, optional) – Include optional root variables when available. Defaults to True.

  • optional_groups (bool, optional) – Include the /radar_parameters, /georeferencing_correction, and /radar_calibration metadata subgroups under the root. Defaults to False.

  • format (str, optional) – h5netcdf format string. Defaults to None.

  • invalid_netcdf (bool, optional) – Accept HDF5 files that are not strictly NetCDF-conformant.

  • phony_dims ({"access", "sort", None}, optional) – How h5netcdf labels unnamed dimensions. Defaults to "access".

  • decode_vlen_strings (bool, optional) – Decode variable-length strings stored in HDF5. Defaults to True.

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked when decode_coords=True. Defaults to None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective with first_dim="auto". Defaults to False.

  • site_coords (bool, optional) – Attach latitude/longitude/altitude as coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults to True.

Returns:

dict[str, xarray.Dataset] – CfRadial2 group paths (/, /sweep_N, optional /radar_parameters etc.) mapped to their datasets, ready for xarray.DataTree.from_dict().

supports_groups: ClassVar[bool] = True#
url: ClassVar[str] = 'https://xradar.rtfd.io/en/latest/io.html#gamic-hdf5'#
xradar.io.backends.gamic.open_gamic_datatree(filename_or_obj, **kwargs)[source]#

Open GAMIC HDF5 dataset as xarray.DataTree.

Deprecated since version Use: xd.open_datatree(file, engine="gamic") instead.

ODIM_H5#

This sub-module contains the ODIM_H5 xarray backend for reading ODIM_H5-based radar data into Xarray structures as well as a reader to create a complete datatree.Datatree.

Code ported from wradlib.

Example:

import xradar as xd
dtree = xd.io.open_odim_datatree(filename)

OdimBackendEntrypoint

Xarray BackendEntrypoint for ODIM data.

open_odim_datatree

Open ODIM_H5 dataset as xarray.DataTree.

class xradar.io.backends.odim.OdimBackendEntrypoint[source]#

Bases: BackendEntrypoint

Xarray BackendEntrypoint for ODIM data.

Keyword Arguments:
  • first_dim (str) – Can be time or auto first dimension. If set to auto, first dimension will be either azimuth or elevation depending on type of sweep. Defaults to auto.

  • reindex_coord (dict, optional) – Defaults to None, no reindexing. Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked if decode_coords=True.

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool) – If True, fixes erroneous second angle data. Defaults to False.

  • site_as_coords (bool) – Attach radar site-coordinates to Dataset, defaults to True.

  • kwargs (dict) – Additional kwargs are fed to xarray.open_dataset().

description: ClassVar[str] = 'Open ODIM_H5 (.h5, .hdf5) using h5netcdf in Xarray'#
guess_can_open(filename_or_obj)[source]#

ODIM_H5 file (HDF5 with Conventions ODIM_H5/...).

open_dataset(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, format=None, group='sweep_0', invalid_netcdf=None, phony_dims='access', decode_vlen_strings=True, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_as_coords=True)[source]#

Backend open_dataset method used by Xarray in open_dataset().

open_datatree(filename_or_obj, **kwargs)[source]#

Open an ODIM_H5 file as xarray.DataTree.

Builds the tree from open_groups_as_dict() and keeps each group’s file, so close() releases it. See open_groups_as_dict() for keyword arguments.

open_groups_as_dict(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, format=None, invalid_netcdf=None, phony_dims='access', decode_vlen_strings=True, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_coords=True, sweep=None, optional=True, optional_groups=False)[source]#

Open an ODIM_H5 file as a CfRadial2-shaped dict of group datasets.

Parameters:
  • filename_or_obj (str, Path, or file-like) – Path or file-like object understood by the underlying reader.

  • mask_and_scale (bool or dict-like, optional) – Replace fill values with NA and apply scale_factor/add_offset decoding. See xarray.open_dataset(). Defaults to True.

  • decode_times (bool or dict-like, optional) – Decode CF time variables (calendar, units) into np.datetime64. Defaults to True.

  • concat_characters (bool or dict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults to True.

  • decode_coords (bool or {"coordinates", "all"}, optional) – Decode the CF coordinates attribute. Defaults to True (equivalent to "coordinates").

  • drop_variables (str or iterable of str, optional) – Names of variables to drop before processing.

  • use_cftime (bool, optional) – Force cftime decoding for time variables (instead of np.datetime64). Defaults to None (auto).

  • decode_timedelta (bool, optional) – Decode CF timedelta variables. Default mirrors decode_times unless the backend overrides it (cfradial1, cfradial2, and imd default to False).

  • sweep (int, str, or list of int/str, optional) – Sweep selection. None (default) returns all sweeps. An int or "sweep_N" string returns one sweep; a list returns the named subset.

  • first_dim ({"auto", "time"}, optional) – Leading dimension of each sweep dataset. "auto" picks azimuth (PPI) or elevation (RHI); "time" keeps the raw time axis. Default "auto" ("time" for cfradial2).

  • optional (bool, optional) – Include optional root variables when available. Defaults to True.

  • optional_groups (bool, optional) – Include the /radar_parameters, /georeferencing_correction, and /radar_calibration metadata subgroups under the root. Defaults to False.

  • format (str, optional) – h5netcdf format string. Defaults to None.

  • invalid_netcdf (bool, optional) – Accept HDF5 files that are not strictly NetCDF-conformant.

  • phony_dims ({"access", "sort", None}, optional) – How h5netcdf labels unnamed dimensions. Defaults to "access".

  • decode_vlen_strings (bool, optional) – Decode variable-length strings stored in HDF5. Defaults to True.

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked when decode_coords=True. Defaults to None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective with first_dim="auto". Defaults to False.

  • site_coords (bool, optional) – Attach latitude/longitude/altitude as coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults to True.

Returns:

dict[str, xarray.Dataset] – CfRadial2 group paths (/, /sweep_N, optional /radar_parameters etc.) mapped to their datasets, ready for xarray.DataTree.from_dict().

supports_groups: ClassVar[bool] = True#
url: ClassVar[str] = 'https://xradar.rtfd.io/en/latest/io.html#odim-h5'#
xradar.io.backends.odim.open_odim_datatree(filename_or_obj, **kwargs)[source]#

Open ODIM_H5 dataset as xarray.DataTree.

Deprecated since version Use: xd.open_datatree(file, engine="odim") or xr.open_datatree(file, engine="odim") instead.

Parameters:

filename_or_obj (str, Path, file-like or DataStore) – Strings and Path objects are interpreted as a path to a local or remote radar file

Keyword Arguments:
  • sweep (int, list of int, optional) – Sweep number(s) to extract, default to first sweep. If None, all sweeps are extracted into a list.

  • first_dim (str) – Can be time or auto first dimension. If set to auto, first dimension will be either azimuth or elevation depending on type of sweep. Defaults to auto.

  • reindex_coord (dict, optional) – Defaults to None, no reindexing. Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked if decode_coords=True.

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool) – If True, fixes erroneous second angle data. Defaults to False.

  • site_as_coords (bool) – Attach radar site-coordinates to Dataset, defaults to True.

  • kwargs (dict) – Additional kwargs are fed to xarray.open_dataset().

Returns:

dtree (xarray.DataTree) – DataTree

Furuno binary data#

Reads data from Furuno’s binary data formats

To read from Furuno files numpy.memmap is used to get access to the data. The Furuno header is read in any case into dedicated OrderedDict’s. Reading sweep data can be skipped by setting loaddata=False. By default, the data is decoded on the fly.

Using rawdata=True the data will be kept undecoded.

Code ported from wradlib.

Example:

import xradar as xd
dtree = xd.io.open_furuno_datatree(filename)

FurunoBackendEntrypoint

Xarray BackendEntrypoint for Furuno data.

open_furuno_datatree

Open FURUNO dataset as xarray.DataTree.

class xradar.io.backends.furuno.FurunoBackendEntrypoint[source]#

Bases: BackendEntrypoint

Xarray BackendEntrypoint for Furuno data.

description: ClassVar[str] = 'Open FURUNO (.scn, .scnx) in Xarray'#
guess_can_open(filename_or_obj)[source]#

Furuno SCN/SCNX, also gzip-compressed (header size and version).

open_dataset(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, group=None, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_as_coords=True, obsmode=None)[source]#

Backend open_dataset method used by Xarray in open_dataset().

open_datatree(filename_or_obj, **kwargs)[source]#

Open a Furuno SCN or SCNX file as xarray.DataTree. See open_groups_as_dict() for keyword arguments.

open_groups_as_dict(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_coords=True, sweep=None, optional=True, optional_groups=False, obsmode=None)[source]#

Open a Furuno SCN or SCNX file as a CfRadial2-shaped dict of group datasets.

Parameters:
  • filename_or_obj (str, Path, or file-like) – Path or file-like object understood by the underlying reader.

  • mask_and_scale (bool or dict-like, optional) – Replace fill values with NA and apply scale_factor/add_offset decoding. See xarray.open_dataset(). Defaults to True.

  • decode_times (bool or dict-like, optional) – Decode CF time variables (calendar, units) into np.datetime64. Defaults to True.

  • concat_characters (bool or dict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults to True.

  • decode_coords (bool or {"coordinates", "all"}, optional) – Decode the CF coordinates attribute. Defaults to True (equivalent to "coordinates").

  • drop_variables (str or iterable of str, optional) – Names of variables to drop before processing.

  • use_cftime (bool, optional) – Force cftime decoding for time variables (instead of np.datetime64). Defaults to None (auto).

  • decode_timedelta (bool, optional) – Decode CF timedelta variables. Default mirrors decode_times unless the backend overrides it (cfradial1, cfradial2, and imd default to False).

  • sweep (int, str, or list of int/str, optional) – Sweep selection. None (default) returns all sweeps. An int or "sweep_N" string returns one sweep; a list returns the named subset.

  • first_dim ({"auto", "time"}, optional) – Leading dimension of each sweep dataset. "auto" picks azimuth (PPI) or elevation (RHI); "time" keeps the raw time axis. Default "auto" ("time" for cfradial2).

  • optional (bool, optional) – Include optional root variables when available. Defaults to True.

  • optional_groups (bool, optional) – Include the /radar_parameters, /georeferencing_correction, and /radar_calibration metadata subgroups under the root. Defaults to False.

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked when decode_coords=True. Defaults to None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective with first_dim="auto". Defaults to False.

  • site_coords (bool, optional) – Attach latitude/longitude/altitude as coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults to True.

  • obsmode (int or None, optional) – Override the file’s observation-mode flag (rare; only needed for files written by older firmware). Defaults to None.

Returns:

dict[str, xarray.Dataset] – CfRadial2 group paths (/, /sweep_N, optional /radar_parameters etc.) mapped to their datasets, ready for xarray.DataTree.from_dict().

supports_groups: ClassVar[bool] = True#
url: ClassVar[str] = 'https://xradar.rtfd.io/en/latest/io.html#furuno-binary-data'#
xradar.io.backends.furuno.open_furuno_datatree(filename_or_obj, **kwargs)[source]#

Open FURUNO dataset as xarray.DataTree.

Deprecated since version Use: xd.open_datatree(file, engine="furuno") instead.

Rainbow Data I/O#

This sub-module contains the Rainbow xarray backend for reading data from Leonardo’s Rainbow5 data formats into Xarray structures as well as a reader to create a complete datatree.Datatree. For this mmap.mmap is utilized.

Code ported from wradlib.

Example:

import xradar as xd
dtree = xd.io.open_rainbow_datatree(filename)

RainbowBackendEntrypoint

Xarray BackendEntrypoint for Rainbow5 data.

open_rainbow_datatree

Open Rainbow5 dataset as xarray.DataTree.

class xradar.io.backends.rainbow.RainbowBackendEntrypoint[source]#

Bases: BackendEntrypoint

Xarray BackendEntrypoint for Rainbow5 data.

description: ClassVar[str] = 'Open Rainbow5 files in Xarray'#
guess_can_open(filename_or_obj)[source]#

Rainbow5 file (XML header starting with <volume).

open_dataset(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, group=None, reindex_coord=None, reindex_angle=False, first_dim='auto', site_as_coords=True)[source]#

Backend open_dataset method used by Xarray in open_dataset().

open_datatree(filename_or_obj, **kwargs)[source]#

Open a Rainbow5 file as xarray.DataTree. See open_groups_as_dict() for keyword arguments.

open_groups_as_dict(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, first_dim='auto', reindex_coord=None, reindex_angle=False, site_coords=True, sweep=None, optional=True, optional_groups=False)[source]#

Open a Rainbow5 file as a CfRadial2-shaped dict of group datasets.

Parameters:
  • filename_or_obj (str, Path, or file-like) – Path or file-like object understood by the underlying reader.

  • mask_and_scale (bool or dict-like, optional) – Replace fill values with NA and apply scale_factor/add_offset decoding. See xarray.open_dataset(). Defaults to True.

  • decode_times (bool or dict-like, optional) – Decode CF time variables (calendar, units) into np.datetime64. Defaults to True.

  • concat_characters (bool or dict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults to True.

  • decode_coords (bool or {"coordinates", "all"}, optional) – Decode the CF coordinates attribute. Defaults to True (equivalent to "coordinates").

  • drop_variables (str or iterable of str, optional) – Names of variables to drop before processing.

  • use_cftime (bool, optional) – Force cftime decoding for time variables (instead of np.datetime64). Defaults to None (auto).

  • decode_timedelta (bool, optional) – Decode CF timedelta variables. Default mirrors decode_times unless the backend overrides it (cfradial1, cfradial2, and imd default to False).

  • sweep (int, str, or list of int/str, optional) – Sweep selection. None (default) returns all sweeps. An int or "sweep_N" string returns one sweep; a list returns the named subset.

  • first_dim ({"auto", "time"}, optional) – Leading dimension of each sweep dataset. "auto" picks azimuth (PPI) or elevation (RHI); "time" keeps the raw time axis. Default "auto" ("time" for cfradial2).

  • optional (bool, optional) – Include optional root variables when available. Defaults to True.

  • optional_groups (bool, optional) – Include the /radar_parameters, /georeferencing_correction, and /radar_calibration metadata subgroups under the root. Defaults to False.

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked when decode_coords=True. Defaults to None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • site_coords (bool, optional) – Attach latitude/longitude/altitude as coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults to True.

Returns:

dict[str, xarray.Dataset] – CfRadial2 group paths (/, /sweep_N, optional /radar_parameters etc.) mapped to their datasets, ready for xarray.DataTree.from_dict().

supports_groups: ClassVar[bool] = True#
url: ClassVar[str] = 'https://xradar.rtfd.io/latest/io.html#rainbow-data-i-o'#
xradar.io.backends.rainbow.open_rainbow_datatree(filename_or_obj, **kwargs)[source]#

Open Rainbow5 dataset as xarray.DataTree.

Deprecated since version Use: xd.open_datatree(file, engine="rainbow") instead.

IRIS/Sigmet Data I/O#

Reads data from Vaisala’s IRIS data formats

IRIS (Vaisala Sigmet Interactive Radar Information System)

The decoders cite the IRIS Programming Guide M212927EN-B (2024), https://ftp.sigmet.vaisala.com/files/manuals/10.1.0/IRIS-Radar-Programming-Guide-M212927EN.pdf; the structure comments come from the earlier M211318EN-F.

To read from IRIS files numpy.memmap is used to get access to the data. The IRIS header (PRODUCT_HDR, INGEST_HEADER) is read in any case into dedicated OrderedDict’s. Reading sweep data can be skipped by setting loaddata=False. By default the data is decoded on the fly. Using rawdata=True the data will be kept undecoded.

Code ported from wradlib.

IrisBackendEntrypoint

Xarray BackendEntrypoint for IRIS/Sigmet data.

open_iris_datatree

Open Iris/Sigmet dataset as xarray.DataTree.

class xradar.io.backends.iris.IrisBackendEntrypoint[source]#

Bases: BackendEntrypoint

Xarray BackendEntrypoint for IRIS/Sigmet data.

description: ClassVar[str] = 'Open IRIS/Sigmet files in Xarray'#
guess_can_open(filename_or_obj)[source]#

IRIS/Sigmet RAW file (product_hdr structure, RAW product).

open_dataset(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, group=None, lock=None, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_as_coords=True, optional=True)[source]#

Backend open_dataset method used by Xarray in open_dataset().

open_datatree(filename_or_obj, **kwargs)[source]#

Open an Iris/Sigmet RAW file as xarray.DataTree. See open_groups_as_dict() for keyword arguments.

open_groups_as_dict(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, lock=None, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_coords=True, sweep=None, optional=True, optional_groups=False)[source]#

Open an Iris/Sigmet RAW file as a CfRadial2-shaped dict of group datasets.

Parameters:
  • filename_or_obj (str, Path, or file-like) – Path or file-like object understood by the underlying reader.

  • mask_and_scale (bool or dict-like, optional) – Replace fill values with NA and apply scale_factor/add_offset decoding. See xarray.open_dataset(). Defaults to True.

  • decode_times (bool or dict-like, optional) – Decode CF time variables (calendar, units) into np.datetime64. Defaults to True.

  • concat_characters (bool or dict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults to True.

  • decode_coords (bool or {"coordinates", "all"}, optional) – Decode the CF coordinates attribute. Defaults to True (equivalent to "coordinates").

  • drop_variables (str or iterable of str, optional) – Names of variables to drop before processing.

  • use_cftime (bool, optional) – Force cftime decoding for time variables (instead of np.datetime64). Defaults to None (auto).

  • decode_timedelta (bool, optional) – Decode CF timedelta variables. Default mirrors decode_times unless the backend overrides it (cfradial1, cfradial2, and imd default to False).

  • sweep (int, str, or list of int/str, optional) – Sweep selection. None (default) returns all sweeps. An int or "sweep_N" string returns one sweep; a list returns the named subset.

  • first_dim ({"auto", "time"}, optional) – Leading dimension of each sweep dataset. "auto" picks azimuth (PPI) or elevation (RHI); "time" keeps the raw time axis. Default "auto" ("time" for cfradial2).

  • optional (bool, optional) – Include optional root variables when available. Defaults to True.

  • optional_groups (bool, optional) – Include the /radar_parameters, /georeferencing_correction, and /radar_calibration metadata subgroups under the root. Defaults to False.

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked when decode_coords=True. Defaults to None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective with first_dim="auto". Defaults to False.

  • site_coords (bool, optional) – Attach latitude/longitude/altitude as coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults to True.

  • lock (threading.Lock or None, optional) – Reader lock for thread-safe access. Defaults to None.

Returns:

dict[str, xarray.Dataset] – CfRadial2 group paths (/, /sweep_N, optional /radar_parameters etc.) mapped to their datasets, ready for xarray.DataTree.from_dict().

supports_groups: ClassVar[bool] = True#
url: ClassVar[str] = 'https://xradar.rtfd.io/latest/io.html#iris-sigmet-data-i-o'#
xradar.io.backends.iris.open_iris_datatree(filename_or_obj, **kwargs)[source]#

Open Iris/Sigmet dataset as xarray.DataTree.

Deprecated since version Use: xd.open_datatree(file, engine="iris") instead.

StreamLine HPL#

This sub-module contains the StreamLine HPL xarray backend for reading StreamLine-based lidar data into Xarray structures.

Import of StreamLine .hpl (txt) files and save locally in directory. Therefore the data is converted into matrices with dimension “number of range gates” x “time stamp/rays”. In newer versions of the StreamLine software, the spectral width can be stored as additional parameter in the .hpl files.

HPLBackendEntrypoint

Xarray BackendEntrypoint for Halo Photonics Doppler processed lidar data.

open_hpl_datatree

Open Halo Photonics processed Doppler lidar dataset as xarray.DataTree.

class xradar.io.backends.hpl.HPLBackendEntrypoint[source]#

Bases: BackendEntrypoint

Xarray BackendEntrypoint for Halo Photonics Doppler processed lidar data.

Keyword Arguments:
  • first_dim (str) – Can be time or auto first dimension. If set to auto, first dimension will be either azimuth or elevation depending on type of sweep. Defaults to auto.

  • site_as_coords (bool) – Attach radar site-coordinates to Dataset, defaults to True.

  • kwargs (dict) – Additional kwargs are fed to xarray.open_dataset().

description: ClassVar[str] = 'Backend for reading Halo Photonics Doppler lidar processed data'#
guess_can_open(filename_or_obj)[source]#

Halo Photonics .hpl (text header starting with Filename:).

open_dataset(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, format=None, group='sweep_0', invalid_netcdf=None, phony_dims='access', decode_vlen_strings=True, first_dim='auto', reindex_coord=None, reindex_angle=False, site_as_coords=True, optional=True, latitude=0, longitude=0, altitude=0, transition_threshold_azi=0.01, transition_threshold_el=0.005)[source]#

Backend open_dataset method used by Xarray in open_dataset().

open_datatree(filename_or_obj, **kwargs)[source]#

Open a Halo Photonics .hpl file as xarray.DataTree. See open_groups_as_dict() for keyword arguments.

open_groups_as_dict(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, format=None, invalid_netcdf=None, phony_dims='access', decode_vlen_strings=True, first_dim='auto', reindex_coord=None, reindex_angle=False, site_coords=True, sweep=None, optional=True, optional_groups=False, latitude=0, longitude=0, altitude=0, transition_threshold_azi=0.01, transition_threshold_el=0.005)[source]#

Open a Halo Photonics Stream Line (.hpl) lidar file as a CfRadial2-shaped dict of group datasets.

Parameters:
  • filename_or_obj (str, Path, or file-like) – Path or file-like object understood by the underlying reader.

  • mask_and_scale (bool or dict-like, optional) – Replace fill values with NA and apply scale_factor/add_offset decoding. See xarray.open_dataset(). Defaults to True.

  • decode_times (bool or dict-like, optional) – Decode CF time variables (calendar, units) into np.datetime64. Defaults to True.

  • concat_characters (bool or dict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults to True.

  • decode_coords (bool or {"coordinates", "all"}, optional) – Decode the CF coordinates attribute. Defaults to True (equivalent to "coordinates").

  • drop_variables (str or iterable of str, optional) – Names of variables to drop before processing.

  • use_cftime (bool, optional) – Force cftime decoding for time variables (instead of np.datetime64). Defaults to None (auto).

  • decode_timedelta (bool, optional) – Decode CF timedelta variables. Default mirrors decode_times unless the backend overrides it (cfradial1, cfradial2, and imd default to False).

  • sweep (int, str, or list of int/str, optional) – Sweep selection. None (default) returns all sweeps. An int or "sweep_N" string returns one sweep; a list returns the named subset.

  • first_dim ({"auto", "time"}, optional) – Leading dimension of each sweep dataset. "auto" picks azimuth (PPI) or elevation (RHI); "time" keeps the raw time axis. Default "auto" ("time" for cfradial2).

  • optional (bool, optional) – Include optional root variables when available. Defaults to True.

  • optional_groups (bool, optional) – Include the /radar_parameters, /georeferencing_correction, and /radar_calibration metadata subgroups under the root. Defaults to False.

  • format (str, optional) – h5netcdf format string. Defaults to None.

  • invalid_netcdf (bool, optional) – Accept HDF5 files that are not strictly NetCDF-conformant.

  • phony_dims ({"access", "sort", None}, optional) – How h5netcdf labels unnamed dimensions. Defaults to "access".

  • decode_vlen_strings (bool, optional) – Decode variable-length strings stored in HDF5. Defaults to True.

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked when decode_coords=True. Defaults to None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • site_coords (bool, optional) – Attach latitude/longitude/altitude as coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults to True.

  • latitude (float, optional) – Override the site latitude (HPL files often lack geolocation).

  • longitude (float, optional) – Override the site longitude.

  • altitude (float, optional) – Override the site altitude above sea level (meters).

  • transition_threshold_azi (float, optional) – Azimuth-jump threshold (deg) for sweep boundary detection.

  • transition_threshold_el (float, optional) – Elevation-jump threshold (deg) for sweep boundary detection.

Returns:

dict[str, xarray.Dataset] – CfRadial2 group paths (/, /sweep_N, optional /radar_parameters etc.) mapped to their datasets, ready for xarray.DataTree.from_dict().

supports_groups: ClassVar[bool] = True#
url: ClassVar[str] = 'https://xradar.rtfd.io/en/latest/io.html#metek'#
xradar.io.backends.hpl.open_hpl_datatree(filename_or_obj, **kwargs)[source]#

Open Halo Photonics processed Doppler lidar dataset as xarray.DataTree.

Deprecated since version Use: xd.open_datatree(file, engine="hpl") instead.

NEXRAD Level2 Data I/O#

Reads data from NEXRAD Level2 data format

See https://www.roc.noaa.gov/WSR88D/BuildInfo/Files.aspx

Documents:
  • ICD 2620002 M ICD FOR RDA/RPG - Build RDA 11.5/RPG 13.0 (PDF)

  • ICD 2620010 E ICD FOR ARCHIVE II/USER - Build 12.0 (PDF)

To read from NEXRAD Level2 files numpy.memmap is used for uncompressed files (pre 2016-06-01) and bz2:BZ2Decompressor for BZ2 compressed data. The NEXRAD header (VOLUME_HEADER, MSG_HEADER) are read in any case into dedicated OrderedDict’s. Reading sweep data can be skipped by setting loaddata=False. By default, the data is decoded on the fly. Using rawdata=True the data will be kept undecoded.

Code adapted from Py-ART.

NexradLevel2BackendEntrypoint

Xarray BackendEntrypoint for NEXRAD Level2 Data

open_nexradlevel2_datatree

Open a NEXRAD Level2 dataset as xarray.DataTree.

class xradar.io.backends.nexrad_level2.NexradLevel2BackendEntrypoint[source]#

Bases: BackendEntrypoint

Xarray BackendEntrypoint for NEXRAD Level2 Data

description: ClassVar[str] = 'Open NEXRAD Level2 files in Xarray'#
guess_can_open(filename_or_obj)[source]#

NEXRAD Level II archive (AR2V / ARCHIVE2 volume header).

open_dataset(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, group=None, lock=None, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_as_coords=True, optional=True)[source]#

Backend open_dataset method used by Xarray in open_dataset().

open_datatree(filename_or_obj, **kwargs)[source]#

Open a NEXRAD Level II file as xarray.DataTree. See open_groups_as_dict() for keyword arguments.

open_groups_as_dict(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, sweep=None, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_coords=True, optional=True, optional_groups=False, incomplete_sweep='drop', lock=None, **kwargs)[source]#

Open a NEXRAD Level II file as a CfRadial2-shaped dict of group datasets. Accepts a single file path, a bytes buffer, or a list/tuple of LDM chunk paths (the first chunk must hold the AR2V volume header).

Parameters:
  • filename_or_obj (str, Path, or file-like) – Path or file-like object understood by the underlying reader.

  • mask_and_scale (bool or dict-like, optional) – Replace fill values with NA and apply scale_factor/add_offset decoding. See xarray.open_dataset(). Defaults to True.

  • decode_times (bool or dict-like, optional) – Decode CF time variables (calendar, units) into np.datetime64. Defaults to True.

  • concat_characters (bool or dict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults to True.

  • decode_coords (bool or {"coordinates", "all"}, optional) – Decode the CF coordinates attribute. Defaults to True (equivalent to "coordinates").

  • drop_variables (str or iterable of str, optional) – Names of variables to drop before processing.

  • use_cftime (bool, optional) – Force cftime decoding for time variables (instead of np.datetime64). Defaults to None (auto).

  • decode_timedelta (bool, optional) – Decode CF timedelta variables. Default mirrors decode_times unless the backend overrides it (cfradial1, cfradial2, and imd default to False).

  • sweep (int, str, or list of int/str, optional) – Sweep selection. None (default) returns all sweeps. An int or "sweep_N" string returns one sweep; a list returns the named subset.

  • first_dim ({"auto", "time"}, optional) – Leading dimension of each sweep dataset. "auto" picks azimuth (PPI) or elevation (RHI); "time" keeps the raw time axis. Default "auto" ("time" for cfradial2).

  • optional (bool, optional) – Include optional root variables when available. Defaults to True.

  • optional_groups (bool, optional) – Include the /radar_parameters, /georeferencing_correction, and /radar_calibration metadata subgroups under the root. Defaults to False.

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked when decode_coords=True. Defaults to None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective with first_dim="auto". Defaults to False.

  • site_coords (bool, optional) – Attach latitude/longitude/altitude as coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults to True.

  • incomplete_sweep ({"drop", "pad"}, optional) – How to handle sweeps with fewer rays than the VCP nominal count. "drop" (default) excludes them with a UserWarning; "pad" keeps them with NaN-filled rays so the reindexed azimuth grid is complete.

  • lock (threading.Lock or None, optional) – Reader lock for thread-safe access. Defaults to None.

Returns:

dict[str, xarray.Dataset] – CfRadial2 group paths (/, /sweep_N, optional /radar_parameters etc.) mapped to their datasets, ready for xarray.DataTree.from_dict().

supports_groups: ClassVar[bool] = True#
url: ClassVar[str] = 'tbd'#
xradar.io.backends.nexrad_level2.open_nexradlevel2_datatree(filename_or_obj, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, sweep=None, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_as_coords=True, optional=True, optional_groups=False, incomplete_sweep='drop', lock=None, **kwargs)[source]#

Open a NEXRAD Level2 dataset as xarray.DataTree.

This function loads NEXRAD Level2 radar data into a DataTree structure, which organizes radar sweeps as separate nodes. Provides options for decoding time and applying various transformations to the data.

Parameters:
  • filename_or_obj (str, Path, file-like, bytes, list, or DataStore) – The path or file-like object representing the radar file. Path-like objects are interpreted as local or remote paths. A list or tuple of chunk sources (bytes, file-like, or paths) will be concatenated before reading. When passing chunks, the S file (volume header) must be the first element and I/E chunks must follow in sequence order (.001, .002, …). Out-of-order chunks produce corrupted data or decompression errors.

  • mask_and_scale (bool, optional) – If True, replaces values in the dataset that match _FillValue with NaN and applies scale and offset adjustments. Default is True. The special moment codes below threshold (0) and range folded (1) are both decoded to NaN. Use mask_and_scale=False to get the raw codes, e.g. to keep range folded gates distinguishable.

  • decode_times (bool, optional) – If True, decodes time variables according to CF conventions. Default is True.

  • concat_characters (bool, optional) – If True, concatenates character arrays along the last dimension, forming string arrays. Default is True.

  • decode_coords (bool, optional) – If True, decodes the “coordinates” attribute to identify coordinates in the resulting dataset. Default is True.

  • drop_variables (str or list of str, optional) – Specifies variables to exclude from the dataset. Useful for removing problematic or inconsistent variables. Default is None.

  • use_cftime (bool, optional) – If True, uses cftime objects to represent time variables; if False, uses np.datetime64 objects. If None, chooses the best format automatically. Default is None.

  • decode_timedelta (bool, optional) – If True, decodes variables with units of time (e.g., seconds, minutes) into timedelta objects. If False, leaves them as numeric values. Default is None.

  • sweep (int or list of int, optional) – Sweep numbers to extract from the dataset. If None, extracts all sweeps into a list. Default is the first sweep.

  • first_dim ({"time", "auto"}, optional) – Defines the first dimension for each sweep. If “time,” uses time as the first dimension. If “auto,” determines the first dimension based on the sweep type (azimuth or elevation). Default is “auto.”

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(). Only used if decode_coords=True. Default is None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool, optional) – If True, corrects errors in the second angle data, such as misaligned elevation or azimuth values. Default is False.

  • site_as_coords (bool, optional) – Attaches radar site coordinates to the dataset if True. Default is True.

  • optional (bool, optional) – If True, suppresses errors for optional dataset attributes, making them optional instead of required. Default is True.

  • optional_groups (bool, optional) – If True, includes /radar_parameters, /georeferencing_correction and /radar_calibration metadata subgroups in the DataTree. These groups are often empty or sparsely populated. Default is False.

  • incomplete_sweep ({"drop", "pad"}, optional) – How to handle incomplete sweeps (sweeps that were force-closed because the data ended mid-sweep, e.g. chunk files). "drop" (default) excludes incomplete sweeps and emits a warning. "pad" includes them, reindexing to a full azimuth grid with NaN-filled rays for missing positions.

  • kwargs (dict) – Additional keyword arguments passed to xarray.open_dataset.

Returns:

dtree (xarray.DataTree) – An xarray.DataTree representing the radar data organized by sweeps.

Datamet#

This sub-module contains the Datamet xarray backend for reading Datamet-based radar data into Xarray structures.

DataMetBackendEntrypoint

Xarray BackendEntrypoint for DataMet data.

open_datamet_datatree

Open DataMet dataset as xarray.DataTree.

class xradar.io.backends.datamet.DataMetBackendEntrypoint[source]#

Bases: BackendEntrypoint

Xarray BackendEntrypoint for DataMet data.

description: ClassVar[str] = 'Open DataMet files in Xarray'#
guess_can_open(filename_or_obj)[source]#

DataMet volume (tar archive with navigation.txt).

open_dataset(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, group=None, reindex_coord=None, reindex_angle=False, first_dim='auto', site_as_coords=True)[source]#

Backend open_dataset method used by Xarray in open_dataset().

open_datatree(filename_or_obj, **kwargs)[source]#

Open a DataMet archive as xarray.DataTree. See open_groups_as_dict() for keyword arguments.

open_groups_as_dict(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, first_dim='auto', reindex_coord=None, reindex_angle=False, site_coords=True, sweep=None, optional=True, optional_groups=False)[source]#

Open a DataMet (Servizio Meteorologico Italiano) .tar.gz archive as a CfRadial2-shaped dict of group datasets.

Parameters:
  • filename_or_obj (str, Path, or file-like) – Path or file-like object understood by the underlying reader.

  • mask_and_scale (bool or dict-like, optional) – Replace fill values with NA and apply scale_factor/add_offset decoding. See xarray.open_dataset(). Defaults to True.

  • decode_times (bool or dict-like, optional) – Decode CF time variables (calendar, units) into np.datetime64. Defaults to True.

  • concat_characters (bool or dict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults to True.

  • decode_coords (bool or {"coordinates", "all"}, optional) – Decode the CF coordinates attribute. Defaults to True (equivalent to "coordinates").

  • drop_variables (str or iterable of str, optional) – Names of variables to drop before processing.

  • use_cftime (bool, optional) – Force cftime decoding for time variables (instead of np.datetime64). Defaults to None (auto).

  • decode_timedelta (bool, optional) – Decode CF timedelta variables. Default mirrors decode_times unless the backend overrides it (cfradial1, cfradial2, and imd default to False).

  • sweep (int, str, or list of int/str, optional) – Sweep selection. None (default) returns all sweeps. An int or "sweep_N" string returns one sweep; a list returns the named subset.

  • first_dim ({"auto", "time"}, optional) – Leading dimension of each sweep dataset. "auto" picks azimuth (PPI) or elevation (RHI); "time" keeps the raw time axis. Default "auto" ("time" for cfradial2).

  • optional (bool, optional) – Include optional root variables when available. Defaults to True.

  • optional_groups (bool, optional) – Include the /radar_parameters, /georeferencing_correction, and /radar_calibration metadata subgroups under the root. Defaults to False.

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked when decode_coords=True. Defaults to None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • site_coords (bool, optional) – Attach latitude/longitude/altitude as coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults to True.

Returns:

dict[str, xarray.Dataset] – CfRadial2 group paths (/, /sweep_N, optional /radar_parameters etc.) mapped to their datasets, ready for xarray.DataTree.from_dict().

supports_groups: ClassVar[bool] = True#
url: ClassVar[str] = 'https://xradar.rtfd.io/latest/io.html#datamet-data-i-o'#
xradar.io.backends.datamet.open_datamet_datatree(filename_or_obj, **kwargs)[source]#

Open DataMet dataset as xarray.DataTree.

Deprecated since version Use: xd.open_datatree(file, engine="datamet") instead.

Metek MRR2 raw and processed data#

Read data from METEK’s MRR-2 raw (.raw) and processed (.pro, .avg) files.

Example:

import xradar as xd
ds = xr.open_dataset('0308.pro', engine='metek')

MRRBackendEntrypoint

Xarray BackendEntrypoint for Metek MRR2 data.

open_metek_datatree

Open Metek MRR2 dataset as xarray.DataTree.

class xradar.io.backends.metek.MRRBackendEntrypoint[source]#

Bases: BackendEntrypoint

Xarray BackendEntrypoint for Metek MRR2 data.

Keyword Arguments:
  • first_dim (str) – Can be time or auto first dimension. If set to auto, first dimension will be either azimuth or elevation depending on type of sweep. Defaults to auto.

  • site_as_coords (bool) – Attach radar site-coordinates to Dataset, defaults to True.

  • kwargs (dict) – Additional kwargs are fed to xarray.open_dataset().

description: ClassVar[str] = 'Backend for reading Metek MRR2 processed and raw data'#
guess_can_open(filename_or_obj)[source]#

Metek MRR file (header lines starting with MRR).

open_dataset(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, format=None, group='/', invalid_netcdf=None, phony_dims='access', decode_vlen_strings=True, first_dim='auto', site_as_coords=True, optional=True)[source]#

Backend open_dataset method used by Xarray in open_dataset().

open_datatree(filename_or_obj, **kwargs)[source]#

Open a Metek MRR2 file as xarray.DataTree. See open_groups_as_dict() for keyword arguments.

open_groups_as_dict(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, format=None, invalid_netcdf=None, phony_dims='access', decode_vlen_strings=True, first_dim='auto', site_coords=True, sweep=None, optional=True, optional_groups=False)[source]#

Open a Metek MRR2 (.ave/.pro/.raw) file as a CfRadial2-shaped dict of group datasets. MRR2 is a vertically pointing radar — the output contains one sweep_0 group with all profiles.

Parameters:
  • filename_or_obj (str, Path, or file-like) – Path or file-like object understood by the underlying reader.

  • mask_and_scale (bool or dict-like, optional) – Replace fill values with NA and apply scale_factor/add_offset decoding. See xarray.open_dataset(). Defaults to True.

  • decode_times (bool or dict-like, optional) – Decode CF time variables (calendar, units) into np.datetime64. Defaults to True.

  • concat_characters (bool or dict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults to True.

  • decode_coords (bool or {"coordinates", "all"}, optional) – Decode the CF coordinates attribute. Defaults to True (equivalent to "coordinates").

  • drop_variables (str or iterable of str, optional) – Names of variables to drop before processing.

  • use_cftime (bool, optional) – Force cftime decoding for time variables (instead of np.datetime64). Defaults to None (auto).

  • decode_timedelta (bool, optional) – Decode CF timedelta variables. Default mirrors decode_times unless the backend overrides it (cfradial1, cfradial2, and imd default to False).

  • sweep (int, str, or list of int/str, optional) – Sweep selection. None (default) returns all sweeps. An int or "sweep_N" string returns one sweep; a list returns the named subset.

  • first_dim ({"auto", "time"}, optional) – Leading dimension of each sweep dataset. "auto" picks azimuth (PPI) or elevation (RHI); "time" keeps the raw time axis. Default "auto" ("time" for cfradial2).

  • optional (bool, optional) – Include optional root variables when available. Defaults to True.

  • optional_groups (bool, optional) – Include the /radar_parameters, /georeferencing_correction, and /radar_calibration metadata subgroups under the root. Defaults to False.

  • format (str, optional) – h5netcdf format string. Defaults to None.

  • invalid_netcdf (bool, optional) – Accept HDF5 files that are not strictly NetCDF-conformant.

  • phony_dims ({"access", "sort", None}, optional) – How h5netcdf labels unnamed dimensions. Defaults to "access".

  • decode_vlen_strings (bool, optional) – Decode variable-length strings stored in HDF5. Defaults to True.

  • site_coords (bool, optional) – Attach latitude/longitude/altitude as coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults to True.

Returns:

dict[str, xarray.Dataset] – CfRadial2 group paths (/, /sweep_N, optional /radar_parameters etc.) mapped to their datasets, ready for xarray.DataTree.from_dict().

supports_groups: ClassVar[bool] = True#
url: ClassVar[str] = 'https://xradar.rtfd.io/en/latest/io.html#metek'#
xradar.io.backends.metek.open_metek_datatree(filename_or_obj, **kwargs)[source]#

Open Metek MRR2 dataset as xarray.DataTree.

Deprecated since version Use: xd.open_datatree(file, engine="metek") instead.

Universal Format UF#

Reads data from UF data format

IRIS (Vaisala Sigmet Interactive Radar Information System)

See M211318EN-F Programming Guide ftp://ftp.sigmet.com/outgoing/manuals/ or https://www.eol.ucar.edu/sites/default/files/files_live/private/UfDoc.txt

UFBackendEntrypoint

Xarray BackendEntrypoint for Universal Format (UF) data.

open_uf_datatree

Open a Universal Format (UF) dataset as xarray.DataTree.

class xradar.io.backends.uf.UFBackendEntrypoint[source]#

Bases: BackendEntrypoint

Xarray BackendEntrypoint for Universal Format (UF) data.

description: ClassVar[str] = 'Open Universal Format (UF) files in Xarray'#
guess_can_open(filename_or_obj)[source]#

Universal Format, UF at the start of the first record.

open_dataset(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, group=None, lock=None, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_as_coords=True, optional=True)[source]#

Backend open_dataset method used by Xarray in open_dataset().

open_datatree(filename_or_obj, **kwargs)[source]#

Open a Universal Format (UF) file as xarray.DataTree. See open_groups_as_dict() for keyword arguments.

open_groups_as_dict(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, sweep=None, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_coords=True, optional=True, optional_groups=False, lock=None, **kwargs)[source]#

Open a Universal Format (UF) file as a CfRadial2-shaped dict of group datasets.

Parameters:
  • filename_or_obj (str, Path, or file-like) – Path or file-like object understood by the underlying reader.

  • mask_and_scale (bool or dict-like, optional) – Replace fill values with NA and apply scale_factor/add_offset decoding. See xarray.open_dataset(). Defaults to True.

  • decode_times (bool or dict-like, optional) – Decode CF time variables (calendar, units) into np.datetime64. Defaults to True.

  • concat_characters (bool or dict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults to True.

  • decode_coords (bool or {"coordinates", "all"}, optional) – Decode the CF coordinates attribute. Defaults to True (equivalent to "coordinates").

  • drop_variables (str or iterable of str, optional) – Names of variables to drop before processing.

  • use_cftime (bool, optional) – Force cftime decoding for time variables (instead of np.datetime64). Defaults to None (auto).

  • decode_timedelta (bool, optional) – Decode CF timedelta variables. Default mirrors decode_times unless the backend overrides it (cfradial1, cfradial2, and imd default to False).

  • sweep (int, str, or list of int/str, optional) – Sweep selection. None (default) returns all sweeps. An int or "sweep_N" string returns one sweep; a list returns the named subset.

  • first_dim ({"auto", "time"}, optional) – Leading dimension of each sweep dataset. "auto" picks azimuth (PPI) or elevation (RHI); "time" keeps the raw time axis. Default "auto" ("time" for cfradial2).

  • optional (bool, optional) – Include optional root variables when available. Defaults to True.

  • optional_groups (bool, optional) – Include the /radar_parameters, /georeferencing_correction, and /radar_calibration metadata subgroups under the root. Defaults to False.

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked when decode_coords=True. Defaults to None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective with first_dim="auto". Defaults to False.

  • site_coords (bool, optional) – Attach latitude/longitude/altitude as coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults to True.

  • lock (threading.Lock or None, optional) – Reader lock for thread-safe access. Defaults to None.

Returns:

dict[str, xarray.Dataset] – CfRadial2 group paths (/, /sweep_N, optional /radar_parameters etc.) mapped to their datasets, ready for xarray.DataTree.from_dict().

supports_groups: ClassVar[bool] = True#
url: ClassVar[str] = 'https://xradar.rtfd.io/latest/io.html#uf-data-i-o'#
xradar.io.backends.uf.open_uf_datatree(filename_or_obj, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, sweep=None, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_as_coords=True, optional=True, optional_groups=False, lock=None, **kwargs)[source]#

Open a Universal Format (UF) dataset as xarray.DataTree.

Deprecated since version Use: xd.open_datatree(file, engine="uf") instead.

This function loads UF radar data into a DataTree structure, which organizes radar sweeps as separate nodes. Provides options for decoding time and applying various transformations to the data.

Parameters:
  • filename_or_obj (str, Path, file-like, or DataStore) – The path or file-like object representing the radar file. Path-like objects are interpreted as local or remote paths.

  • mask_and_scale (bool, optional) – If True, replaces values in the dataset that match _FillValue with NaN and applies scale and offset adjustments. Default is True.

  • decode_times (bool, optional) – If True, decodes time variables according to CF conventions. Default is True.

  • concat_characters (bool, optional) – If True, concatenates character arrays along the last dimension, forming string arrays. Default is True.

  • decode_coords (bool, optional) – If True, decodes the “coordinates” attribute to identify coordinates in the resulting dataset. Default is True.

  • drop_variables (str or list of str, optional) – Specifies variables to exclude from the dataset. Useful for removing problematic or inconsistent variables. Default is None.

  • use_cftime (bool, optional) – If True, uses cftime objects to represent time variables; if False, uses np.datetime64 objects. If None, chooses the best format automatically. Default is None.

  • decode_timedelta (bool, optional) – If True, decodes variables with units of time (e.g., seconds, minutes) into timedelta objects. If False, leaves them as numeric values. Default is None.

  • sweep (int or list of int, optional) – Sweep numbers to extract from the dataset. Default is None, which extracts all sweeps.

  • first_dim ({"time", "auto"}, optional) – Defines the first dimension for each sweep. If “time,” uses time as the first dimension. If “auto,” determines the first dimension based on the sweep type (azimuth or elevation). Default is “auto.”

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(). Only used if decode_coords=True. Default is None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool, optional) – If True, corrects errors in the second angle data, such as misaligned elevation or azimuth values. Default is False.

  • site_as_coords (bool, optional) – Attaches radar site coordinates to the dataset if True. Default is True.

  • optional (bool, optional) – If True, suppresses errors for optional dataset attributes, making them optional instead of required. Default is True.

  • optional_groups (bool, optional) – If True, adds the /radar_parameters, /georeferencing_correction and /radar_calibration metadata groups. Default is False.

  • lock (threading.Lock or None, optional) – Lock used when reading the file. Default is None (the UF lock).

  • kwargs (dict) – Additional keyword arguments passed to xarray.open_datatree().

Returns:

dtree (xarray.DataTree) – An xarray.DataTree representing the radar data organized by sweeps.

IMD#

This sub-module contains the xarray backend for reading India Meteorological Department (IMD) radar NetCDF files, which use a NetCDF4 container with an IRIS-inspired variable layout. Each IMD file stores a single sweep; a complete volume is typically assembled from 2-3 files (long-range PPI) up to 9-10 files (short-range, high-resolution PPI).

Code ported from radarx[syedhamidali/radarx].

Example:

import xradar as xd

# Single sweep via xarray engine
ds = xr.open_dataset("sweep_0.nc", engine="imd")

# Single-sweep DataTree
dtree = xd.io.open_imd_datatree("sweep_0.nc")

# Multi-sweep volume DataTree
dtree = xd.io.open_imd_datatree(["sweep_0.nc", "sweep_1.nc", ...])

IMDBackendEntrypoint

Xarray BackendEntrypoint for India Meteorological Department (IMD) radar files.

open_imd_datatree

Open IMD radar file(s) as a xarray.DataTree.

open_imd_volumes

Open a directory of IMD files as a multi-volume xarray.DataTree.

group_imd_files

Group IMD sweep files into volumes by filename stem.

class xradar.io.backends.imd.IMDBackendEntrypoint[source]#

Bases: BackendEntrypoint

Xarray BackendEntrypoint for India Meteorological Department (IMD) radar files.

IMD provides one NetCDF file per sweep. Open a single file with xr.open_dataset(file, engine="imd") to get a CfRadial2-compatible sweep xarray.Dataset. To assemble a multi-sweep volume, use open_imd_datatree() with a list of files.

Keyword Arguments:
  • first_dim (str) – Can be time or auto (default). auto selects azimuth (PPI) or elevation (RHI) as the first dimension.

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(). Defaults to None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • site_as_coords (bool) – If True (default), promote latitude/longitude/altitude to Dataset coordinates.

description: ClassVar[str] = 'Open India Meteorological Department (IMD) radar NetCDF files in Xarray'#
guess_can_open(filename_or_obj)[source]#

IMD IRIS-netCDF file (radialAzim and elevationAngle).

open_dataset(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, format=None, group=None, first_dim='auto', reindex_coord=None, reindex_angle=False, site_as_coords=True)[source]#

Backend open_dataset method used by Xarray in open_dataset().

open_datatree(filename_or_obj, **kwargs)[source]#

Open a single IMD NetCDF file as xarray.DataTree. See open_groups_as_dict() for keyword arguments.

open_groups_as_dict(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=False, sweep=None, first_dim='auto', reindex_coord=None, reindex_angle=False, site_coords=True, optional_groups=False)[source]#

Open a single IMD (India Meteorological Department) NetCDF file as a CfRadial2-shaped dict of group datasets. Single-file only — for multi-file IMD volumes use open_imd_datatree().

Parameters:
  • filename_or_obj (str, Path, or file-like) – Path or file-like object understood by the underlying reader.

  • mask_and_scale (bool or dict-like, optional) – Replace fill values with NA and apply scale_factor/add_offset decoding. See xarray.open_dataset(). Defaults to True.

  • decode_times (bool or dict-like, optional) – Decode CF time variables (calendar, units) into np.datetime64. Defaults to True.

  • concat_characters (bool or dict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults to True.

  • decode_coords (bool or {"coordinates", "all"}, optional) – Decode the CF coordinates attribute. Defaults to True (equivalent to "coordinates").

  • drop_variables (str or iterable of str, optional) – Names of variables to drop before processing.

  • use_cftime (bool, optional) – Force cftime decoding for time variables (instead of np.datetime64). Defaults to None (auto).

  • decode_timedelta (bool, optional) – Decode CF timedelta variables. Default mirrors decode_times unless the backend overrides it (cfradial1, cfradial2, and imd default to False).

  • sweep (int, str, or list of int/str, optional) – Sweep selection. None (default) returns all sweeps. An int or "sweep_N" string returns one sweep; a list returns the named subset.

  • first_dim ({"auto", "time"}, optional) – Leading dimension of each sweep dataset. "auto" picks azimuth (PPI) or elevation (RHI); "time" keeps the raw time axis. Default "auto" ("time" for cfradial2).

  • optional_groups (bool, optional) – Include the /radar_parameters, /georeferencing_correction, and /radar_calibration metadata subgroups under the root. Defaults to False.

  • sweep (int, str or list, optional) – IMD files hold one sweep, so only None, 0 or "sweep_0" are accepted. Defaults to None.

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked when decode_coords=True. Defaults to None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • site_coords (bool, optional) – Attach latitude/longitude/altitude as coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults to True.

Returns:

dict[str, xarray.Dataset] – CfRadial2 group paths (/, /sweep_N, optional /radar_parameters etc.) mapped to their datasets, ready for xarray.DataTree.from_dict().

supports_groups: ClassVar[bool] = True#
url: ClassVar[str] = 'https://xradar.rtfd.io/en/latest/io.html#imd'#
xradar.io.backends.imd.group_imd_files(paths)[source]#

Group IMD sweep files into volumes by filename stem.

IMD distributes one sweep per file. Files of a single volume share a common stem ending in .nc; additional sweeps in the same volume get numeric suffixes:

GOA210515003646-IMD-C.nc        <- sweep 0
GOA210515003646-IMD-C.nc.1      <- sweep 1
...
GOA210515003646-IMD-C.nc.9      <- sweep 9

A new volume changes the timestamp component of the stem.

Parameters:

paths (str, Path, or iterable of those) –

  • A directory path – all IMD files inside are grouped.

  • A glob pattern string – files matching the glob are grouped.

  • An iterable of file paths – grouped as-is.

Returns:

list[list[str]] – One list of absolute paths per detected volume, inner lists in sweep order (.nc, .nc.1, …).

Examples

>>> import xradar as xd
>>> for group in xd.io.group_imd_files("/data/goa"):
...     dtree = xd.io.open_imd_datatree(group)
xradar.io.backends.imd.open_imd_datatree(filename_or_obj, **kwargs)[source]#

Open IMD radar file(s) as a xarray.DataTree.

IMD stores one sweep per NetCDF file. A volume is assembled from multiple files (typically 2-3 for long-range PPI or 9-10 for short-range, high-resolution PPI).

  • Single file path -> single-sweep DataTree.

  • List of file paths -> single volume DataTree. Multi-file stacking is delegated to xradar.util.create_volume(), which sorts sweeps by time and supports time_coverage_start, time_coverage_end, min_angle, max_angle filtering.

Note

When opening a single IMD sweep file as a DataTree, prefer xd.open_datatree(file, engine="imd") (or the xarray-native xr.open_datatree(file, engine="imd")). This function remains the documented API for the multi-file path because IMD volumes span multiple files, which the engine="imd" registry entry does not support.

To split a directory of mixed-volume files into per-volume groups, use group_imd_files() first:

for group in xd.io.group_imd_files("/data/imd"):
    dtree = xd.io.open_imd_datatree(group)
Parameters:

filename_or_obj (str, Path, or list/tuple of those) – Single IMD file path, or a list of paths making up one volume.

Keyword Arguments:
  • first_dim (str) – "auto" (default) or "time".

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range().

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • site_as_coords (bool) – Attach station variables as coordinates on sweep Datasets. site_coords is accepted as an alias.

  • optional_groups (bool) – Include /radar_parameters, /georeferencing_correction and /radar_calibration subgroups. Defaults to False. With multiple files the values the files disagree about are left out of the groups, with a UserWarning.

  • volume_number (time_coverage_start, time_coverage_end, min_angle, max_angle,) – Forwarded to xradar.util.create_volume() when multi-file input is provided.

Returns:

dtree (xarray.DataTree) – CfRadial2-style DataTree with / root and sweep_N children.

xradar.io.backends.imd.open_imd_volumes(paths, **kwargs)[source]#

Open a directory of IMD files as a multi-volume xarray.DataTree.

Groups files by filename stem via group_imd_files(), opens each group as a CfRadial2 volume via open_imd_datatree(), and nests them under zero-padded vcp_NN child nodes of a parent root. vcp stands for volume coverage pattern. Padding width is chosen so the child names sort lexically (e.g. 121 volumes -> vcp_000 .. vcp_120).

Parameters:

paths (str, Path, or iterable of those) – Same as group_imd_files(): directory, glob, or list.

:keyword All kwargs are forwarded to open_imd_datatree() (applied per: :keyword volume). Typical: :kwtype volume). Typical: first_dim, reindex_coord, site_as_coords, :keyword optional_groups, min_angle, max_angle.:

Returns:

dtree (xarray.DataTree) –

Root with vcp_NN children, each a full CfRadial2 volume tree:

/
├── vcp_00/
│   ├── (root: sweep_group_name, sweep_fixed_angle, ...)
│   ├── sweep_0
│   ├── sweep_1
│   └── ...
├── vcp_01/
└── ...

Examples

>>> import xradar as xd
>>> tree = xd.io.open_imd_volumes("/data/JPR220822IMD-B")
>>> tree["vcp_00/sweep_0"].dataset["DBZH"]

Engine discovery#

Find the xradar backend engine which can open a given file, based on the backends’ guess_can_open.

discover_engine

Find the xradar engine which can open the given file.

list_xradar_engines

Names of the xarray backend engines provided by xradar.

xradar.io.backends.discover.discover_engine(filename_or_obj)[source]#

Find the xradar engine which can open the given file.

Each xradar backend checks the file with its guess_can_open (format signatures, e.g. AR2V for NEXRAD Level II, ODIM_H5 conventions in HDF5 files), see list_xradar_engines().

Parameters:

filename_or_obj (str, os.PathLike, bytes or file-like) – Radar file.

Returns:

engine (str) – Name of the engine, to be used with e.g. xr.open_dataset(filename, engine=engine, group="sweep_0").

Raises:

ValueError – If no xradar engine can open the file.

Examples

>>> engine = xd.io.discover_engine(filename)
>>> ds = xr.open_dataset(filename, engine=engine, group="sweep_0")
xradar.io.backends.discover.list_xradar_engines()[source]#

Names of the xarray backend engines provided by xradar.

Returns:

engines (list of str)

class xradar.io.backends.CfRadial1BackendEntrypoint[source]#

Bases: BackendEntrypoint

Xarray BackendEntrypoint for CfRadial1 data.

Keyword Arguments:
  • first_dim (str) – Can be time or auto first dimension. If set to auto, first dimension will be either azimuth or elevation depending on type of sweep. Defaults to auto.

  • reindex_coord (dict, optional) – Defaults to None, no reindexing. Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked if decode_coords=True.

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool) – For PPI only. If True, fixes erroneous second angle data. Defaults to False.

  • site_as_coords (bool) – Attach radar site-coordinates to Dataset, defaults to True.

  • kwargs (dict) – Additional kwargs are fed to xarray.open_dataset().

description: ClassVar[str] = 'Open CfRadial1 (.nc, .nc4) using netCDF4 in Xarray'#
guess_can_open(filename_or_obj)[source]#

CfRadial1 file (netCDF with sweep_start_ray_index and a Conventions or version mentioning CF/Radial).

open_dataset(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=False, format=None, group='/', first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_as_coords=True, optional=True)[source]#

Backend open_dataset method used by Xarray in open_dataset().

open_datatree(filename_or_obj, **kwargs)[source]#

Open a CfRadial1 file as xarray.DataTree. See open_groups_as_dict() for keyword arguments.

open_groups_as_dict(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=False, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_coords=True, optional=True, optional_groups=False, sweep=None, netcdf_engine='netcdf4')[source]#

Open a CfRadial1 file as a CfRadial2-shaped dict of group datasets.

Parameters:
  • filename_or_obj (str, Path, or file-like) – Path or file-like object understood by the underlying reader.

  • mask_and_scale (bool or dict-like, optional) – Replace fill values with NA and apply scale_factor/add_offset decoding. See xarray.open_dataset(). Defaults to True.

  • decode_times (bool or dict-like, optional) – Decode CF time variables (calendar, units) into np.datetime64. Defaults to True.

  • concat_characters (bool or dict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults to True.

  • decode_coords (bool or {"coordinates", "all"}, optional) – Decode the CF coordinates attribute. Defaults to True (equivalent to "coordinates").

  • drop_variables (str or iterable of str, optional) – Names of variables to drop before processing.

  • use_cftime (bool, optional) – Force cftime decoding for time variables (instead of np.datetime64). Defaults to None (auto).

  • decode_timedelta (bool, optional) – Decode CF timedelta variables. Default mirrors decode_times unless the backend overrides it (cfradial1, cfradial2, and imd default to False).

  • sweep (int, str, or list of int/str, optional) – Sweep selection. None (default) returns all sweeps. An int or "sweep_N" string returns one sweep; a list returns the named subset.

  • first_dim ({"auto", "time"}, optional) – Leading dimension of each sweep dataset. "auto" picks azimuth (PPI) or elevation (RHI); "time" keeps the raw time axis. Default "auto" ("time" for cfradial2).

  • optional (bool, optional) – Include optional root variables when available. Defaults to True.

  • optional_groups (bool, optional) – Include the /radar_parameters, /georeferencing_correction, and /radar_calibration metadata subgroups under the root. Defaults to False.

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked when decode_coords=True. Defaults to None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective with first_dim="auto". Defaults to False.

  • site_coords (bool, optional) – Attach latitude/longitude/altitude as coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults to True.

  • netcdf_engine ({"netcdf4", "h5netcdf"}, optional) – Underlying NetCDF engine used by xr.open_dataset to read the CfRadial1 file. Defaults to "netcdf4".

Returns:

dict[str, xarray.Dataset] – CfRadial2 group paths (/, /sweep_N, optional /radar_parameters etc.) mapped to their datasets, ready for xarray.DataTree.from_dict().

supports_groups: ClassVar[bool] = True#
url: ClassVar[str] = 'https://xradar.rtfd.io/en/latest/io.html#cfradial1'#
class xradar.io.backends.CfRadial2BackendEntrypoint[source]#

Bases: BackendEntrypoint

Xarray BackendEntrypoint for CfRadial2/FM301 grouped datasets.

Keyword Arguments:
  • sweep (int, str, iterable, optional) – Sweep selection. Defaults to all available sweeps.

  • first_dim (str) – Can be time or auto. Defaults to time.

  • optional (bool) – Keep optional root variables when available. Defaults to True.

  • optional_groups (bool) – Include root metadata subgroups if present. Defaults to False.

  • kwargs (dict) – Additional kwargs are fed to xarray.open_datatree().

description: ClassVar[str] = 'Open CfRadial2/FM301 grouped datasets in Xarray'#
guess_can_open(filename_or_obj)[source]#

CfRadial2 file (netCDF/HDF5 with sweep groups, whose Conventions mention CF/Radial and whose root has sweep_group_name and time_coverage_start).

Files with sweep_start_ray_index (CfRadial1) and vendor files which use the CfRadial2 layout without the time coverage (e.g. WindCube) are not claimed.

open_dataset(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=False, group='sweep_0', first_dim='time', optional=True)[source]#

Backend open_dataset method used by Xarray in open_dataset().

open_datatree(filename_or_obj, **kwargs)[source]#

Open a CfRadial2/FM301 grouped file as xarray.DataTree. See open_groups_as_dict() for keyword arguments.

open_groups_as_dict(filename_or_obj, *, sweep=None, first_dim='time', optional=True, optional_groups=False, site_coords=True, netcdf_engine=None, **kwargs)[source]#

Open a CfRadial2/FM301 grouped file as a dict of normalized group datasets. Best-effort normalization of common institutional variations is applied so the result matches xradar’s FM301-oriented layout.

Parameters:
  • filename_or_obj (str, Path, or file-like) – Path or file-like object understood by the underlying reader.

  • mask_and_scale (bool or dict-like, optional) – Replace fill values with NA and apply scale_factor/add_offset decoding. See xarray.open_dataset(). Defaults to True.

  • decode_times (bool or dict-like, optional) – Decode CF time variables (calendar, units) into np.datetime64. Defaults to True.

  • concat_characters (bool or dict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults to True.

  • decode_coords (bool or {"coordinates", "all"}, optional) – Decode the CF coordinates attribute. Defaults to True (equivalent to "coordinates").

  • drop_variables (str or iterable of str, optional) – Names of variables to drop before processing.

  • use_cftime (bool, optional) – Force cftime decoding for time variables (instead of np.datetime64). Defaults to None (auto).

  • decode_timedelta (bool, optional) – Decode CF timedelta variables. Default mirrors decode_times unless the backend overrides it (cfradial1, cfradial2, and imd default to False).

  • sweep (int, str, or list of int/str, optional) – Sweep selection. None (default) returns all sweeps. An int or "sweep_N" string returns one sweep; a list returns the named subset.

  • first_dim ({"auto", "time"}, optional) – Leading dimension of each sweep dataset. "auto" picks azimuth (PPI) or elevation (RHI); "time" keeps the raw time axis. Default "auto" ("time" for cfradial2).

  • optional (bool, optional) – Include optional root variables when available. Defaults to True.

  • optional_groups (bool, optional) – Include the /radar_parameters, /georeferencing_correction, and /radar_calibration metadata subgroups under the root. Defaults to False.

  • site_coords (bool, optional) – Keep latitude/longitude/altitude as coordinates on the root dataset. CfRadial2 stores station coords at root by default; pass False to drop them. Defaults to True.

  • netcdf_engine (str, optional) – netCDF engine used to read the file (e.g. "netcdf4" or "h5netcdf"). Defaults to None (xarray’s choice).

Returns:

dict[str, xarray.Dataset] – CfRadial2 group paths (/, /sweep_N, optional /radar_parameters etc.) mapped to their datasets, ready for xarray.DataTree.from_dict().

supports_groups: ClassVar[bool] = True#
url: ClassVar[str] = 'https://xradar.rtfd.io/en/latest/io.html#cfradial2'#
class xradar.io.backends.DataMetBackendEntrypoint[source]#

Bases: BackendEntrypoint

Xarray BackendEntrypoint for DataMet data.

description: ClassVar[str] = 'Open DataMet files in Xarray'#
guess_can_open(filename_or_obj)[source]#

DataMet volume (tar archive with navigation.txt).

open_dataset(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, group=None, reindex_coord=None, reindex_angle=False, first_dim='auto', site_as_coords=True)[source]#

Backend open_dataset method used by Xarray in open_dataset().

open_datatree(filename_or_obj, **kwargs)[source]#

Open a DataMet archive as xarray.DataTree. See open_groups_as_dict() for keyword arguments.

open_groups_as_dict(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, first_dim='auto', reindex_coord=None, reindex_angle=False, site_coords=True, sweep=None, optional=True, optional_groups=False)[source]#

Open a DataMet (Servizio Meteorologico Italiano) .tar.gz archive as a CfRadial2-shaped dict of group datasets.

Parameters:
  • filename_or_obj (str, Path, or file-like) – Path or file-like object understood by the underlying reader.

  • mask_and_scale (bool or dict-like, optional) – Replace fill values with NA and apply scale_factor/add_offset decoding. See xarray.open_dataset(). Defaults to True.

  • decode_times (bool or dict-like, optional) – Decode CF time variables (calendar, units) into np.datetime64. Defaults to True.

  • concat_characters (bool or dict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults to True.

  • decode_coords (bool or {"coordinates", "all"}, optional) – Decode the CF coordinates attribute. Defaults to True (equivalent to "coordinates").

  • drop_variables (str or iterable of str, optional) – Names of variables to drop before processing.

  • use_cftime (bool, optional) – Force cftime decoding for time variables (instead of np.datetime64). Defaults to None (auto).

  • decode_timedelta (bool, optional) – Decode CF timedelta variables. Default mirrors decode_times unless the backend overrides it (cfradial1, cfradial2, and imd default to False).

  • sweep (int, str, or list of int/str, optional) – Sweep selection. None (default) returns all sweeps. An int or "sweep_N" string returns one sweep; a list returns the named subset.

  • first_dim ({"auto", "time"}, optional) – Leading dimension of each sweep dataset. "auto" picks azimuth (PPI) or elevation (RHI); "time" keeps the raw time axis. Default "auto" ("time" for cfradial2).

  • optional (bool, optional) – Include optional root variables when available. Defaults to True.

  • optional_groups (bool, optional) – Include the /radar_parameters, /georeferencing_correction, and /radar_calibration metadata subgroups under the root. Defaults to False.

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked when decode_coords=True. Defaults to None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • site_coords (bool, optional) – Attach latitude/longitude/altitude as coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults to True.

Returns:

dict[str, xarray.Dataset] – CfRadial2 group paths (/, /sweep_N, optional /radar_parameters etc.) mapped to their datasets, ready for xarray.DataTree.from_dict().

supports_groups: ClassVar[bool] = True#
url: ClassVar[str] = 'https://xradar.rtfd.io/latest/io.html#datamet-data-i-o'#
class xradar.io.backends.FurunoBackendEntrypoint[source]#

Bases: BackendEntrypoint

Xarray BackendEntrypoint for Furuno data.

description: ClassVar[str] = 'Open FURUNO (.scn, .scnx) in Xarray'#
guess_can_open(filename_or_obj)[source]#

Furuno SCN/SCNX, also gzip-compressed (header size and version).

open_dataset(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, group=None, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_as_coords=True, obsmode=None)[source]#

Backend open_dataset method used by Xarray in open_dataset().

open_datatree(filename_or_obj, **kwargs)[source]#

Open a Furuno SCN or SCNX file as xarray.DataTree. See open_groups_as_dict() for keyword arguments.

open_groups_as_dict(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_coords=True, sweep=None, optional=True, optional_groups=False, obsmode=None)[source]#

Open a Furuno SCN or SCNX file as a CfRadial2-shaped dict of group datasets.

Parameters:
  • filename_or_obj (str, Path, or file-like) – Path or file-like object understood by the underlying reader.

  • mask_and_scale (bool or dict-like, optional) – Replace fill values with NA and apply scale_factor/add_offset decoding. See xarray.open_dataset(). Defaults to True.

  • decode_times (bool or dict-like, optional) – Decode CF time variables (calendar, units) into np.datetime64. Defaults to True.

  • concat_characters (bool or dict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults to True.

  • decode_coords (bool or {"coordinates", "all"}, optional) – Decode the CF coordinates attribute. Defaults to True (equivalent to "coordinates").

  • drop_variables (str or iterable of str, optional) – Names of variables to drop before processing.

  • use_cftime (bool, optional) – Force cftime decoding for time variables (instead of np.datetime64). Defaults to None (auto).

  • decode_timedelta (bool, optional) – Decode CF timedelta variables. Default mirrors decode_times unless the backend overrides it (cfradial1, cfradial2, and imd default to False).

  • sweep (int, str, or list of int/str, optional) – Sweep selection. None (default) returns all sweeps. An int or "sweep_N" string returns one sweep; a list returns the named subset.

  • first_dim ({"auto", "time"}, optional) – Leading dimension of each sweep dataset. "auto" picks azimuth (PPI) or elevation (RHI); "time" keeps the raw time axis. Default "auto" ("time" for cfradial2).

  • optional (bool, optional) – Include optional root variables when available. Defaults to True.

  • optional_groups (bool, optional) – Include the /radar_parameters, /georeferencing_correction, and /radar_calibration metadata subgroups under the root. Defaults to False.

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked when decode_coords=True. Defaults to None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective with first_dim="auto". Defaults to False.

  • site_coords (bool, optional) – Attach latitude/longitude/altitude as coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults to True.

  • obsmode (int or None, optional) – Override the file’s observation-mode flag (rare; only needed for files written by older firmware). Defaults to None.

Returns:

dict[str, xarray.Dataset] – CfRadial2 group paths (/, /sweep_N, optional /radar_parameters etc.) mapped to their datasets, ready for xarray.DataTree.from_dict().

supports_groups: ClassVar[bool] = True#
url: ClassVar[str] = 'https://xradar.rtfd.io/en/latest/io.html#furuno-binary-data'#
class xradar.io.backends.GamicBackendEntrypoint[source]#

Bases: BackendEntrypoint

Xarray BackendEntrypoint for GAMIC data.

Keyword Arguments:
  • first_dim (str) – Can be time or auto first dimension. If set to auto, first dimension will be either azimuth or elevation depending on type of sweep. Defaults to auto.

  • reindex_coord (dict, optional) – Defaults to None, no reindexing. Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked if decode_coords=True.

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool) – For PPI only. If True, fixes erroneous second angle data. Defaults to False.

  • site_as_coords (bool) – Attach radar site-coordinates to Dataset, defaults to True.

  • kwargs (dict) – Additional kwargs are fed to xarray.open_dataset().

description: ClassVar[str] = 'Open GAMIC HDF5 (.h5, .hdf5, .mvol) using h5netcdf in Xarray'#
guess_can_open(filename_or_obj)[source]#

GAMIC HDF5 file (what and scan0 groups).

open_dataset(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, format=None, group='sweep_0', invalid_netcdf=None, phony_dims='access', decode_vlen_strings=True, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_as_coords=True)[source]#

Backend open_dataset method used by Xarray in open_dataset().

open_datatree(filename_or_obj, **kwargs)[source]#

Open a GAMIC HDF5 file as xarray.DataTree. See open_groups_as_dict() for keyword arguments.

open_groups_as_dict(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, format=None, invalid_netcdf=None, phony_dims='access', decode_vlen_strings=True, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_coords=True, sweep=None, optional=True, optional_groups=False)[source]#

Open a GAMIC HDF5 file as a CfRadial2-shaped dict of group datasets.

Parameters:
  • filename_or_obj (str, Path, or file-like) – Path or file-like object understood by the underlying reader.

  • mask_and_scale (bool or dict-like, optional) – Replace fill values with NA and apply scale_factor/add_offset decoding. See xarray.open_dataset(). Defaults to True.

  • decode_times (bool or dict-like, optional) – Decode CF time variables (calendar, units) into np.datetime64. Defaults to True.

  • concat_characters (bool or dict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults to True.

  • decode_coords (bool or {"coordinates", "all"}, optional) – Decode the CF coordinates attribute. Defaults to True (equivalent to "coordinates").

  • drop_variables (str or iterable of str, optional) – Names of variables to drop before processing.

  • use_cftime (bool, optional) – Force cftime decoding for time variables (instead of np.datetime64). Defaults to None (auto).

  • decode_timedelta (bool, optional) – Decode CF timedelta variables. Default mirrors decode_times unless the backend overrides it (cfradial1, cfradial2, and imd default to False).

  • sweep (int, str, or list of int/str, optional) – Sweep selection. None (default) returns all sweeps. An int or "sweep_N" string returns one sweep; a list returns the named subset.

  • first_dim ({"auto", "time"}, optional) – Leading dimension of each sweep dataset. "auto" picks azimuth (PPI) or elevation (RHI); "time" keeps the raw time axis. Default "auto" ("time" for cfradial2).

  • optional (bool, optional) – Include optional root variables when available. Defaults to True.

  • optional_groups (bool, optional) – Include the /radar_parameters, /georeferencing_correction, and /radar_calibration metadata subgroups under the root. Defaults to False.

  • format (str, optional) – h5netcdf format string. Defaults to None.

  • invalid_netcdf (bool, optional) – Accept HDF5 files that are not strictly NetCDF-conformant.

  • phony_dims ({"access", "sort", None}, optional) – How h5netcdf labels unnamed dimensions. Defaults to "access".

  • decode_vlen_strings (bool, optional) – Decode variable-length strings stored in HDF5. Defaults to True.

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked when decode_coords=True. Defaults to None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective with first_dim="auto". Defaults to False.

  • site_coords (bool, optional) – Attach latitude/longitude/altitude as coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults to True.

Returns:

dict[str, xarray.Dataset] – CfRadial2 group paths (/, /sweep_N, optional /radar_parameters etc.) mapped to their datasets, ready for xarray.DataTree.from_dict().

supports_groups: ClassVar[bool] = True#
url: ClassVar[str] = 'https://xradar.rtfd.io/en/latest/io.html#gamic-hdf5'#
class xradar.io.backends.HPLBackendEntrypoint[source]#

Bases: BackendEntrypoint

Xarray BackendEntrypoint for Halo Photonics Doppler processed lidar data.

Keyword Arguments:
  • first_dim (str) – Can be time or auto first dimension. If set to auto, first dimension will be either azimuth or elevation depending on type of sweep. Defaults to auto.

  • site_as_coords (bool) – Attach radar site-coordinates to Dataset, defaults to True.

  • kwargs (dict) – Additional kwargs are fed to xarray.open_dataset().

description: ClassVar[str] = 'Backend for reading Halo Photonics Doppler lidar processed data'#
guess_can_open(filename_or_obj)[source]#

Halo Photonics .hpl (text header starting with Filename:).

open_dataset(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, format=None, group='sweep_0', invalid_netcdf=None, phony_dims='access', decode_vlen_strings=True, first_dim='auto', reindex_coord=None, reindex_angle=False, site_as_coords=True, optional=True, latitude=0, longitude=0, altitude=0, transition_threshold_azi=0.01, transition_threshold_el=0.005)[source]#

Backend open_dataset method used by Xarray in open_dataset().

open_datatree(filename_or_obj, **kwargs)[source]#

Open a Halo Photonics .hpl file as xarray.DataTree. See open_groups_as_dict() for keyword arguments.

open_groups_as_dict(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, format=None, invalid_netcdf=None, phony_dims='access', decode_vlen_strings=True, first_dim='auto', reindex_coord=None, reindex_angle=False, site_coords=True, sweep=None, optional=True, optional_groups=False, latitude=0, longitude=0, altitude=0, transition_threshold_azi=0.01, transition_threshold_el=0.005)[source]#

Open a Halo Photonics Stream Line (.hpl) lidar file as a CfRadial2-shaped dict of group datasets.

Parameters:
  • filename_or_obj (str, Path, or file-like) – Path or file-like object understood by the underlying reader.

  • mask_and_scale (bool or dict-like, optional) – Replace fill values with NA and apply scale_factor/add_offset decoding. See xarray.open_dataset(). Defaults to True.

  • decode_times (bool or dict-like, optional) – Decode CF time variables (calendar, units) into np.datetime64. Defaults to True.

  • concat_characters (bool or dict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults to True.

  • decode_coords (bool or {"coordinates", "all"}, optional) – Decode the CF coordinates attribute. Defaults to True (equivalent to "coordinates").

  • drop_variables (str or iterable of str, optional) – Names of variables to drop before processing.

  • use_cftime (bool, optional) – Force cftime decoding for time variables (instead of np.datetime64). Defaults to None (auto).

  • decode_timedelta (bool, optional) – Decode CF timedelta variables. Default mirrors decode_times unless the backend overrides it (cfradial1, cfradial2, and imd default to False).

  • sweep (int, str, or list of int/str, optional) – Sweep selection. None (default) returns all sweeps. An int or "sweep_N" string returns one sweep; a list returns the named subset.

  • first_dim ({"auto", "time"}, optional) – Leading dimension of each sweep dataset. "auto" picks azimuth (PPI) or elevation (RHI); "time" keeps the raw time axis. Default "auto" ("time" for cfradial2).

  • optional (bool, optional) – Include optional root variables when available. Defaults to True.

  • optional_groups (bool, optional) – Include the /radar_parameters, /georeferencing_correction, and /radar_calibration metadata subgroups under the root. Defaults to False.

  • format (str, optional) – h5netcdf format string. Defaults to None.

  • invalid_netcdf (bool, optional) – Accept HDF5 files that are not strictly NetCDF-conformant.

  • phony_dims ({"access", "sort", None}, optional) – How h5netcdf labels unnamed dimensions. Defaults to "access".

  • decode_vlen_strings (bool, optional) – Decode variable-length strings stored in HDF5. Defaults to True.

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked when decode_coords=True. Defaults to None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • site_coords (bool, optional) – Attach latitude/longitude/altitude as coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults to True.

  • latitude (float, optional) – Override the site latitude (HPL files often lack geolocation).

  • longitude (float, optional) – Override the site longitude.

  • altitude (float, optional) – Override the site altitude above sea level (meters).

  • transition_threshold_azi (float, optional) – Azimuth-jump threshold (deg) for sweep boundary detection.

  • transition_threshold_el (float, optional) – Elevation-jump threshold (deg) for sweep boundary detection.

Returns:

dict[str, xarray.Dataset] – CfRadial2 group paths (/, /sweep_N, optional /radar_parameters etc.) mapped to their datasets, ready for xarray.DataTree.from_dict().

supports_groups: ClassVar[bool] = True#
url: ClassVar[str] = 'https://xradar.rtfd.io/en/latest/io.html#metek'#
class xradar.io.backends.IMDBackendEntrypoint[source]#

Bases: BackendEntrypoint

Xarray BackendEntrypoint for India Meteorological Department (IMD) radar files.

IMD provides one NetCDF file per sweep. Open a single file with xr.open_dataset(file, engine="imd") to get a CfRadial2-compatible sweep xarray.Dataset. To assemble a multi-sweep volume, use open_imd_datatree() with a list of files.

Keyword Arguments:
  • first_dim (str) – Can be time or auto (default). auto selects azimuth (PPI) or elevation (RHI) as the first dimension.

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(). Defaults to None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • site_as_coords (bool) – If True (default), promote latitude/longitude/altitude to Dataset coordinates.

description: ClassVar[str] = 'Open India Meteorological Department (IMD) radar NetCDF files in Xarray'#
guess_can_open(filename_or_obj)[source]#

IMD IRIS-netCDF file (radialAzim and elevationAngle).

open_dataset(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, format=None, group=None, first_dim='auto', reindex_coord=None, reindex_angle=False, site_as_coords=True)[source]#

Backend open_dataset method used by Xarray in open_dataset().

open_datatree(filename_or_obj, **kwargs)[source]#

Open a single IMD NetCDF file as xarray.DataTree. See open_groups_as_dict() for keyword arguments.

open_groups_as_dict(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=False, sweep=None, first_dim='auto', reindex_coord=None, reindex_angle=False, site_coords=True, optional_groups=False)[source]#

Open a single IMD (India Meteorological Department) NetCDF file as a CfRadial2-shaped dict of group datasets. Single-file only — for multi-file IMD volumes use open_imd_datatree().

Parameters:
  • filename_or_obj (str, Path, or file-like) – Path or file-like object understood by the underlying reader.

  • mask_and_scale (bool or dict-like, optional) – Replace fill values with NA and apply scale_factor/add_offset decoding. See xarray.open_dataset(). Defaults to True.

  • decode_times (bool or dict-like, optional) – Decode CF time variables (calendar, units) into np.datetime64. Defaults to True.

  • concat_characters (bool or dict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults to True.

  • decode_coords (bool or {"coordinates", "all"}, optional) – Decode the CF coordinates attribute. Defaults to True (equivalent to "coordinates").

  • drop_variables (str or iterable of str, optional) – Names of variables to drop before processing.

  • use_cftime (bool, optional) – Force cftime decoding for time variables (instead of np.datetime64). Defaults to None (auto).

  • decode_timedelta (bool, optional) – Decode CF timedelta variables. Default mirrors decode_times unless the backend overrides it (cfradial1, cfradial2, and imd default to False).

  • sweep (int, str, or list of int/str, optional) – Sweep selection. None (default) returns all sweeps. An int or "sweep_N" string returns one sweep; a list returns the named subset.

  • first_dim ({"auto", "time"}, optional) – Leading dimension of each sweep dataset. "auto" picks azimuth (PPI) or elevation (RHI); "time" keeps the raw time axis. Default "auto" ("time" for cfradial2).

  • optional_groups (bool, optional) – Include the /radar_parameters, /georeferencing_correction, and /radar_calibration metadata subgroups under the root. Defaults to False.

  • sweep (int, str or list, optional) – IMD files hold one sweep, so only None, 0 or "sweep_0" are accepted. Defaults to None.

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked when decode_coords=True. Defaults to None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • site_coords (bool, optional) – Attach latitude/longitude/altitude as coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults to True.

Returns:

dict[str, xarray.Dataset] – CfRadial2 group paths (/, /sweep_N, optional /radar_parameters etc.) mapped to their datasets, ready for xarray.DataTree.from_dict().

supports_groups: ClassVar[bool] = True#
url: ClassVar[str] = 'https://xradar.rtfd.io/en/latest/io.html#imd'#
class xradar.io.backends.IrisBackendEntrypoint[source]#

Bases: BackendEntrypoint

Xarray BackendEntrypoint for IRIS/Sigmet data.

description: ClassVar[str] = 'Open IRIS/Sigmet files in Xarray'#
guess_can_open(filename_or_obj)[source]#

IRIS/Sigmet RAW file (product_hdr structure, RAW product).

open_dataset(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, group=None, lock=None, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_as_coords=True, optional=True)[source]#

Backend open_dataset method used by Xarray in open_dataset().

open_datatree(filename_or_obj, **kwargs)[source]#

Open an Iris/Sigmet RAW file as xarray.DataTree. See open_groups_as_dict() for keyword arguments.

open_groups_as_dict(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, lock=None, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_coords=True, sweep=None, optional=True, optional_groups=False)[source]#

Open an Iris/Sigmet RAW file as a CfRadial2-shaped dict of group datasets.

Parameters:
  • filename_or_obj (str, Path, or file-like) – Path or file-like object understood by the underlying reader.

  • mask_and_scale (bool or dict-like, optional) – Replace fill values with NA and apply scale_factor/add_offset decoding. See xarray.open_dataset(). Defaults to True.

  • decode_times (bool or dict-like, optional) – Decode CF time variables (calendar, units) into np.datetime64. Defaults to True.

  • concat_characters (bool or dict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults to True.

  • decode_coords (bool or {"coordinates", "all"}, optional) – Decode the CF coordinates attribute. Defaults to True (equivalent to "coordinates").

  • drop_variables (str or iterable of str, optional) – Names of variables to drop before processing.

  • use_cftime (bool, optional) – Force cftime decoding for time variables (instead of np.datetime64). Defaults to None (auto).

  • decode_timedelta (bool, optional) – Decode CF timedelta variables. Default mirrors decode_times unless the backend overrides it (cfradial1, cfradial2, and imd default to False).

  • sweep (int, str, or list of int/str, optional) – Sweep selection. None (default) returns all sweeps. An int or "sweep_N" string returns one sweep; a list returns the named subset.

  • first_dim ({"auto", "time"}, optional) – Leading dimension of each sweep dataset. "auto" picks azimuth (PPI) or elevation (RHI); "time" keeps the raw time axis. Default "auto" ("time" for cfradial2).

  • optional (bool, optional) – Include optional root variables when available. Defaults to True.

  • optional_groups (bool, optional) – Include the /radar_parameters, /georeferencing_correction, and /radar_calibration metadata subgroups under the root. Defaults to False.

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked when decode_coords=True. Defaults to None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective with first_dim="auto". Defaults to False.

  • site_coords (bool, optional) – Attach latitude/longitude/altitude as coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults to True.

  • lock (threading.Lock or None, optional) – Reader lock for thread-safe access. Defaults to None.

Returns:

dict[str, xarray.Dataset] – CfRadial2 group paths (/, /sweep_N, optional /radar_parameters etc.) mapped to their datasets, ready for xarray.DataTree.from_dict().

supports_groups: ClassVar[bool] = True#
url: ClassVar[str] = 'https://xradar.rtfd.io/latest/io.html#iris-sigmet-data-i-o'#
class xradar.io.backends.MRRBackendEntrypoint[source]#

Bases: BackendEntrypoint

Xarray BackendEntrypoint for Metek MRR2 data.

Keyword Arguments:
  • first_dim (str) – Can be time or auto first dimension. If set to auto, first dimension will be either azimuth or elevation depending on type of sweep. Defaults to auto.

  • site_as_coords (bool) – Attach radar site-coordinates to Dataset, defaults to True.

  • kwargs (dict) – Additional kwargs are fed to xarray.open_dataset().

description: ClassVar[str] = 'Backend for reading Metek MRR2 processed and raw data'#
guess_can_open(filename_or_obj)[source]#

Metek MRR file (header lines starting with MRR).

open_dataset(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, format=None, group='/', invalid_netcdf=None, phony_dims='access', decode_vlen_strings=True, first_dim='auto', site_as_coords=True, optional=True)[source]#

Backend open_dataset method used by Xarray in open_dataset().

open_datatree(filename_or_obj, **kwargs)[source]#

Open a Metek MRR2 file as xarray.DataTree. See open_groups_as_dict() for keyword arguments.

open_groups_as_dict(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, format=None, invalid_netcdf=None, phony_dims='access', decode_vlen_strings=True, first_dim='auto', site_coords=True, sweep=None, optional=True, optional_groups=False)[source]#

Open a Metek MRR2 (.ave/.pro/.raw) file as a CfRadial2-shaped dict of group datasets. MRR2 is a vertically pointing radar — the output contains one sweep_0 group with all profiles.

Parameters:
  • filename_or_obj (str, Path, or file-like) – Path or file-like object understood by the underlying reader.

  • mask_and_scale (bool or dict-like, optional) – Replace fill values with NA and apply scale_factor/add_offset decoding. See xarray.open_dataset(). Defaults to True.

  • decode_times (bool or dict-like, optional) – Decode CF time variables (calendar, units) into np.datetime64. Defaults to True.

  • concat_characters (bool or dict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults to True.

  • decode_coords (bool or {"coordinates", "all"}, optional) – Decode the CF coordinates attribute. Defaults to True (equivalent to "coordinates").

  • drop_variables (str or iterable of str, optional) – Names of variables to drop before processing.

  • use_cftime (bool, optional) – Force cftime decoding for time variables (instead of np.datetime64). Defaults to None (auto).

  • decode_timedelta (bool, optional) – Decode CF timedelta variables. Default mirrors decode_times unless the backend overrides it (cfradial1, cfradial2, and imd default to False).

  • sweep (int, str, or list of int/str, optional) – Sweep selection. None (default) returns all sweeps. An int or "sweep_N" string returns one sweep; a list returns the named subset.

  • first_dim ({"auto", "time"}, optional) – Leading dimension of each sweep dataset. "auto" picks azimuth (PPI) or elevation (RHI); "time" keeps the raw time axis. Default "auto" ("time" for cfradial2).

  • optional (bool, optional) – Include optional root variables when available. Defaults to True.

  • optional_groups (bool, optional) – Include the /radar_parameters, /georeferencing_correction, and /radar_calibration metadata subgroups under the root. Defaults to False.

  • format (str, optional) – h5netcdf format string. Defaults to None.

  • invalid_netcdf (bool, optional) – Accept HDF5 files that are not strictly NetCDF-conformant.

  • phony_dims ({"access", "sort", None}, optional) – How h5netcdf labels unnamed dimensions. Defaults to "access".

  • decode_vlen_strings (bool, optional) – Decode variable-length strings stored in HDF5. Defaults to True.

  • site_coords (bool, optional) – Attach latitude/longitude/altitude as coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults to True.

Returns:

dict[str, xarray.Dataset] – CfRadial2 group paths (/, /sweep_N, optional /radar_parameters etc.) mapped to their datasets, ready for xarray.DataTree.from_dict().

supports_groups: ClassVar[bool] = True#
url: ClassVar[str] = 'https://xradar.rtfd.io/en/latest/io.html#metek'#
class xradar.io.backends.NexradLevel2BackendEntrypoint[source]#

Bases: BackendEntrypoint

Xarray BackendEntrypoint for NEXRAD Level2 Data

description: ClassVar[str] = 'Open NEXRAD Level2 files in Xarray'#
guess_can_open(filename_or_obj)[source]#

NEXRAD Level II archive (AR2V / ARCHIVE2 volume header).

open_dataset(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, group=None, lock=None, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_as_coords=True, optional=True)[source]#

Backend open_dataset method used by Xarray in open_dataset().

open_datatree(filename_or_obj, **kwargs)[source]#

Open a NEXRAD Level II file as xarray.DataTree. See open_groups_as_dict() for keyword arguments.

open_groups_as_dict(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, sweep=None, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_coords=True, optional=True, optional_groups=False, incomplete_sweep='drop', lock=None, **kwargs)[source]#

Open a NEXRAD Level II file as a CfRadial2-shaped dict of group datasets. Accepts a single file path, a bytes buffer, or a list/tuple of LDM chunk paths (the first chunk must hold the AR2V volume header).

Parameters:
  • filename_or_obj (str, Path, or file-like) – Path or file-like object understood by the underlying reader.

  • mask_and_scale (bool or dict-like, optional) – Replace fill values with NA and apply scale_factor/add_offset decoding. See xarray.open_dataset(). Defaults to True.

  • decode_times (bool or dict-like, optional) – Decode CF time variables (calendar, units) into np.datetime64. Defaults to True.

  • concat_characters (bool or dict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults to True.

  • decode_coords (bool or {"coordinates", "all"}, optional) – Decode the CF coordinates attribute. Defaults to True (equivalent to "coordinates").

  • drop_variables (str or iterable of str, optional) – Names of variables to drop before processing.

  • use_cftime (bool, optional) – Force cftime decoding for time variables (instead of np.datetime64). Defaults to None (auto).

  • decode_timedelta (bool, optional) – Decode CF timedelta variables. Default mirrors decode_times unless the backend overrides it (cfradial1, cfradial2, and imd default to False).

  • sweep (int, str, or list of int/str, optional) – Sweep selection. None (default) returns all sweeps. An int or "sweep_N" string returns one sweep; a list returns the named subset.

  • first_dim ({"auto", "time"}, optional) – Leading dimension of each sweep dataset. "auto" picks azimuth (PPI) or elevation (RHI); "time" keeps the raw time axis. Default "auto" ("time" for cfradial2).

  • optional (bool, optional) – Include optional root variables when available. Defaults to True.

  • optional_groups (bool, optional) – Include the /radar_parameters, /georeferencing_correction, and /radar_calibration metadata subgroups under the root. Defaults to False.

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked when decode_coords=True. Defaults to None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective with first_dim="auto". Defaults to False.

  • site_coords (bool, optional) – Attach latitude/longitude/altitude as coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults to True.

  • incomplete_sweep ({"drop", "pad"}, optional) – How to handle sweeps with fewer rays than the VCP nominal count. "drop" (default) excludes them with a UserWarning; "pad" keeps them with NaN-filled rays so the reindexed azimuth grid is complete.

  • lock (threading.Lock or None, optional) – Reader lock for thread-safe access. Defaults to None.

Returns:

dict[str, xarray.Dataset] – CfRadial2 group paths (/, /sweep_N, optional /radar_parameters etc.) mapped to their datasets, ready for xarray.DataTree.from_dict().

supports_groups: ClassVar[bool] = True#
url: ClassVar[str] = 'tbd'#
class xradar.io.backends.OdimBackendEntrypoint[source]#

Bases: BackendEntrypoint

Xarray BackendEntrypoint for ODIM data.

Keyword Arguments:
  • first_dim (str) – Can be time or auto first dimension. If set to auto, first dimension will be either azimuth or elevation depending on type of sweep. Defaults to auto.

  • reindex_coord (dict, optional) – Defaults to None, no reindexing. Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked if decode_coords=True.

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool) – If True, fixes erroneous second angle data. Defaults to False.

  • site_as_coords (bool) – Attach radar site-coordinates to Dataset, defaults to True.

  • kwargs (dict) – Additional kwargs are fed to xarray.open_dataset().

description: ClassVar[str] = 'Open ODIM_H5 (.h5, .hdf5) using h5netcdf in Xarray'#
guess_can_open(filename_or_obj)[source]#

ODIM_H5 file (HDF5 with Conventions ODIM_H5/...).

open_dataset(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, format=None, group='sweep_0', invalid_netcdf=None, phony_dims='access', decode_vlen_strings=True, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_as_coords=True)[source]#

Backend open_dataset method used by Xarray in open_dataset().

open_datatree(filename_or_obj, **kwargs)[source]#

Open an ODIM_H5 file as xarray.DataTree.

Builds the tree from open_groups_as_dict() and keeps each group’s file, so close() releases it. See open_groups_as_dict() for keyword arguments.

open_groups_as_dict(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, format=None, invalid_netcdf=None, phony_dims='access', decode_vlen_strings=True, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_coords=True, sweep=None, optional=True, optional_groups=False)[source]#

Open an ODIM_H5 file as a CfRadial2-shaped dict of group datasets.

Parameters:
  • filename_or_obj (str, Path, or file-like) – Path or file-like object understood by the underlying reader.

  • mask_and_scale (bool or dict-like, optional) – Replace fill values with NA and apply scale_factor/add_offset decoding. See xarray.open_dataset(). Defaults to True.

  • decode_times (bool or dict-like, optional) – Decode CF time variables (calendar, units) into np.datetime64. Defaults to True.

  • concat_characters (bool or dict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults to True.

  • decode_coords (bool or {"coordinates", "all"}, optional) – Decode the CF coordinates attribute. Defaults to True (equivalent to "coordinates").

  • drop_variables (str or iterable of str, optional) – Names of variables to drop before processing.

  • use_cftime (bool, optional) – Force cftime decoding for time variables (instead of np.datetime64). Defaults to None (auto).

  • decode_timedelta (bool, optional) – Decode CF timedelta variables. Default mirrors decode_times unless the backend overrides it (cfradial1, cfradial2, and imd default to False).

  • sweep (int, str, or list of int/str, optional) – Sweep selection. None (default) returns all sweeps. An int or "sweep_N" string returns one sweep; a list returns the named subset.

  • first_dim ({"auto", "time"}, optional) – Leading dimension of each sweep dataset. "auto" picks azimuth (PPI) or elevation (RHI); "time" keeps the raw time axis. Default "auto" ("time" for cfradial2).

  • optional (bool, optional) – Include optional root variables when available. Defaults to True.

  • optional_groups (bool, optional) – Include the /radar_parameters, /georeferencing_correction, and /radar_calibration metadata subgroups under the root. Defaults to False.

  • format (str, optional) – h5netcdf format string. Defaults to None.

  • invalid_netcdf (bool, optional) – Accept HDF5 files that are not strictly NetCDF-conformant.

  • phony_dims ({"access", "sort", None}, optional) – How h5netcdf labels unnamed dimensions. Defaults to "access".

  • decode_vlen_strings (bool, optional) – Decode variable-length strings stored in HDF5. Defaults to True.

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked when decode_coords=True. Defaults to None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective with first_dim="auto". Defaults to False.

  • site_coords (bool, optional) – Attach latitude/longitude/altitude as coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults to True.

Returns:

dict[str, xarray.Dataset] – CfRadial2 group paths (/, /sweep_N, optional /radar_parameters etc.) mapped to their datasets, ready for xarray.DataTree.from_dict().

supports_groups: ClassVar[bool] = True#
url: ClassVar[str] = 'https://xradar.rtfd.io/en/latest/io.html#odim-h5'#
class xradar.io.backends.RainbowBackendEntrypoint[source]#

Bases: BackendEntrypoint

Xarray BackendEntrypoint for Rainbow5 data.

description: ClassVar[str] = 'Open Rainbow5 files in Xarray'#
guess_can_open(filename_or_obj)[source]#

Rainbow5 file (XML header starting with <volume).

open_dataset(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, group=None, reindex_coord=None, reindex_angle=False, first_dim='auto', site_as_coords=True)[source]#

Backend open_dataset method used by Xarray in open_dataset().

open_datatree(filename_or_obj, **kwargs)[source]#

Open a Rainbow5 file as xarray.DataTree. See open_groups_as_dict() for keyword arguments.

open_groups_as_dict(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, first_dim='auto', reindex_coord=None, reindex_angle=False, site_coords=True, sweep=None, optional=True, optional_groups=False)[source]#

Open a Rainbow5 file as a CfRadial2-shaped dict of group datasets.

Parameters:
  • filename_or_obj (str, Path, or file-like) – Path or file-like object understood by the underlying reader.

  • mask_and_scale (bool or dict-like, optional) – Replace fill values with NA and apply scale_factor/add_offset decoding. See xarray.open_dataset(). Defaults to True.

  • decode_times (bool or dict-like, optional) – Decode CF time variables (calendar, units) into np.datetime64. Defaults to True.

  • concat_characters (bool or dict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults to True.

  • decode_coords (bool or {"coordinates", "all"}, optional) – Decode the CF coordinates attribute. Defaults to True (equivalent to "coordinates").

  • drop_variables (str or iterable of str, optional) – Names of variables to drop before processing.

  • use_cftime (bool, optional) – Force cftime decoding for time variables (instead of np.datetime64). Defaults to None (auto).

  • decode_timedelta (bool, optional) – Decode CF timedelta variables. Default mirrors decode_times unless the backend overrides it (cfradial1, cfradial2, and imd default to False).

  • sweep (int, str, or list of int/str, optional) – Sweep selection. None (default) returns all sweeps. An int or "sweep_N" string returns one sweep; a list returns the named subset.

  • first_dim ({"auto", "time"}, optional) – Leading dimension of each sweep dataset. "auto" picks azimuth (PPI) or elevation (RHI); "time" keeps the raw time axis. Default "auto" ("time" for cfradial2).

  • optional (bool, optional) – Include optional root variables when available. Defaults to True.

  • optional_groups (bool, optional) – Include the /radar_parameters, /georeferencing_correction, and /radar_calibration metadata subgroups under the root. Defaults to False.

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked when decode_coords=True. Defaults to None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • site_coords (bool, optional) – Attach latitude/longitude/altitude as coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults to True.

Returns:

dict[str, xarray.Dataset] – CfRadial2 group paths (/, /sweep_N, optional /radar_parameters etc.) mapped to their datasets, ready for xarray.DataTree.from_dict().

supports_groups: ClassVar[bool] = True#
url: ClassVar[str] = 'https://xradar.rtfd.io/latest/io.html#rainbow-data-i-o'#
class xradar.io.backends.UFBackendEntrypoint[source]#

Bases: BackendEntrypoint

Xarray BackendEntrypoint for Universal Format (UF) data.

description: ClassVar[str] = 'Open Universal Format (UF) files in Xarray'#
guess_can_open(filename_or_obj)[source]#

Universal Format, UF at the start of the first record.

open_dataset(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, group=None, lock=None, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_as_coords=True, optional=True)[source]#

Backend open_dataset method used by Xarray in open_dataset().

open_datatree(filename_or_obj, **kwargs)[source]#

Open a Universal Format (UF) file as xarray.DataTree. See open_groups_as_dict() for keyword arguments.

open_groups_as_dict(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, sweep=None, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_coords=True, optional=True, optional_groups=False, lock=None, **kwargs)[source]#

Open a Universal Format (UF) file as a CfRadial2-shaped dict of group datasets.

Parameters:
  • filename_or_obj (str, Path, or file-like) – Path or file-like object understood by the underlying reader.

  • mask_and_scale (bool or dict-like, optional) – Replace fill values with NA and apply scale_factor/add_offset decoding. See xarray.open_dataset(). Defaults to True.

  • decode_times (bool or dict-like, optional) – Decode CF time variables (calendar, units) into np.datetime64. Defaults to True.

  • concat_characters (bool or dict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults to True.

  • decode_coords (bool or {"coordinates", "all"}, optional) – Decode the CF coordinates attribute. Defaults to True (equivalent to "coordinates").

  • drop_variables (str or iterable of str, optional) – Names of variables to drop before processing.

  • use_cftime (bool, optional) – Force cftime decoding for time variables (instead of np.datetime64). Defaults to None (auto).

  • decode_timedelta (bool, optional) – Decode CF timedelta variables. Default mirrors decode_times unless the backend overrides it (cfradial1, cfradial2, and imd default to False).

  • sweep (int, str, or list of int/str, optional) – Sweep selection. None (default) returns all sweeps. An int or "sweep_N" string returns one sweep; a list returns the named subset.

  • first_dim ({"auto", "time"}, optional) – Leading dimension of each sweep dataset. "auto" picks azimuth (PPI) or elevation (RHI); "time" keeps the raw time axis. Default "auto" ("time" for cfradial2).

  • optional (bool, optional) – Include optional root variables when available. Defaults to True.

  • optional_groups (bool, optional) – Include the /radar_parameters, /georeferencing_correction, and /radar_calibration metadata subgroups under the root. Defaults to False.

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked when decode_coords=True. Defaults to None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective with first_dim="auto". Defaults to False.

  • site_coords (bool, optional) – Attach latitude/longitude/altitude as coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults to True.

  • lock (threading.Lock or None, optional) – Reader lock for thread-safe access. Defaults to None.

Returns:

dict[str, xarray.Dataset] – CfRadial2 group paths (/, /sweep_N, optional /radar_parameters etc.) mapped to their datasets, ready for xarray.DataTree.from_dict().

supports_groups: ClassVar[bool] = True#
url: ClassVar[str] = 'https://xradar.rtfd.io/latest/io.html#uf-data-i-o'#
xradar.io.backends.discover_engine(filename_or_obj)[source]#

Find the xradar engine which can open the given file.

Each xradar backend checks the file with its guess_can_open (format signatures, e.g. AR2V for NEXRAD Level II, ODIM_H5 conventions in HDF5 files), see list_xradar_engines().

Parameters:

filename_or_obj (str, os.PathLike, bytes or file-like) – Radar file.

Returns:

engine (str) – Name of the engine, to be used with e.g. xr.open_dataset(filename, engine=engine, group="sweep_0").

Raises:

ValueError – If no xradar engine can open the file.

Examples

>>> engine = xd.io.discover_engine(filename)
>>> ds = xr.open_dataset(filename, engine=engine, group="sweep_0")
xradar.io.backends.group_imd_files(paths)[source]#

Group IMD sweep files into volumes by filename stem.

IMD distributes one sweep per file. Files of a single volume share a common stem ending in .nc; additional sweeps in the same volume get numeric suffixes:

GOA210515003646-IMD-C.nc        <- sweep 0
GOA210515003646-IMD-C.nc.1      <- sweep 1
...
GOA210515003646-IMD-C.nc.9      <- sweep 9

A new volume changes the timestamp component of the stem.

Parameters:

paths (str, Path, or iterable of those) –

  • A directory path – all IMD files inside are grouped.

  • A glob pattern string – files matching the glob are grouped.

  • An iterable of file paths – grouped as-is.

Returns:

list[list[str]] – One list of absolute paths per detected volume, inner lists in sweep order (.nc, .nc.1, …).

Examples

>>> import xradar as xd
>>> for group in xd.io.group_imd_files("/data/goa"):
...     dtree = xd.io.open_imd_datatree(group)
xradar.io.backends.list_xradar_engines()[source]#

Names of the xarray backend engines provided by xradar.

Returns:

engines (list of str)

xradar.io.backends.open_cfradial1_datatree(filename_or_obj, **kwargs)[source]#

Open CfRadial1 dataset as xarray.DataTree.

Deprecated since version Use: xd.open_datatree(file, engine="cfradial1") or xr.open_datatree(file, engine="cfradial1") instead.

Parameters:

filename_or_obj (str, Path, file-like or xarray.DataStore) – Strings and Path objects are interpreted as a path to a local or remote radar file

Keyword Arguments:
  • sweep (int, list of int, optional) – Sweep number(s) to extract, default to first sweep. If None, all sweeps are extracted into a list.

  • first_dim (str) – Can be time or auto first dimension. If set to auto, first dimension will be either azimuth or elevation depending on type of sweep. Defaults to auto.

  • reindex_coord (dict, optional) – Defaults to None, no reindexing. Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked if decode_coords=True.

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool) – If True, fixes erroneous second angle data. Defaults to False.

  • optional (bool) – Import optional mandatory data and metadata, defaults to True.

  • site_as_coords (bool) – Attach radar site-coordinates to Dataset, defaults to True.

  • engine (str) – Engine that will be passed to Xarray.open_dataset, defaults to “netcdf4”

Returns:

dtree (xarray.DataTree) – DataTree with CfRadial2 groups.

xradar.io.backends.open_cfradial2_datatree(filename_or_obj: str | PathLike[str], **kwargs: Any) → DataTree[source]#

Open a CfRadial2-like grouped dataset as xarray.DataTree.

Deprecated since version Use: xd.open_datatree(file, engine="cfradial2") or xr.open_datatree(file, engine="cfradial2") instead.

Parameters:

filename_or_obj (str or PathLike) – Path or object understood by xarray.open_datatree().

Keyword Arguments:
  • sweep (int, str, iterable, optional) – Sweep selection. Defaults to all available sweeps.

  • first_dim (str) – Can be time or auto. Defaults to time.

  • optional (bool) – Keep optional root variables when available. Defaults to True.

  • optional_groups (bool) – Include root metadata subgroups if present. Defaults to False.

  • **kwargs (dict) – Additional keyword arguments passed to xarray.open_datatree().

Returns:

xarray.DataTree – Normalized DataTree containing root metadata and sweep groups.

xradar.io.backends.open_datamet_datatree(filename_or_obj, **kwargs)[source]#

Open DataMet dataset as xarray.DataTree.

Deprecated since version Use: xd.open_datatree(file, engine="datamet") instead.

xradar.io.backends.open_furuno_datatree(filename_or_obj, **kwargs)[source]#

Open FURUNO dataset as xarray.DataTree.

Deprecated since version Use: xd.open_datatree(file, engine="furuno") instead.

xradar.io.backends.open_gamic_datatree(filename_or_obj, **kwargs)[source]#

Open GAMIC HDF5 dataset as xarray.DataTree.

Deprecated since version Use: xd.open_datatree(file, engine="gamic") instead.

xradar.io.backends.open_hpl_datatree(filename_or_obj, **kwargs)[source]#

Open Halo Photonics processed Doppler lidar dataset as xarray.DataTree.

Deprecated since version Use: xd.open_datatree(file, engine="hpl") instead.

xradar.io.backends.open_imd_datatree(filename_or_obj, **kwargs)[source]#

Open IMD radar file(s) as a xarray.DataTree.

IMD stores one sweep per NetCDF file. A volume is assembled from multiple files (typically 2-3 for long-range PPI or 9-10 for short-range, high-resolution PPI).

  • Single file path -> single-sweep DataTree.

  • List of file paths -> single volume DataTree. Multi-file stacking is delegated to xradar.util.create_volume(), which sorts sweeps by time and supports time_coverage_start, time_coverage_end, min_angle, max_angle filtering.

Note

When opening a single IMD sweep file as a DataTree, prefer xd.open_datatree(file, engine="imd") (or the xarray-native xr.open_datatree(file, engine="imd")). This function remains the documented API for the multi-file path because IMD volumes span multiple files, which the engine="imd" registry entry does not support.

To split a directory of mixed-volume files into per-volume groups, use group_imd_files() first:

for group in xd.io.group_imd_files("/data/imd"):
    dtree = xd.io.open_imd_datatree(group)
Parameters:

filename_or_obj (str, Path, or list/tuple of those) – Single IMD file path, or a list of paths making up one volume.

Keyword Arguments:
  • first_dim (str) – "auto" (default) or "time".

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range().

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • site_as_coords (bool) – Attach station variables as coordinates on sweep Datasets. site_coords is accepted as an alias.

  • optional_groups (bool) – Include /radar_parameters, /georeferencing_correction and /radar_calibration subgroups. Defaults to False. With multiple files the values the files disagree about are left out of the groups, with a UserWarning.

  • volume_number (time_coverage_start, time_coverage_end, min_angle, max_angle,) – Forwarded to xradar.util.create_volume() when multi-file input is provided.

Returns:

dtree (xarray.DataTree) – CfRadial2-style DataTree with / root and sweep_N children.

xradar.io.backends.open_imd_volumes(paths, **kwargs)[source]#

Open a directory of IMD files as a multi-volume xarray.DataTree.

Groups files by filename stem via group_imd_files(), opens each group as a CfRadial2 volume via open_imd_datatree(), and nests them under zero-padded vcp_NN child nodes of a parent root. vcp stands for volume coverage pattern. Padding width is chosen so the child names sort lexically (e.g. 121 volumes -> vcp_000 .. vcp_120).

Parameters:

paths (str, Path, or iterable of those) – Same as group_imd_files(): directory, glob, or list.

:keyword All kwargs are forwarded to open_imd_datatree() (applied per: :keyword volume). Typical: :kwtype volume). Typical: first_dim, reindex_coord, site_as_coords, :keyword optional_groups, min_angle, max_angle.:

Returns:

dtree (xarray.DataTree) –

Root with vcp_NN children, each a full CfRadial2 volume tree:

/
├── vcp_00/
│   ├── (root: sweep_group_name, sweep_fixed_angle, ...)
│   ├── sweep_0
│   ├── sweep_1
│   └── ...
├── vcp_01/
└── ...

Examples

>>> import xradar as xd
>>> tree = xd.io.open_imd_volumes("/data/JPR220822IMD-B")
>>> tree["vcp_00/sweep_0"].dataset["DBZH"]
xradar.io.backends.open_iris_datatree(filename_or_obj, **kwargs)[source]#

Open Iris/Sigmet dataset as xarray.DataTree.

Deprecated since version Use: xd.open_datatree(file, engine="iris") instead.

xradar.io.backends.open_metek_datatree(filename_or_obj, **kwargs)[source]#

Open Metek MRR2 dataset as xarray.DataTree.

Deprecated since version Use: xd.open_datatree(file, engine="metek") instead.

xradar.io.backends.open_nexradlevel2_datatree(filename_or_obj, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, sweep=None, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_as_coords=True, optional=True, optional_groups=False, incomplete_sweep='drop', lock=None, **kwargs)[source]#

Open a NEXRAD Level2 dataset as xarray.DataTree.

This function loads NEXRAD Level2 radar data into a DataTree structure, which organizes radar sweeps as separate nodes. Provides options for decoding time and applying various transformations to the data.

Parameters:
  • filename_or_obj (str, Path, file-like, bytes, list, or DataStore) – The path or file-like object representing the radar file. Path-like objects are interpreted as local or remote paths. A list or tuple of chunk sources (bytes, file-like, or paths) will be concatenated before reading. When passing chunks, the S file (volume header) must be the first element and I/E chunks must follow in sequence order (.001, .002, …). Out-of-order chunks produce corrupted data or decompression errors.

  • mask_and_scale (bool, optional) – If True, replaces values in the dataset that match _FillValue with NaN and applies scale and offset adjustments. Default is True. The special moment codes below threshold (0) and range folded (1) are both decoded to NaN. Use mask_and_scale=False to get the raw codes, e.g. to keep range folded gates distinguishable.

  • decode_times (bool, optional) – If True, decodes time variables according to CF conventions. Default is True.

  • concat_characters (bool, optional) – If True, concatenates character arrays along the last dimension, forming string arrays. Default is True.

  • decode_coords (bool, optional) – If True, decodes the “coordinates” attribute to identify coordinates in the resulting dataset. Default is True.

  • drop_variables (str or list of str, optional) – Specifies variables to exclude from the dataset. Useful for removing problematic or inconsistent variables. Default is None.

  • use_cftime (bool, optional) – If True, uses cftime objects to represent time variables; if False, uses np.datetime64 objects. If None, chooses the best format automatically. Default is None.

  • decode_timedelta (bool, optional) – If True, decodes variables with units of time (e.g., seconds, minutes) into timedelta objects. If False, leaves them as numeric values. Default is None.

  • sweep (int or list of int, optional) – Sweep numbers to extract from the dataset. If None, extracts all sweeps into a list. Default is the first sweep.

  • first_dim ({"time", "auto"}, optional) – Defines the first dimension for each sweep. If “time,” uses time as the first dimension. If “auto,” determines the first dimension based on the sweep type (azimuth or elevation). Default is “auto.”

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(). Only used if decode_coords=True. Default is None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool, optional) – If True, corrects errors in the second angle data, such as misaligned elevation or azimuth values. Default is False.

  • site_as_coords (bool, optional) – Attaches radar site coordinates to the dataset if True. Default is True.

  • optional (bool, optional) – If True, suppresses errors for optional dataset attributes, making them optional instead of required. Default is True.

  • optional_groups (bool, optional) – If True, includes /radar_parameters, /georeferencing_correction and /radar_calibration metadata subgroups in the DataTree. These groups are often empty or sparsely populated. Default is False.

  • incomplete_sweep ({"drop", "pad"}, optional) – How to handle incomplete sweeps (sweeps that were force-closed because the data ended mid-sweep, e.g. chunk files). "drop" (default) excludes incomplete sweeps and emits a warning. "pad" includes them, reindexing to a full azimuth grid with NaN-filled rays for missing positions.

  • kwargs (dict) – Additional keyword arguments passed to xarray.open_dataset.

Returns:

dtree (xarray.DataTree) – An xarray.DataTree representing the radar data organized by sweeps.

xradar.io.backends.open_odim_datatree(filename_or_obj, **kwargs)[source]#

Open ODIM_H5 dataset as xarray.DataTree.

Deprecated since version Use: xd.open_datatree(file, engine="odim") or xr.open_datatree(file, engine="odim") instead.

Parameters:

filename_or_obj (str, Path, file-like or DataStore) – Strings and Path objects are interpreted as a path to a local or remote radar file

Keyword Arguments:
  • sweep (int, list of int, optional) – Sweep number(s) to extract, default to first sweep. If None, all sweeps are extracted into a list.

  • first_dim (str) – Can be time or auto first dimension. If set to auto, first dimension will be either azimuth or elevation depending on type of sweep. Defaults to auto.

  • reindex_coord (dict, optional) – Defaults to None, no reindexing. Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked if decode_coords=True.

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool) – If True, fixes erroneous second angle data. Defaults to False.

  • site_as_coords (bool) – Attach radar site-coordinates to Dataset, defaults to True.

  • kwargs (dict) – Additional kwargs are fed to xarray.open_dataset().

Returns:

dtree (xarray.DataTree) – DataTree

xradar.io.backends.open_rainbow_datatree(filename_or_obj, **kwargs)[source]#

Open Rainbow5 dataset as xarray.DataTree.

Deprecated since version Use: xd.open_datatree(file, engine="rainbow") instead.

xradar.io.backends.open_uf_datatree(filename_or_obj, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, sweep=None, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_as_coords=True, optional=True, optional_groups=False, lock=None, **kwargs)[source]#

Open a Universal Format (UF) dataset as xarray.DataTree.

Deprecated since version Use: xd.open_datatree(file, engine="uf") instead.

This function loads UF radar data into a DataTree structure, which organizes radar sweeps as separate nodes. Provides options for decoding time and applying various transformations to the data.

Parameters:
  • filename_or_obj (str, Path, file-like, or DataStore) – The path or file-like object representing the radar file. Path-like objects are interpreted as local or remote paths.

  • mask_and_scale (bool, optional) – If True, replaces values in the dataset that match _FillValue with NaN and applies scale and offset adjustments. Default is True.

  • decode_times (bool, optional) – If True, decodes time variables according to CF conventions. Default is True.

  • concat_characters (bool, optional) – If True, concatenates character arrays along the last dimension, forming string arrays. Default is True.

  • decode_coords (bool, optional) – If True, decodes the “coordinates” attribute to identify coordinates in the resulting dataset. Default is True.

  • drop_variables (str or list of str, optional) – Specifies variables to exclude from the dataset. Useful for removing problematic or inconsistent variables. Default is None.

  • use_cftime (bool, optional) – If True, uses cftime objects to represent time variables; if False, uses np.datetime64 objects. If None, chooses the best format automatically. Default is None.

  • decode_timedelta (bool, optional) – If True, decodes variables with units of time (e.g., seconds, minutes) into timedelta objects. If False, leaves them as numeric values. Default is None.

  • sweep (int or list of int, optional) – Sweep numbers to extract from the dataset. Default is None, which extracts all sweeps.

  • first_dim ({"time", "auto"}, optional) – Defines the first dimension for each sweep. If “time,” uses time as the first dimension. If “auto,” determines the first dimension based on the sweep type (azimuth or elevation). Default is “auto.”

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(). Only used if decode_coords=True. Default is None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool, optional) – If True, corrects errors in the second angle data, such as misaligned elevation or azimuth values. Default is False.

  • site_as_coords (bool, optional) – Attaches radar site coordinates to the dataset if True. Default is True.

  • optional (bool, optional) – If True, suppresses errors for optional dataset attributes, making them optional instead of required. Default is True.

  • optional_groups (bool, optional) – If True, adds the /radar_parameters, /georeferencing_correction and /radar_calibration metadata groups. Default is False.

  • lock (threading.Lock or None, optional) – Lock used when reading the file. Default is None (the UF lock).

  • kwargs (dict) – Additional keyword arguments passed to xarray.open_datatree().

Returns:

dtree (xarray.DataTree) – An xarray.DataTree representing the radar data organized by sweeps.

Data Export#

CfRadial2 output#

This sub-module contains the writer for export of CfRadial2-based radar data.

Code ported from wradlib.

Example:

import xradar as xd
dtree = xd.io.to_cfradial2(dtree, filename)

to_cfradial2

Save DataTree to CfRadial2 compliant file.

xradar.io.export.cfradial2.to_cfradial2(dtree, filename, engine=None, timestep=None, deepcopy=False)[source]#

Save DataTree to CfRadial2 compliant file.

The input DataTree is never modified. All sweep rewrites and root attribute edits are applied to a copy, which is shallow by default.

Parameters:
  • dtree (xarray.DataTree) – DataTree with CfRadial2 groups.

  • filename (str) – output filename

Keyword Arguments:
  • timestep (int) – timestep of wanted volume, currently not used

  • engine (str) – Either netcdf4 or h5netcdf.

  • deepcopy (bool) – If True, work on a deep copy of dtree (the data is duplicated in memory). If False (default), work on a shallow copy, which shares the underlying data arrays with dtree but not its structure and attributes.

ODIM_H5 output#

This sub-module contains the writer for export of ODIM_H5-based radar data.

Code ported from wradlib.

Example:

import xradar as xd
dtree = xd.io.to_odim(dtree, filename)

to_odim

Save DataTree to ODIM_H5/V2_2 compliant file.

xradar.io.export.odim.to_odim(dtree, filename, source=None, optional_how=False, compression='gzip', compression_opts=6)[source]#

Save DataTree to ODIM_H5/V2_2 compliant file.

Parameters:
Keyword Arguments:
  • source (str, optional) – Radar identifiers for what/source (see ODIM documentation), at least one of NOD, RAD or WMO. Defaults to the identifiers stored in the global attributes by the ODIM reader (wmo__id, node, site_name, wmo__originating_centre, wmo__wsi).

  • optional_how (boolean) – True to include optional how attributes, defaults to False

  • compression (str) – Compression filter name, defaults to “gzip”.

  • compression_opts (compression strategy) – options as needed by above filter, defaults to 6

xradar.io.export.to_cfradial1(dtree=None, filename=None, calibs=True, range_geometry='common')[source]#

Convert a radar xarray.DataTree to the CfRadial1 format and save it to a file. Ensure that the resulting dataset is well-formed and does not include specified extraneous variables.

Parameters:
  • dtree (xarray.DataTree) – Radar xarray.DataTree object.

  • filename (str, optional) – The name of the output netCDF file. When omitted, a name is derived from the instrument name and first timestamp.

  • calibs (bool, optional) – Whether to include calibration parameters.

  • range_geometry ({"common", "per_sweep"}, optional) – CfRadial1 has one range(range) for all rays. "common" (default) needs the same first gate and gate spacing in all sweeps (the number of gates may differ) and raises an error otherwise. "per_sweep" writes sweeps with different geometries as they are, in a 2-D range(sweep, range) with the attributes meters_to_center_of_first_gate and meters_between_gates per sweep (CfRadial 1.4 Section 2.5). Sweeps with fewer gates continue their grid and have NaN measurements in the remaining gates. If all sweeps share the geometry, the usual 1-D range is written. xradar reads such files, other readers may not (e.g. Py-ART, ARM-DOE/pyart#1900).

xradar.io.export.to_cfradial2(dtree, filename, engine=None, timestep=None, deepcopy=False)[source]#

Save DataTree to CfRadial2 compliant file.

The input DataTree is never modified. All sweep rewrites and root attribute edits are applied to a copy, which is shallow by default.

Parameters:
  • dtree (xarray.DataTree) – DataTree with CfRadial2 groups.

  • filename (str) – output filename

Keyword Arguments:
  • timestep (int) – timestep of wanted volume, currently not used

  • engine (str) – Either netcdf4 or h5netcdf.

  • deepcopy (bool) – If True, work on a deep copy of dtree (the data is duplicated in memory). If False (default), work on a shallow copy, which shares the underlying data arrays with dtree but not its structure and attributes.

xradar.io.export.to_odim(dtree, filename, source=None, optional_how=False, compression='gzip', compression_opts=6)[source]#

Save DataTree to ODIM_H5/V2_2 compliant file.

Parameters:
Keyword Arguments:
  • source (str, optional) – Radar identifiers for what/source (see ODIM documentation), at least one of NOD, RAD or WMO. Defaults to the identifiers stored in the global attributes by the ODIM reader (wmo__id, node, site_name, wmo__originating_centre, wmo__wsi).

  • optional_how (boolean) – True to include optional how attributes, defaults to False

  • compression (str) – Compression filter name, defaults to “gzip”.

  • compression_opts (compression strategy) – options as needed by above filter, defaults to 6

class xradar.io.CfRadial1BackendEntrypoint[source]#

Bases: BackendEntrypoint

Xarray BackendEntrypoint for CfRadial1 data.

Keyword Arguments:
  • first_dim (str) – Can be time or auto first dimension. If set to auto, first dimension will be either azimuth or elevation depending on type of sweep. Defaults to auto.

  • reindex_coord (dict, optional) – Defaults to None, no reindexing. Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked if decode_coords=True.

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool) – For PPI only. If True, fixes erroneous second angle data. Defaults to False.

  • site_as_coords (bool) – Attach radar site-coordinates to Dataset, defaults to True.

  • kwargs (dict) – Additional kwargs are fed to xarray.open_dataset().

description: ClassVar[str] = 'Open CfRadial1 (.nc, .nc4) using netCDF4 in Xarray'#
guess_can_open(filename_or_obj)[source]#

CfRadial1 file (netCDF with sweep_start_ray_index and a Conventions or version mentioning CF/Radial).

open_dataset(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=False, format=None, group='/', first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_as_coords=True, optional=True)[source]#

Backend open_dataset method used by Xarray in open_dataset().

open_datatree(filename_or_obj, **kwargs)[source]#

Open a CfRadial1 file as xarray.DataTree. See open_groups_as_dict() for keyword arguments.

open_groups_as_dict(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=False, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_coords=True, optional=True, optional_groups=False, sweep=None, netcdf_engine='netcdf4')[source]#

Open a CfRadial1 file as a CfRadial2-shaped dict of group datasets.

Parameters:
  • filename_or_obj (str, Path, or file-like) – Path or file-like object understood by the underlying reader.

  • mask_and_scale (bool or dict-like, optional) – Replace fill values with NA and apply scale_factor/add_offset decoding. See xarray.open_dataset(). Defaults to True.

  • decode_times (bool or dict-like, optional) – Decode CF time variables (calendar, units) into np.datetime64. Defaults to True.

  • concat_characters (bool or dict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults to True.

  • decode_coords (bool or {"coordinates", "all"}, optional) – Decode the CF coordinates attribute. Defaults to True (equivalent to "coordinates").

  • drop_variables (str or iterable of str, optional) – Names of variables to drop before processing.

  • use_cftime (bool, optional) – Force cftime decoding for time variables (instead of np.datetime64). Defaults to None (auto).

  • decode_timedelta (bool, optional) – Decode CF timedelta variables. Default mirrors decode_times unless the backend overrides it (cfradial1, cfradial2, and imd default to False).

  • sweep (int, str, or list of int/str, optional) – Sweep selection. None (default) returns all sweeps. An int or "sweep_N" string returns one sweep; a list returns the named subset.

  • first_dim ({"auto", "time"}, optional) – Leading dimension of each sweep dataset. "auto" picks azimuth (PPI) or elevation (RHI); "time" keeps the raw time axis. Default "auto" ("time" for cfradial2).

  • optional (bool, optional) – Include optional root variables when available. Defaults to True.

  • optional_groups (bool, optional) – Include the /radar_parameters, /georeferencing_correction, and /radar_calibration metadata subgroups under the root. Defaults to False.

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked when decode_coords=True. Defaults to None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective with first_dim="auto". Defaults to False.

  • site_coords (bool, optional) – Attach latitude/longitude/altitude as coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults to True.

  • netcdf_engine ({"netcdf4", "h5netcdf"}, optional) – Underlying NetCDF engine used by xr.open_dataset to read the CfRadial1 file. Defaults to "netcdf4".

Returns:

dict[str, xarray.Dataset] – CfRadial2 group paths (/, /sweep_N, optional /radar_parameters etc.) mapped to their datasets, ready for xarray.DataTree.from_dict().

supports_groups: ClassVar[bool] = True#
url: ClassVar[str] = 'https://xradar.rtfd.io/en/latest/io.html#cfradial1'#
class xradar.io.CfRadial2BackendEntrypoint[source]#

Bases: BackendEntrypoint

Xarray BackendEntrypoint for CfRadial2/FM301 grouped datasets.

Keyword Arguments:
  • sweep (int, str, iterable, optional) – Sweep selection. Defaults to all available sweeps.

  • first_dim (str) – Can be time or auto. Defaults to time.

  • optional (bool) – Keep optional root variables when available. Defaults to True.

  • optional_groups (bool) – Include root metadata subgroups if present. Defaults to False.

  • kwargs (dict) – Additional kwargs are fed to xarray.open_datatree().

description: ClassVar[str] = 'Open CfRadial2/FM301 grouped datasets in Xarray'#
guess_can_open(filename_or_obj)[source]#

CfRadial2 file (netCDF/HDF5 with sweep groups, whose Conventions mention CF/Radial and whose root has sweep_group_name and time_coverage_start).

Files with sweep_start_ray_index (CfRadial1) and vendor files which use the CfRadial2 layout without the time coverage (e.g. WindCube) are not claimed.

open_dataset(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=False, group='sweep_0', first_dim='time', optional=True)[source]#

Backend open_dataset method used by Xarray in open_dataset().

open_datatree(filename_or_obj, **kwargs)[source]#

Open a CfRadial2/FM301 grouped file as xarray.DataTree. See open_groups_as_dict() for keyword arguments.

open_groups_as_dict(filename_or_obj, *, sweep=None, first_dim='time', optional=True, optional_groups=False, site_coords=True, netcdf_engine=None, **kwargs)[source]#

Open a CfRadial2/FM301 grouped file as a dict of normalized group datasets. Best-effort normalization of common institutional variations is applied so the result matches xradar’s FM301-oriented layout.

Parameters:
  • filename_or_obj (str, Path, or file-like) – Path or file-like object understood by the underlying reader.

  • mask_and_scale (bool or dict-like, optional) – Replace fill values with NA and apply scale_factor/add_offset decoding. See xarray.open_dataset(). Defaults to True.

  • decode_times (bool or dict-like, optional) – Decode CF time variables (calendar, units) into np.datetime64. Defaults to True.

  • concat_characters (bool or dict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults to True.

  • decode_coords (bool or {"coordinates", "all"}, optional) – Decode the CF coordinates attribute. Defaults to True (equivalent to "coordinates").

  • drop_variables (str or iterable of str, optional) – Names of variables to drop before processing.

  • use_cftime (bool, optional) – Force cftime decoding for time variables (instead of np.datetime64). Defaults to None (auto).

  • decode_timedelta (bool, optional) – Decode CF timedelta variables. Default mirrors decode_times unless the backend overrides it (cfradial1, cfradial2, and imd default to False).

  • sweep (int, str, or list of int/str, optional) – Sweep selection. None (default) returns all sweeps. An int or "sweep_N" string returns one sweep; a list returns the named subset.

  • first_dim ({"auto", "time"}, optional) – Leading dimension of each sweep dataset. "auto" picks azimuth (PPI) or elevation (RHI); "time" keeps the raw time axis. Default "auto" ("time" for cfradial2).

  • optional (bool, optional) – Include optional root variables when available. Defaults to True.

  • optional_groups (bool, optional) – Include the /radar_parameters, /georeferencing_correction, and /radar_calibration metadata subgroups under the root. Defaults to False.

  • site_coords (bool, optional) – Keep latitude/longitude/altitude as coordinates on the root dataset. CfRadial2 stores station coords at root by default; pass False to drop them. Defaults to True.

  • netcdf_engine (str, optional) – netCDF engine used to read the file (e.g. "netcdf4" or "h5netcdf"). Defaults to None (xarray’s choice).

Returns:

dict[str, xarray.Dataset] – CfRadial2 group paths (/, /sweep_N, optional /radar_parameters etc.) mapped to their datasets, ready for xarray.DataTree.from_dict().

supports_groups: ClassVar[bool] = True#
url: ClassVar[str] = 'https://xradar.rtfd.io/en/latest/io.html#cfradial2'#
class xradar.io.DataMetBackendEntrypoint[source]#

Bases: BackendEntrypoint

Xarray BackendEntrypoint for DataMet data.

description: ClassVar[str] = 'Open DataMet files in Xarray'#
guess_can_open(filename_or_obj)[source]#

DataMet volume (tar archive with navigation.txt).

open_dataset(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, group=None, reindex_coord=None, reindex_angle=False, first_dim='auto', site_as_coords=True)[source]#

Backend open_dataset method used by Xarray in open_dataset().

open_datatree(filename_or_obj, **kwargs)[source]#

Open a DataMet archive as xarray.DataTree. See open_groups_as_dict() for keyword arguments.

open_groups_as_dict(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, first_dim='auto', reindex_coord=None, reindex_angle=False, site_coords=True, sweep=None, optional=True, optional_groups=False)[source]#

Open a DataMet (Servizio Meteorologico Italiano) .tar.gz archive as a CfRadial2-shaped dict of group datasets.

Parameters:
  • filename_or_obj (str, Path, or file-like) – Path or file-like object understood by the underlying reader.

  • mask_and_scale (bool or dict-like, optional) – Replace fill values with NA and apply scale_factor/add_offset decoding. See xarray.open_dataset(). Defaults to True.

  • decode_times (bool or dict-like, optional) – Decode CF time variables (calendar, units) into np.datetime64. Defaults to True.

  • concat_characters (bool or dict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults to True.

  • decode_coords (bool or {"coordinates", "all"}, optional) – Decode the CF coordinates attribute. Defaults to True (equivalent to "coordinates").

  • drop_variables (str or iterable of str, optional) – Names of variables to drop before processing.

  • use_cftime (bool, optional) – Force cftime decoding for time variables (instead of np.datetime64). Defaults to None (auto).

  • decode_timedelta (bool, optional) – Decode CF timedelta variables. Default mirrors decode_times unless the backend overrides it (cfradial1, cfradial2, and imd default to False).

  • sweep (int, str, or list of int/str, optional) – Sweep selection. None (default) returns all sweeps. An int or "sweep_N" string returns one sweep; a list returns the named subset.

  • first_dim ({"auto", "time"}, optional) – Leading dimension of each sweep dataset. "auto" picks azimuth (PPI) or elevation (RHI); "time" keeps the raw time axis. Default "auto" ("time" for cfradial2).

  • optional (bool, optional) – Include optional root variables when available. Defaults to True.

  • optional_groups (bool, optional) – Include the /radar_parameters, /georeferencing_correction, and /radar_calibration metadata subgroups under the root. Defaults to False.

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked when decode_coords=True. Defaults to None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • site_coords (bool, optional) – Attach latitude/longitude/altitude as coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults to True.

Returns:

dict[str, xarray.Dataset] – CfRadial2 group paths (/, /sweep_N, optional /radar_parameters etc.) mapped to their datasets, ready for xarray.DataTree.from_dict().

supports_groups: ClassVar[bool] = True#
url: ClassVar[str] = 'https://xradar.rtfd.io/latest/io.html#datamet-data-i-o'#
class xradar.io.FurunoBackendEntrypoint[source]#

Bases: BackendEntrypoint

Xarray BackendEntrypoint for Furuno data.

description: ClassVar[str] = 'Open FURUNO (.scn, .scnx) in Xarray'#
guess_can_open(filename_or_obj)[source]#

Furuno SCN/SCNX, also gzip-compressed (header size and version).

open_dataset(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, group=None, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_as_coords=True, obsmode=None)[source]#

Backend open_dataset method used by Xarray in open_dataset().

open_datatree(filename_or_obj, **kwargs)[source]#

Open a Furuno SCN or SCNX file as xarray.DataTree. See open_groups_as_dict() for keyword arguments.

open_groups_as_dict(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_coords=True, sweep=None, optional=True, optional_groups=False, obsmode=None)[source]#

Open a Furuno SCN or SCNX file as a CfRadial2-shaped dict of group datasets.

Parameters:
  • filename_or_obj (str, Path, or file-like) – Path or file-like object understood by the underlying reader.

  • mask_and_scale (bool or dict-like, optional) – Replace fill values with NA and apply scale_factor/add_offset decoding. See xarray.open_dataset(). Defaults to True.

  • decode_times (bool or dict-like, optional) – Decode CF time variables (calendar, units) into np.datetime64. Defaults to True.

  • concat_characters (bool or dict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults to True.

  • decode_coords (bool or {"coordinates", "all"}, optional) – Decode the CF coordinates attribute. Defaults to True (equivalent to "coordinates").

  • drop_variables (str or iterable of str, optional) – Names of variables to drop before processing.

  • use_cftime (bool, optional) – Force cftime decoding for time variables (instead of np.datetime64). Defaults to None (auto).

  • decode_timedelta (bool, optional) – Decode CF timedelta variables. Default mirrors decode_times unless the backend overrides it (cfradial1, cfradial2, and imd default to False).

  • sweep (int, str, or list of int/str, optional) – Sweep selection. None (default) returns all sweeps. An int or "sweep_N" string returns one sweep; a list returns the named subset.

  • first_dim ({"auto", "time"}, optional) – Leading dimension of each sweep dataset. "auto" picks azimuth (PPI) or elevation (RHI); "time" keeps the raw time axis. Default "auto" ("time" for cfradial2).

  • optional (bool, optional) – Include optional root variables when available. Defaults to True.

  • optional_groups (bool, optional) – Include the /radar_parameters, /georeferencing_correction, and /radar_calibration metadata subgroups under the root. Defaults to False.

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked when decode_coords=True. Defaults to None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective with first_dim="auto". Defaults to False.

  • site_coords (bool, optional) – Attach latitude/longitude/altitude as coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults to True.

  • obsmode (int or None, optional) – Override the file’s observation-mode flag (rare; only needed for files written by older firmware). Defaults to None.

Returns:

dict[str, xarray.Dataset] – CfRadial2 group paths (/, /sweep_N, optional /radar_parameters etc.) mapped to their datasets, ready for xarray.DataTree.from_dict().

supports_groups: ClassVar[bool] = True#
url: ClassVar[str] = 'https://xradar.rtfd.io/en/latest/io.html#furuno-binary-data'#
class xradar.io.GamicBackendEntrypoint[source]#

Bases: BackendEntrypoint

Xarray BackendEntrypoint for GAMIC data.

Keyword Arguments:
  • first_dim (str) – Can be time or auto first dimension. If set to auto, first dimension will be either azimuth or elevation depending on type of sweep. Defaults to auto.

  • reindex_coord (dict, optional) – Defaults to None, no reindexing. Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked if decode_coords=True.

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool) – For PPI only. If True, fixes erroneous second angle data. Defaults to False.

  • site_as_coords (bool) – Attach radar site-coordinates to Dataset, defaults to True.

  • kwargs (dict) – Additional kwargs are fed to xarray.open_dataset().

description: ClassVar[str] = 'Open GAMIC HDF5 (.h5, .hdf5, .mvol) using h5netcdf in Xarray'#
guess_can_open(filename_or_obj)[source]#

GAMIC HDF5 file (what and scan0 groups).

open_dataset(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, format=None, group='sweep_0', invalid_netcdf=None, phony_dims='access', decode_vlen_strings=True, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_as_coords=True)[source]#

Backend open_dataset method used by Xarray in open_dataset().

open_datatree(filename_or_obj, **kwargs)[source]#

Open a GAMIC HDF5 file as xarray.DataTree. See open_groups_as_dict() for keyword arguments.

open_groups_as_dict(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, format=None, invalid_netcdf=None, phony_dims='access', decode_vlen_strings=True, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_coords=True, sweep=None, optional=True, optional_groups=False)[source]#

Open a GAMIC HDF5 file as a CfRadial2-shaped dict of group datasets.

Parameters:
  • filename_or_obj (str, Path, or file-like) – Path or file-like object understood by the underlying reader.

  • mask_and_scale (bool or dict-like, optional) – Replace fill values with NA and apply scale_factor/add_offset decoding. See xarray.open_dataset(). Defaults to True.

  • decode_times (bool or dict-like, optional) – Decode CF time variables (calendar, units) into np.datetime64. Defaults to True.

  • concat_characters (bool or dict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults to True.

  • decode_coords (bool or {"coordinates", "all"}, optional) – Decode the CF coordinates attribute. Defaults to True (equivalent to "coordinates").

  • drop_variables (str or iterable of str, optional) – Names of variables to drop before processing.

  • use_cftime (bool, optional) – Force cftime decoding for time variables (instead of np.datetime64). Defaults to None (auto).

  • decode_timedelta (bool, optional) – Decode CF timedelta variables. Default mirrors decode_times unless the backend overrides it (cfradial1, cfradial2, and imd default to False).

  • sweep (int, str, or list of int/str, optional) – Sweep selection. None (default) returns all sweeps. An int or "sweep_N" string returns one sweep; a list returns the named subset.

  • first_dim ({"auto", "time"}, optional) – Leading dimension of each sweep dataset. "auto" picks azimuth (PPI) or elevation (RHI); "time" keeps the raw time axis. Default "auto" ("time" for cfradial2).

  • optional (bool, optional) – Include optional root variables when available. Defaults to True.

  • optional_groups (bool, optional) – Include the /radar_parameters, /georeferencing_correction, and /radar_calibration metadata subgroups under the root. Defaults to False.

  • format (str, optional) – h5netcdf format string. Defaults to None.

  • invalid_netcdf (bool, optional) – Accept HDF5 files that are not strictly NetCDF-conformant.

  • phony_dims ({"access", "sort", None}, optional) – How h5netcdf labels unnamed dimensions. Defaults to "access".

  • decode_vlen_strings (bool, optional) – Decode variable-length strings stored in HDF5. Defaults to True.

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked when decode_coords=True. Defaults to None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective with first_dim="auto". Defaults to False.

  • site_coords (bool, optional) – Attach latitude/longitude/altitude as coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults to True.

Returns:

dict[str, xarray.Dataset] – CfRadial2 group paths (/, /sweep_N, optional /radar_parameters etc.) mapped to their datasets, ready for xarray.DataTree.from_dict().

supports_groups: ClassVar[bool] = True#
url: ClassVar[str] = 'https://xradar.rtfd.io/en/latest/io.html#gamic-hdf5'#
class xradar.io.HPLBackendEntrypoint[source]#

Bases: BackendEntrypoint

Xarray BackendEntrypoint for Halo Photonics Doppler processed lidar data.

Keyword Arguments:
  • first_dim (str) – Can be time or auto first dimension. If set to auto, first dimension will be either azimuth or elevation depending on type of sweep. Defaults to auto.

  • site_as_coords (bool) – Attach radar site-coordinates to Dataset, defaults to True.

  • kwargs (dict) – Additional kwargs are fed to xarray.open_dataset().

description: ClassVar[str] = 'Backend for reading Halo Photonics Doppler lidar processed data'#
guess_can_open(filename_or_obj)[source]#

Halo Photonics .hpl (text header starting with Filename:).

open_dataset(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, format=None, group='sweep_0', invalid_netcdf=None, phony_dims='access', decode_vlen_strings=True, first_dim='auto', reindex_coord=None, reindex_angle=False, site_as_coords=True, optional=True, latitude=0, longitude=0, altitude=0, transition_threshold_azi=0.01, transition_threshold_el=0.005)[source]#

Backend open_dataset method used by Xarray in open_dataset().

open_datatree(filename_or_obj, **kwargs)[source]#

Open a Halo Photonics .hpl file as xarray.DataTree. See open_groups_as_dict() for keyword arguments.

open_groups_as_dict(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, format=None, invalid_netcdf=None, phony_dims='access', decode_vlen_strings=True, first_dim='auto', reindex_coord=None, reindex_angle=False, site_coords=True, sweep=None, optional=True, optional_groups=False, latitude=0, longitude=0, altitude=0, transition_threshold_azi=0.01, transition_threshold_el=0.005)[source]#

Open a Halo Photonics Stream Line (.hpl) lidar file as a CfRadial2-shaped dict of group datasets.

Parameters:
  • filename_or_obj (str, Path, or file-like) – Path or file-like object understood by the underlying reader.

  • mask_and_scale (bool or dict-like, optional) – Replace fill values with NA and apply scale_factor/add_offset decoding. See xarray.open_dataset(). Defaults to True.

  • decode_times (bool or dict-like, optional) – Decode CF time variables (calendar, units) into np.datetime64. Defaults to True.

  • concat_characters (bool or dict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults to True.

  • decode_coords (bool or {"coordinates", "all"}, optional) – Decode the CF coordinates attribute. Defaults to True (equivalent to "coordinates").

  • drop_variables (str or iterable of str, optional) – Names of variables to drop before processing.

  • use_cftime (bool, optional) – Force cftime decoding for time variables (instead of np.datetime64). Defaults to None (auto).

  • decode_timedelta (bool, optional) – Decode CF timedelta variables. Default mirrors decode_times unless the backend overrides it (cfradial1, cfradial2, and imd default to False).

  • sweep (int, str, or list of int/str, optional) – Sweep selection. None (default) returns all sweeps. An int or "sweep_N" string returns one sweep; a list returns the named subset.

  • first_dim ({"auto", "time"}, optional) – Leading dimension of each sweep dataset. "auto" picks azimuth (PPI) or elevation (RHI); "time" keeps the raw time axis. Default "auto" ("time" for cfradial2).

  • optional (bool, optional) – Include optional root variables when available. Defaults to True.

  • optional_groups (bool, optional) – Include the /radar_parameters, /georeferencing_correction, and /radar_calibration metadata subgroups under the root. Defaults to False.

  • format (str, optional) – h5netcdf format string. Defaults to None.

  • invalid_netcdf (bool, optional) – Accept HDF5 files that are not strictly NetCDF-conformant.

  • phony_dims ({"access", "sort", None}, optional) – How h5netcdf labels unnamed dimensions. Defaults to "access".

  • decode_vlen_strings (bool, optional) – Decode variable-length strings stored in HDF5. Defaults to True.

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked when decode_coords=True. Defaults to None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • site_coords (bool, optional) – Attach latitude/longitude/altitude as coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults to True.

  • latitude (float, optional) – Override the site latitude (HPL files often lack geolocation).

  • longitude (float, optional) – Override the site longitude.

  • altitude (float, optional) – Override the site altitude above sea level (meters).

  • transition_threshold_azi (float, optional) – Azimuth-jump threshold (deg) for sweep boundary detection.

  • transition_threshold_el (float, optional) – Elevation-jump threshold (deg) for sweep boundary detection.

Returns:

dict[str, xarray.Dataset] – CfRadial2 group paths (/, /sweep_N, optional /radar_parameters etc.) mapped to their datasets, ready for xarray.DataTree.from_dict().

supports_groups: ClassVar[bool] = True#
url: ClassVar[str] = 'https://xradar.rtfd.io/en/latest/io.html#metek'#
class xradar.io.IMDBackendEntrypoint[source]#

Bases: BackendEntrypoint

Xarray BackendEntrypoint for India Meteorological Department (IMD) radar files.

IMD provides one NetCDF file per sweep. Open a single file with xr.open_dataset(file, engine="imd") to get a CfRadial2-compatible sweep xarray.Dataset. To assemble a multi-sweep volume, use open_imd_datatree() with a list of files.

Keyword Arguments:
  • first_dim (str) – Can be time or auto (default). auto selects azimuth (PPI) or elevation (RHI) as the first dimension.

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(). Defaults to None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • site_as_coords (bool) – If True (default), promote latitude/longitude/altitude to Dataset coordinates.

description: ClassVar[str] = 'Open India Meteorological Department (IMD) radar NetCDF files in Xarray'#
guess_can_open(filename_or_obj)[source]#

IMD IRIS-netCDF file (radialAzim and elevationAngle).

open_dataset(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, format=None, group=None, first_dim='auto', reindex_coord=None, reindex_angle=False, site_as_coords=True)[source]#

Backend open_dataset method used by Xarray in open_dataset().

open_datatree(filename_or_obj, **kwargs)[source]#

Open a single IMD NetCDF file as xarray.DataTree. See open_groups_as_dict() for keyword arguments.

open_groups_as_dict(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=False, sweep=None, first_dim='auto', reindex_coord=None, reindex_angle=False, site_coords=True, optional_groups=False)[source]#

Open a single IMD (India Meteorological Department) NetCDF file as a CfRadial2-shaped dict of group datasets. Single-file only — for multi-file IMD volumes use open_imd_datatree().

Parameters:
  • filename_or_obj (str, Path, or file-like) – Path or file-like object understood by the underlying reader.

  • mask_and_scale (bool or dict-like, optional) – Replace fill values with NA and apply scale_factor/add_offset decoding. See xarray.open_dataset(). Defaults to True.

  • decode_times (bool or dict-like, optional) – Decode CF time variables (calendar, units) into np.datetime64. Defaults to True.

  • concat_characters (bool or dict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults to True.

  • decode_coords (bool or {"coordinates", "all"}, optional) – Decode the CF coordinates attribute. Defaults to True (equivalent to "coordinates").

  • drop_variables (str or iterable of str, optional) – Names of variables to drop before processing.

  • use_cftime (bool, optional) – Force cftime decoding for time variables (instead of np.datetime64). Defaults to None (auto).

  • decode_timedelta (bool, optional) – Decode CF timedelta variables. Default mirrors decode_times unless the backend overrides it (cfradial1, cfradial2, and imd default to False).

  • sweep (int, str, or list of int/str, optional) – Sweep selection. None (default) returns all sweeps. An int or "sweep_N" string returns one sweep; a list returns the named subset.

  • first_dim ({"auto", "time"}, optional) – Leading dimension of each sweep dataset. "auto" picks azimuth (PPI) or elevation (RHI); "time" keeps the raw time axis. Default "auto" ("time" for cfradial2).

  • optional_groups (bool, optional) – Include the /radar_parameters, /georeferencing_correction, and /radar_calibration metadata subgroups under the root. Defaults to False.

  • sweep (int, str or list, optional) – IMD files hold one sweep, so only None, 0 or "sweep_0" are accepted. Defaults to None.

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked when decode_coords=True. Defaults to None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • site_coords (bool, optional) – Attach latitude/longitude/altitude as coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults to True.

Returns:

dict[str, xarray.Dataset] – CfRadial2 group paths (/, /sweep_N, optional /radar_parameters etc.) mapped to their datasets, ready for xarray.DataTree.from_dict().

supports_groups: ClassVar[bool] = True#
url: ClassVar[str] = 'https://xradar.rtfd.io/en/latest/io.html#imd'#
class xradar.io.IrisBackendEntrypoint[source]#

Bases: BackendEntrypoint

Xarray BackendEntrypoint for IRIS/Sigmet data.

description: ClassVar[str] = 'Open IRIS/Sigmet files in Xarray'#
guess_can_open(filename_or_obj)[source]#

IRIS/Sigmet RAW file (product_hdr structure, RAW product).

open_dataset(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, group=None, lock=None, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_as_coords=True, optional=True)[source]#

Backend open_dataset method used by Xarray in open_dataset().

open_datatree(filename_or_obj, **kwargs)[source]#

Open an Iris/Sigmet RAW file as xarray.DataTree. See open_groups_as_dict() for keyword arguments.

open_groups_as_dict(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, lock=None, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_coords=True, sweep=None, optional=True, optional_groups=False)[source]#

Open an Iris/Sigmet RAW file as a CfRadial2-shaped dict of group datasets.

Parameters:
  • filename_or_obj (str, Path, or file-like) – Path or file-like object understood by the underlying reader.

  • mask_and_scale (bool or dict-like, optional) – Replace fill values with NA and apply scale_factor/add_offset decoding. See xarray.open_dataset(). Defaults to True.

  • decode_times (bool or dict-like, optional) – Decode CF time variables (calendar, units) into np.datetime64. Defaults to True.

  • concat_characters (bool or dict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults to True.

  • decode_coords (bool or {"coordinates", "all"}, optional) – Decode the CF coordinates attribute. Defaults to True (equivalent to "coordinates").

  • drop_variables (str or iterable of str, optional) – Names of variables to drop before processing.

  • use_cftime (bool, optional) – Force cftime decoding for time variables (instead of np.datetime64). Defaults to None (auto).

  • decode_timedelta (bool, optional) – Decode CF timedelta variables. Default mirrors decode_times unless the backend overrides it (cfradial1, cfradial2, and imd default to False).

  • sweep (int, str, or list of int/str, optional) – Sweep selection. None (default) returns all sweeps. An int or "sweep_N" string returns one sweep; a list returns the named subset.

  • first_dim ({"auto", "time"}, optional) – Leading dimension of each sweep dataset. "auto" picks azimuth (PPI) or elevation (RHI); "time" keeps the raw time axis. Default "auto" ("time" for cfradial2).

  • optional (bool, optional) – Include optional root variables when available. Defaults to True.

  • optional_groups (bool, optional) – Include the /radar_parameters, /georeferencing_correction, and /radar_calibration metadata subgroups under the root. Defaults to False.

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked when decode_coords=True. Defaults to None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective with first_dim="auto". Defaults to False.

  • site_coords (bool, optional) – Attach latitude/longitude/altitude as coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults to True.

  • lock (threading.Lock or None, optional) – Reader lock for thread-safe access. Defaults to None.

Returns:

dict[str, xarray.Dataset] – CfRadial2 group paths (/, /sweep_N, optional /radar_parameters etc.) mapped to their datasets, ready for xarray.DataTree.from_dict().

supports_groups: ClassVar[bool] = True#
url: ClassVar[str] = 'https://xradar.rtfd.io/latest/io.html#iris-sigmet-data-i-o'#
class xradar.io.MRRBackendEntrypoint[source]#

Bases: BackendEntrypoint

Xarray BackendEntrypoint for Metek MRR2 data.

Keyword Arguments:
  • first_dim (str) – Can be time or auto first dimension. If set to auto, first dimension will be either azimuth or elevation depending on type of sweep. Defaults to auto.

  • site_as_coords (bool) – Attach radar site-coordinates to Dataset, defaults to True.

  • kwargs (dict) – Additional kwargs are fed to xarray.open_dataset().

description: ClassVar[str] = 'Backend for reading Metek MRR2 processed and raw data'#
guess_can_open(filename_or_obj)[source]#

Metek MRR file (header lines starting with MRR).

open_dataset(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, format=None, group='/', invalid_netcdf=None, phony_dims='access', decode_vlen_strings=True, first_dim='auto', site_as_coords=True, optional=True)[source]#

Backend open_dataset method used by Xarray in open_dataset().

open_datatree(filename_or_obj, **kwargs)[source]#

Open a Metek MRR2 file as xarray.DataTree. See open_groups_as_dict() for keyword arguments.

open_groups_as_dict(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, format=None, invalid_netcdf=None, phony_dims='access', decode_vlen_strings=True, first_dim='auto', site_coords=True, sweep=None, optional=True, optional_groups=False)[source]#

Open a Metek MRR2 (.ave/.pro/.raw) file as a CfRadial2-shaped dict of group datasets. MRR2 is a vertically pointing radar — the output contains one sweep_0 group with all profiles.

Parameters:
  • filename_or_obj (str, Path, or file-like) – Path or file-like object understood by the underlying reader.

  • mask_and_scale (bool or dict-like, optional) – Replace fill values with NA and apply scale_factor/add_offset decoding. See xarray.open_dataset(). Defaults to True.

  • decode_times (bool or dict-like, optional) – Decode CF time variables (calendar, units) into np.datetime64. Defaults to True.

  • concat_characters (bool or dict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults to True.

  • decode_coords (bool or {"coordinates", "all"}, optional) – Decode the CF coordinates attribute. Defaults to True (equivalent to "coordinates").

  • drop_variables (str or iterable of str, optional) – Names of variables to drop before processing.

  • use_cftime (bool, optional) – Force cftime decoding for time variables (instead of np.datetime64). Defaults to None (auto).

  • decode_timedelta (bool, optional) – Decode CF timedelta variables. Default mirrors decode_times unless the backend overrides it (cfradial1, cfradial2, and imd default to False).

  • sweep (int, str, or list of int/str, optional) – Sweep selection. None (default) returns all sweeps. An int or "sweep_N" string returns one sweep; a list returns the named subset.

  • first_dim ({"auto", "time"}, optional) – Leading dimension of each sweep dataset. "auto" picks azimuth (PPI) or elevation (RHI); "time" keeps the raw time axis. Default "auto" ("time" for cfradial2).

  • optional (bool, optional) – Include optional root variables when available. Defaults to True.

  • optional_groups (bool, optional) – Include the /radar_parameters, /georeferencing_correction, and /radar_calibration metadata subgroups under the root. Defaults to False.

  • format (str, optional) – h5netcdf format string. Defaults to None.

  • invalid_netcdf (bool, optional) – Accept HDF5 files that are not strictly NetCDF-conformant.

  • phony_dims ({"access", "sort", None}, optional) – How h5netcdf labels unnamed dimensions. Defaults to "access".

  • decode_vlen_strings (bool, optional) – Decode variable-length strings stored in HDF5. Defaults to True.

  • site_coords (bool, optional) – Attach latitude/longitude/altitude as coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults to True.

Returns:

dict[str, xarray.Dataset] – CfRadial2 group paths (/, /sweep_N, optional /radar_parameters etc.) mapped to their datasets, ready for xarray.DataTree.from_dict().

supports_groups: ClassVar[bool] = True#
url: ClassVar[str] = 'https://xradar.rtfd.io/en/latest/io.html#metek'#
class xradar.io.NexradLevel2BackendEntrypoint[source]#

Bases: BackendEntrypoint

Xarray BackendEntrypoint for NEXRAD Level2 Data

description: ClassVar[str] = 'Open NEXRAD Level2 files in Xarray'#
guess_can_open(filename_or_obj)[source]#

NEXRAD Level II archive (AR2V / ARCHIVE2 volume header).

open_dataset(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, group=None, lock=None, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_as_coords=True, optional=True)[source]#

Backend open_dataset method used by Xarray in open_dataset().

open_datatree(filename_or_obj, **kwargs)[source]#

Open a NEXRAD Level II file as xarray.DataTree. See open_groups_as_dict() for keyword arguments.

open_groups_as_dict(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, sweep=None, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_coords=True, optional=True, optional_groups=False, incomplete_sweep='drop', lock=None, **kwargs)[source]#

Open a NEXRAD Level II file as a CfRadial2-shaped dict of group datasets. Accepts a single file path, a bytes buffer, or a list/tuple of LDM chunk paths (the first chunk must hold the AR2V volume header).

Parameters:
  • filename_or_obj (str, Path, or file-like) – Path or file-like object understood by the underlying reader.

  • mask_and_scale (bool or dict-like, optional) – Replace fill values with NA and apply scale_factor/add_offset decoding. See xarray.open_dataset(). Defaults to True.

  • decode_times (bool or dict-like, optional) – Decode CF time variables (calendar, units) into np.datetime64. Defaults to True.

  • concat_characters (bool or dict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults to True.

  • decode_coords (bool or {"coordinates", "all"}, optional) – Decode the CF coordinates attribute. Defaults to True (equivalent to "coordinates").

  • drop_variables (str or iterable of str, optional) – Names of variables to drop before processing.

  • use_cftime (bool, optional) – Force cftime decoding for time variables (instead of np.datetime64). Defaults to None (auto).

  • decode_timedelta (bool, optional) – Decode CF timedelta variables. Default mirrors decode_times unless the backend overrides it (cfradial1, cfradial2, and imd default to False).

  • sweep (int, str, or list of int/str, optional) – Sweep selection. None (default) returns all sweeps. An int or "sweep_N" string returns one sweep; a list returns the named subset.

  • first_dim ({"auto", "time"}, optional) – Leading dimension of each sweep dataset. "auto" picks azimuth (PPI) or elevation (RHI); "time" keeps the raw time axis. Default "auto" ("time" for cfradial2).

  • optional (bool, optional) – Include optional root variables when available. Defaults to True.

  • optional_groups (bool, optional) – Include the /radar_parameters, /georeferencing_correction, and /radar_calibration metadata subgroups under the root. Defaults to False.

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked when decode_coords=True. Defaults to None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective with first_dim="auto". Defaults to False.

  • site_coords (bool, optional) – Attach latitude/longitude/altitude as coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults to True.

  • incomplete_sweep ({"drop", "pad"}, optional) – How to handle sweeps with fewer rays than the VCP nominal count. "drop" (default) excludes them with a UserWarning; "pad" keeps them with NaN-filled rays so the reindexed azimuth grid is complete.

  • lock (threading.Lock or None, optional) – Reader lock for thread-safe access. Defaults to None.

Returns:

dict[str, xarray.Dataset] – CfRadial2 group paths (/, /sweep_N, optional /radar_parameters etc.) mapped to their datasets, ready for xarray.DataTree.from_dict().

supports_groups: ClassVar[bool] = True#
url: ClassVar[str] = 'tbd'#
class xradar.io.OdimBackendEntrypoint[source]#

Bases: BackendEntrypoint

Xarray BackendEntrypoint for ODIM data.

Keyword Arguments:
  • first_dim (str) – Can be time or auto first dimension. If set to auto, first dimension will be either azimuth or elevation depending on type of sweep. Defaults to auto.

  • reindex_coord (dict, optional) – Defaults to None, no reindexing. Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked if decode_coords=True.

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool) – If True, fixes erroneous second angle data. Defaults to False.

  • site_as_coords (bool) – Attach radar site-coordinates to Dataset, defaults to True.

  • kwargs (dict) – Additional kwargs are fed to xarray.open_dataset().

description: ClassVar[str] = 'Open ODIM_H5 (.h5, .hdf5) using h5netcdf in Xarray'#
guess_can_open(filename_or_obj)[source]#

ODIM_H5 file (HDF5 with Conventions ODIM_H5/...).

open_dataset(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, format=None, group='sweep_0', invalid_netcdf=None, phony_dims='access', decode_vlen_strings=True, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_as_coords=True)[source]#

Backend open_dataset method used by Xarray in open_dataset().

open_datatree(filename_or_obj, **kwargs)[source]#

Open an ODIM_H5 file as xarray.DataTree.

Builds the tree from open_groups_as_dict() and keeps each group’s file, so close() releases it. See open_groups_as_dict() for keyword arguments.

open_groups_as_dict(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, format=None, invalid_netcdf=None, phony_dims='access', decode_vlen_strings=True, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_coords=True, sweep=None, optional=True, optional_groups=False)[source]#

Open an ODIM_H5 file as a CfRadial2-shaped dict of group datasets.

Parameters:
  • filename_or_obj (str, Path, or file-like) – Path or file-like object understood by the underlying reader.

  • mask_and_scale (bool or dict-like, optional) – Replace fill values with NA and apply scale_factor/add_offset decoding. See xarray.open_dataset(). Defaults to True.

  • decode_times (bool or dict-like, optional) – Decode CF time variables (calendar, units) into np.datetime64. Defaults to True.

  • concat_characters (bool or dict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults to True.

  • decode_coords (bool or {"coordinates", "all"}, optional) – Decode the CF coordinates attribute. Defaults to True (equivalent to "coordinates").

  • drop_variables (str or iterable of str, optional) – Names of variables to drop before processing.

  • use_cftime (bool, optional) – Force cftime decoding for time variables (instead of np.datetime64). Defaults to None (auto).

  • decode_timedelta (bool, optional) – Decode CF timedelta variables. Default mirrors decode_times unless the backend overrides it (cfradial1, cfradial2, and imd default to False).

  • sweep (int, str, or list of int/str, optional) – Sweep selection. None (default) returns all sweeps. An int or "sweep_N" string returns one sweep; a list returns the named subset.

  • first_dim ({"auto", "time"}, optional) – Leading dimension of each sweep dataset. "auto" picks azimuth (PPI) or elevation (RHI); "time" keeps the raw time axis. Default "auto" ("time" for cfradial2).

  • optional (bool, optional) – Include optional root variables when available. Defaults to True.

  • optional_groups (bool, optional) – Include the /radar_parameters, /georeferencing_correction, and /radar_calibration metadata subgroups under the root. Defaults to False.

  • format (str, optional) – h5netcdf format string. Defaults to None.

  • invalid_netcdf (bool, optional) – Accept HDF5 files that are not strictly NetCDF-conformant.

  • phony_dims ({"access", "sort", None}, optional) – How h5netcdf labels unnamed dimensions. Defaults to "access".

  • decode_vlen_strings (bool, optional) – Decode variable-length strings stored in HDF5. Defaults to True.

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked when decode_coords=True. Defaults to None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective with first_dim="auto". Defaults to False.

  • site_coords (bool, optional) – Attach latitude/longitude/altitude as coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults to True.

Returns:

dict[str, xarray.Dataset] – CfRadial2 group paths (/, /sweep_N, optional /radar_parameters etc.) mapped to their datasets, ready for xarray.DataTree.from_dict().

supports_groups: ClassVar[bool] = True#
url: ClassVar[str] = 'https://xradar.rtfd.io/en/latest/io.html#odim-h5'#
class xradar.io.RainbowBackendEntrypoint[source]#

Bases: BackendEntrypoint

Xarray BackendEntrypoint for Rainbow5 data.

description: ClassVar[str] = 'Open Rainbow5 files in Xarray'#
guess_can_open(filename_or_obj)[source]#

Rainbow5 file (XML header starting with <volume).

open_dataset(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, group=None, reindex_coord=None, reindex_angle=False, first_dim='auto', site_as_coords=True)[source]#

Backend open_dataset method used by Xarray in open_dataset().

open_datatree(filename_or_obj, **kwargs)[source]#

Open a Rainbow5 file as xarray.DataTree. See open_groups_as_dict() for keyword arguments.

open_groups_as_dict(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, first_dim='auto', reindex_coord=None, reindex_angle=False, site_coords=True, sweep=None, optional=True, optional_groups=False)[source]#

Open a Rainbow5 file as a CfRadial2-shaped dict of group datasets.

Parameters:
  • filename_or_obj (str, Path, or file-like) – Path or file-like object understood by the underlying reader.

  • mask_and_scale (bool or dict-like, optional) – Replace fill values with NA and apply scale_factor/add_offset decoding. See xarray.open_dataset(). Defaults to True.

  • decode_times (bool or dict-like, optional) – Decode CF time variables (calendar, units) into np.datetime64. Defaults to True.

  • concat_characters (bool or dict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults to True.

  • decode_coords (bool or {"coordinates", "all"}, optional) – Decode the CF coordinates attribute. Defaults to True (equivalent to "coordinates").

  • drop_variables (str or iterable of str, optional) – Names of variables to drop before processing.

  • use_cftime (bool, optional) – Force cftime decoding for time variables (instead of np.datetime64). Defaults to None (auto).

  • decode_timedelta (bool, optional) – Decode CF timedelta variables. Default mirrors decode_times unless the backend overrides it (cfradial1, cfradial2, and imd default to False).

  • sweep (int, str, or list of int/str, optional) – Sweep selection. None (default) returns all sweeps. An int or "sweep_N" string returns one sweep; a list returns the named subset.

  • first_dim ({"auto", "time"}, optional) – Leading dimension of each sweep dataset. "auto" picks azimuth (PPI) or elevation (RHI); "time" keeps the raw time axis. Default "auto" ("time" for cfradial2).

  • optional (bool, optional) – Include optional root variables when available. Defaults to True.

  • optional_groups (bool, optional) – Include the /radar_parameters, /georeferencing_correction, and /radar_calibration metadata subgroups under the root. Defaults to False.

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked when decode_coords=True. Defaults to None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • site_coords (bool, optional) – Attach latitude/longitude/altitude as coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults to True.

Returns:

dict[str, xarray.Dataset] – CfRadial2 group paths (/, /sweep_N, optional /radar_parameters etc.) mapped to their datasets, ready for xarray.DataTree.from_dict().

supports_groups: ClassVar[bool] = True#
url: ClassVar[str] = 'https://xradar.rtfd.io/latest/io.html#rainbow-data-i-o'#
class xradar.io.UFBackendEntrypoint[source]#

Bases: BackendEntrypoint

Xarray BackendEntrypoint for Universal Format (UF) data.

description: ClassVar[str] = 'Open Universal Format (UF) files in Xarray'#
guess_can_open(filename_or_obj)[source]#

Universal Format, UF at the start of the first record.

open_dataset(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, group=None, lock=None, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_as_coords=True, optional=True)[source]#

Backend open_dataset method used by Xarray in open_dataset().

open_datatree(filename_or_obj, **kwargs)[source]#

Open a Universal Format (UF) file as xarray.DataTree. See open_groups_as_dict() for keyword arguments.

open_groups_as_dict(filename_or_obj, *, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, sweep=None, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_coords=True, optional=True, optional_groups=False, lock=None, **kwargs)[source]#

Open a Universal Format (UF) file as a CfRadial2-shaped dict of group datasets.

Parameters:
  • filename_or_obj (str, Path, or file-like) – Path or file-like object understood by the underlying reader.

  • mask_and_scale (bool or dict-like, optional) – Replace fill values with NA and apply scale_factor/add_offset decoding. See xarray.open_dataset(). Defaults to True.

  • decode_times (bool or dict-like, optional) – Decode CF time variables (calendar, units) into np.datetime64. Defaults to True.

  • concat_characters (bool or dict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults to True.

  • decode_coords (bool or {"coordinates", "all"}, optional) – Decode the CF coordinates attribute. Defaults to True (equivalent to "coordinates").

  • drop_variables (str or iterable of str, optional) – Names of variables to drop before processing.

  • use_cftime (bool, optional) – Force cftime decoding for time variables (instead of np.datetime64). Defaults to None (auto).

  • decode_timedelta (bool, optional) – Decode CF timedelta variables. Default mirrors decode_times unless the backend overrides it (cfradial1, cfradial2, and imd default to False).

  • sweep (int, str, or list of int/str, optional) – Sweep selection. None (default) returns all sweeps. An int or "sweep_N" string returns one sweep; a list returns the named subset.

  • first_dim ({"auto", "time"}, optional) – Leading dimension of each sweep dataset. "auto" picks azimuth (PPI) or elevation (RHI); "time" keeps the raw time axis. Default "auto" ("time" for cfradial2).

  • optional (bool, optional) – Include optional root variables when available. Defaults to True.

  • optional_groups (bool, optional) – Include the /radar_parameters, /georeferencing_correction, and /radar_calibration metadata subgroups under the root. Defaults to False.

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked when decode_coords=True. Defaults to None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective with first_dim="auto". Defaults to False.

  • site_coords (bool, optional) – Attach latitude/longitude/altitude as coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults to True.

  • lock (threading.Lock or None, optional) – Reader lock for thread-safe access. Defaults to None.

Returns:

dict[str, xarray.Dataset] – CfRadial2 group paths (/, /sweep_N, optional /radar_parameters etc.) mapped to their datasets, ready for xarray.DataTree.from_dict().

supports_groups: ClassVar[bool] = True#
url: ClassVar[str] = 'https://xradar.rtfd.io/latest/io.html#uf-data-i-o'#
xradar.io.discover_engine(filename_or_obj)[source]#

Find the xradar engine which can open the given file.

Each xradar backend checks the file with its guess_can_open (format signatures, e.g. AR2V for NEXRAD Level II, ODIM_H5 conventions in HDF5 files), see list_xradar_engines().

Parameters:

filename_or_obj (str, os.PathLike, bytes or file-like) – Radar file.

Returns:

engine (str) – Name of the engine, to be used with e.g. xr.open_dataset(filename, engine=engine, group="sweep_0").

Raises:

ValueError – If no xradar engine can open the file.

Examples

>>> engine = xd.io.discover_engine(filename)
>>> ds = xr.open_dataset(filename, engine=engine, group="sweep_0")
xradar.io.group_imd_files(paths)[source]#

Group IMD sweep files into volumes by filename stem.

IMD distributes one sweep per file. Files of a single volume share a common stem ending in .nc; additional sweeps in the same volume get numeric suffixes:

GOA210515003646-IMD-C.nc        <- sweep 0
GOA210515003646-IMD-C.nc.1      <- sweep 1
...
GOA210515003646-IMD-C.nc.9      <- sweep 9

A new volume changes the timestamp component of the stem.

Parameters:

paths (str, Path, or iterable of those) –

  • A directory path – all IMD files inside are grouped.

  • A glob pattern string – files matching the glob are grouped.

  • An iterable of file paths – grouped as-is.

Returns:

list[list[str]] – One list of absolute paths per detected volume, inner lists in sweep order (.nc, .nc.1, …).

Examples

>>> import xradar as xd
>>> for group in xd.io.group_imd_files("/data/goa"):
...     dtree = xd.io.open_imd_datatree(group)
xradar.io.list_engines()[source]#

Return a sorted list of engine names registered with open_datatree().

Examples

>>> import xradar as xd
>>> "odim" in xd.io.list_engines()
True
xradar.io.list_xradar_engines()[source]#

Names of the xarray backend engines provided by xradar.

Returns:

engines (list of str)

xradar.io.open_cfradial1_datatree(filename_or_obj, **kwargs)[source]#

Open CfRadial1 dataset as xarray.DataTree.

Deprecated since version Use: xd.open_datatree(file, engine="cfradial1") or xr.open_datatree(file, engine="cfradial1") instead.

Parameters:

filename_or_obj (str, Path, file-like or xarray.DataStore) – Strings and Path objects are interpreted as a path to a local or remote radar file

Keyword Arguments:
  • sweep (int, list of int, optional) – Sweep number(s) to extract, default to first sweep. If None, all sweeps are extracted into a list.

  • first_dim (str) – Can be time or auto first dimension. If set to auto, first dimension will be either azimuth or elevation depending on type of sweep. Defaults to auto.

  • reindex_coord (dict, optional) – Defaults to None, no reindexing. Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked if decode_coords=True.

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool) – If True, fixes erroneous second angle data. Defaults to False.

  • optional (bool) – Import optional mandatory data and metadata, defaults to True.

  • site_as_coords (bool) – Attach radar site-coordinates to Dataset, defaults to True.

  • engine (str) – Engine that will be passed to Xarray.open_dataset, defaults to “netcdf4”

Returns:

dtree (xarray.DataTree) – DataTree with CfRadial2 groups.

xradar.io.open_cfradial2_datatree(filename_or_obj: str | PathLike[str], **kwargs: Any) → DataTree[source]#

Open a CfRadial2-like grouped dataset as xarray.DataTree.

Deprecated since version Use: xd.open_datatree(file, engine="cfradial2") or xr.open_datatree(file, engine="cfradial2") instead.

Parameters:

filename_or_obj (str or PathLike) – Path or object understood by xarray.open_datatree().

Keyword Arguments:
  • sweep (int, str, iterable, optional) – Sweep selection. Defaults to all available sweeps.

  • first_dim (str) – Can be time or auto. Defaults to time.

  • optional (bool) – Keep optional root variables when available. Defaults to True.

  • optional_groups (bool) – Include root metadata subgroups if present. Defaults to False.

  • **kwargs (dict) – Additional keyword arguments passed to xarray.open_datatree().

Returns:

xarray.DataTree – Normalized DataTree containing root metadata and sweep groups.

xradar.io.open_datamet_datatree(filename_or_obj, **kwargs)[source]#

Open DataMet dataset as xarray.DataTree.

Deprecated since version Use: xd.open_datatree(file, engine="datamet") instead.

xradar.io.open_datatree(filename_or_obj, *, engine=None, **kwargs)[source]#

Open a radar file as xarray.DataTree.

The engine is the given engine or, without it, the one found by xradar.io.discover_engine(). This works for all radar formats, including the netCDF/HDF5 based ones (ODIM_H5, GAMIC, CfRadial) which xarray.open_datatree() without engine hands to xarray’s own netCDF/HDF5 backends.

A list of files is stacked into one volume (see xradar.util.create_volume()): this is for formats which write one sweep per file, e.g. IMD or IRIS/Sigmet files of single sweeps. All files need the same engine, the sweeps of all files are sorted by time and numbered in this order. The keyword arguments time_coverage_start, time_coverage_end, min_angle, max_angle and volume_number of xradar.util.create_volume() select and label the sweeps, all other arguments are used for each file.

Parameters:
  • filename_or_obj (str, Path, file-like or list of str or Path) – Path to the radar file, or the paths of files with one sweep each.

  • engine (str, optional) – Backend engine name (e.g., "odim", "cfradial1", "nexradlevel2"). Default is to discover the engine from the file with xradar.io.discover_engine() (raises ValueError if no xradar engine can open it).

  • **kwargs – Keyword arguments for xarray.open_datatree(): xarray options such as chunks or cache, and the backend options documented on the engine’s open_groups_as_dict (sweep, first_dim, …).

Returns:

dtree (xarray.DataTree) – DataTree with CfRadial2 group structure.

Examples

>>> import xradar as xd
>>> dtree = xd.open_datatree("file.h5", engine="odim")
>>> dtree = xd.open_datatree("file.h5")  # engine discovered
>>> volume = xd.open_datatree(["sweep_1.nc", "sweep_2.nc"])  # stacked sweeps
xradar.io.open_furuno_datatree(filename_or_obj, **kwargs)[source]#

Open FURUNO dataset as xarray.DataTree.

Deprecated since version Use: xd.open_datatree(file, engine="furuno") instead.

xradar.io.open_gamic_datatree(filename_or_obj, **kwargs)[source]#

Open GAMIC HDF5 dataset as xarray.DataTree.

Deprecated since version Use: xd.open_datatree(file, engine="gamic") instead.

xradar.io.open_hpl_datatree(filename_or_obj, **kwargs)[source]#

Open Halo Photonics processed Doppler lidar dataset as xarray.DataTree.

Deprecated since version Use: xd.open_datatree(file, engine="hpl") instead.

xradar.io.open_imd_datatree(filename_or_obj, **kwargs)[source]#

Open IMD radar file(s) as a xarray.DataTree.

IMD stores one sweep per NetCDF file. A volume is assembled from multiple files (typically 2-3 for long-range PPI or 9-10 for short-range, high-resolution PPI).

  • Single file path -> single-sweep DataTree.

  • List of file paths -> single volume DataTree. Multi-file stacking is delegated to xradar.util.create_volume(), which sorts sweeps by time and supports time_coverage_start, time_coverage_end, min_angle, max_angle filtering.

Note

When opening a single IMD sweep file as a DataTree, prefer xd.open_datatree(file, engine="imd") (or the xarray-native xr.open_datatree(file, engine="imd")). This function remains the documented API for the multi-file path because IMD volumes span multiple files, which the engine="imd" registry entry does not support.

To split a directory of mixed-volume files into per-volume groups, use group_imd_files() first:

for group in xd.io.group_imd_files("/data/imd"):
    dtree = xd.io.open_imd_datatree(group)
Parameters:

filename_or_obj (str, Path, or list/tuple of those) – Single IMD file path, or a list of paths making up one volume.

Keyword Arguments:
  • first_dim (str) – "auto" (default) or "time".

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range().

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • site_as_coords (bool) – Attach station variables as coordinates on sweep Datasets. site_coords is accepted as an alias.

  • optional_groups (bool) – Include /radar_parameters, /georeferencing_correction and /radar_calibration subgroups. Defaults to False. With multiple files the values the files disagree about are left out of the groups, with a UserWarning.

  • volume_number (time_coverage_start, time_coverage_end, min_angle, max_angle,) – Forwarded to xradar.util.create_volume() when multi-file input is provided.

Returns:

dtree (xarray.DataTree) – CfRadial2-style DataTree with / root and sweep_N children.

xradar.io.open_imd_volumes(paths, **kwargs)[source]#

Open a directory of IMD files as a multi-volume xarray.DataTree.

Groups files by filename stem via group_imd_files(), opens each group as a CfRadial2 volume via open_imd_datatree(), and nests them under zero-padded vcp_NN child nodes of a parent root. vcp stands for volume coverage pattern. Padding width is chosen so the child names sort lexically (e.g. 121 volumes -> vcp_000 .. vcp_120).

Parameters:

paths (str, Path, or iterable of those) – Same as group_imd_files(): directory, glob, or list.

:keyword All kwargs are forwarded to open_imd_datatree() (applied per: :keyword volume). Typical: :kwtype volume). Typical: first_dim, reindex_coord, site_as_coords, :keyword optional_groups, min_angle, max_angle.:

Returns:

dtree (xarray.DataTree) –

Root with vcp_NN children, each a full CfRadial2 volume tree:

/
├── vcp_00/
│   ├── (root: sweep_group_name, sweep_fixed_angle, ...)
│   ├── sweep_0
│   ├── sweep_1
│   └── ...
├── vcp_01/
└── ...

Examples

>>> import xradar as xd
>>> tree = xd.io.open_imd_volumes("/data/JPR220822IMD-B")
>>> tree["vcp_00/sweep_0"].dataset["DBZH"]
xradar.io.open_iris_datatree(filename_or_obj, **kwargs)[source]#

Open Iris/Sigmet dataset as xarray.DataTree.

Deprecated since version Use: xd.open_datatree(file, engine="iris") instead.

xradar.io.open_metek_datatree(filename_or_obj, **kwargs)[source]#

Open Metek MRR2 dataset as xarray.DataTree.

Deprecated since version Use: xd.open_datatree(file, engine="metek") instead.

xradar.io.open_nexradlevel2_datatree(filename_or_obj, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, sweep=None, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_as_coords=True, optional=True, optional_groups=False, incomplete_sweep='drop', lock=None, **kwargs)[source]#

Open a NEXRAD Level2 dataset as xarray.DataTree.

This function loads NEXRAD Level2 radar data into a DataTree structure, which organizes radar sweeps as separate nodes. Provides options for decoding time and applying various transformations to the data.

Parameters:
  • filename_or_obj (str, Path, file-like, bytes, list, or DataStore) – The path or file-like object representing the radar file. Path-like objects are interpreted as local or remote paths. A list or tuple of chunk sources (bytes, file-like, or paths) will be concatenated before reading. When passing chunks, the S file (volume header) must be the first element and I/E chunks must follow in sequence order (.001, .002, …). Out-of-order chunks produce corrupted data or decompression errors.

  • mask_and_scale (bool, optional) – If True, replaces values in the dataset that match _FillValue with NaN and applies scale and offset adjustments. Default is True. The special moment codes below threshold (0) and range folded (1) are both decoded to NaN. Use mask_and_scale=False to get the raw codes, e.g. to keep range folded gates distinguishable.

  • decode_times (bool, optional) – If True, decodes time variables according to CF conventions. Default is True.

  • concat_characters (bool, optional) – If True, concatenates character arrays along the last dimension, forming string arrays. Default is True.

  • decode_coords (bool, optional) – If True, decodes the “coordinates” attribute to identify coordinates in the resulting dataset. Default is True.

  • drop_variables (str or list of str, optional) – Specifies variables to exclude from the dataset. Useful for removing problematic or inconsistent variables. Default is None.

  • use_cftime (bool, optional) – If True, uses cftime objects to represent time variables; if False, uses np.datetime64 objects. If None, chooses the best format automatically. Default is None.

  • decode_timedelta (bool, optional) – If True, decodes variables with units of time (e.g., seconds, minutes) into timedelta objects. If False, leaves them as numeric values. Default is None.

  • sweep (int or list of int, optional) – Sweep numbers to extract from the dataset. If None, extracts all sweeps into a list. Default is the first sweep.

  • first_dim ({"time", "auto"}, optional) – Defines the first dimension for each sweep. If “time,” uses time as the first dimension. If “auto,” determines the first dimension based on the sweep type (azimuth or elevation). Default is “auto.”

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(). Only used if decode_coords=True. Default is None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool, optional) – If True, corrects errors in the second angle data, such as misaligned elevation or azimuth values. Default is False.

  • site_as_coords (bool, optional) – Attaches radar site coordinates to the dataset if True. Default is True.

  • optional (bool, optional) – If True, suppresses errors for optional dataset attributes, making them optional instead of required. Default is True.

  • optional_groups (bool, optional) – If True, includes /radar_parameters, /georeferencing_correction and /radar_calibration metadata subgroups in the DataTree. These groups are often empty or sparsely populated. Default is False.

  • incomplete_sweep ({"drop", "pad"}, optional) – How to handle incomplete sweeps (sweeps that were force-closed because the data ended mid-sweep, e.g. chunk files). "drop" (default) excludes incomplete sweeps and emits a warning. "pad" includes them, reindexing to a full azimuth grid with NaN-filled rays for missing positions.

  • kwargs (dict) – Additional keyword arguments passed to xarray.open_dataset.

Returns:

dtree (xarray.DataTree) – An xarray.DataTree representing the radar data organized by sweeps.

xradar.io.open_odim_datatree(filename_or_obj, **kwargs)[source]#

Open ODIM_H5 dataset as xarray.DataTree.

Deprecated since version Use: xd.open_datatree(file, engine="odim") or xr.open_datatree(file, engine="odim") instead.

Parameters:

filename_or_obj (str, Path, file-like or DataStore) – Strings and Path objects are interpreted as a path to a local or remote radar file

Keyword Arguments:
  • sweep (int, list of int, optional) – Sweep number(s) to extract, default to first sweep. If None, all sweeps are extracted into a list.

  • first_dim (str) – Can be time or auto first dimension. If set to auto, first dimension will be either azimuth or elevation depending on type of sweep. Defaults to auto.

  • reindex_coord (dict, optional) – Defaults to None, no reindexing. Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(), e.g. dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked if decode_coords=True.

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool) – If True, fixes erroneous second angle data. Defaults to False.

  • site_as_coords (bool) – Attach radar site-coordinates to Dataset, defaults to True.

  • kwargs (dict) – Additional kwargs are fed to xarray.open_dataset().

Returns:

dtree (xarray.DataTree) – DataTree

xradar.io.open_rainbow_datatree(filename_or_obj, **kwargs)[source]#

Open Rainbow5 dataset as xarray.DataTree.

Deprecated since version Use: xd.open_datatree(file, engine="rainbow") instead.

xradar.io.open_uf_datatree(filename_or_obj, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, sweep=None, first_dim='auto', reindex_coord=None, reindex_angle=False, fix_second_angle=False, site_as_coords=True, optional=True, optional_groups=False, lock=None, **kwargs)[source]#

Open a Universal Format (UF) dataset as xarray.DataTree.

Deprecated since version Use: xd.open_datatree(file, engine="uf") instead.

This function loads UF radar data into a DataTree structure, which organizes radar sweeps as separate nodes. Provides options for decoding time and applying various transformations to the data.

Parameters:
  • filename_or_obj (str, Path, file-like, or DataStore) – The path or file-like object representing the radar file. Path-like objects are interpreted as local or remote paths.

  • mask_and_scale (bool, optional) – If True, replaces values in the dataset that match _FillValue with NaN and applies scale and offset adjustments. Default is True.

  • decode_times (bool, optional) – If True, decodes time variables according to CF conventions. Default is True.

  • concat_characters (bool, optional) – If True, concatenates character arrays along the last dimension, forming string arrays. Default is True.

  • decode_coords (bool, optional) – If True, decodes the “coordinates” attribute to identify coordinates in the resulting dataset. Default is True.

  • drop_variables (str or list of str, optional) – Specifies variables to exclude from the dataset. Useful for removing problematic or inconsistent variables. Default is None.

  • use_cftime (bool, optional) – If True, uses cftime objects to represent time variables; if False, uses np.datetime64 objects. If None, chooses the best format automatically. Default is None.

  • decode_timedelta (bool, optional) – If True, decodes variables with units of time (e.g., seconds, minutes) into timedelta objects. If False, leaves them as numeric values. Default is None.

  • sweep (int or list of int, optional) – Sweep numbers to extract from the dataset. Default is None, which extracts all sweeps.

  • first_dim ({"time", "auto"}, optional) – Defines the first dimension for each sweep. If “time,” uses time as the first dimension. If “auto,” determines the first dimension based on the sweep type (azimuth or elevation). Default is “auto.”

  • reindex_coord (dict, optional) – Nested dict with optional keys angle and range holding the kwargs for xradar.util.reindex_angle() and xradar.util.reindex_range(). Only used if decode_coords=True. Default is None (no reindexing).

  • reindex_angle (dict, optional) – Deprecated, use reindex_coord=dict(angle=...) instead.

  • fix_second_angle (bool, optional) – If True, corrects errors in the second angle data, such as misaligned elevation or azimuth values. Default is False.

  • site_as_coords (bool, optional) – Attaches radar site coordinates to the dataset if True. Default is True.

  • optional (bool, optional) – If True, suppresses errors for optional dataset attributes, making them optional instead of required. Default is True.

  • optional_groups (bool, optional) – If True, adds the /radar_parameters, /georeferencing_correction and /radar_calibration metadata groups. Default is False.

  • lock (threading.Lock or None, optional) – Lock used when reading the file. Default is None (the UF lock).

  • kwargs (dict) – Additional keyword arguments passed to xarray.open_datatree().

Returns:

dtree (xarray.DataTree) – An xarray.DataTree representing the radar data organized by sweeps.

xradar.io.to_cfradial1(dtree=None, filename=None, calibs=True, range_geometry='common')[source]#

Convert a radar xarray.DataTree to the CfRadial1 format and save it to a file. Ensure that the resulting dataset is well-formed and does not include specified extraneous variables.

Parameters:
  • dtree (xarray.DataTree) – Radar xarray.DataTree object.

  • filename (str, optional) – The name of the output netCDF file. When omitted, a name is derived from the instrument name and first timestamp.

  • calibs (bool, optional) – Whether to include calibration parameters.

  • range_geometry ({"common", "per_sweep"}, optional) – CfRadial1 has one range(range) for all rays. "common" (default) needs the same first gate and gate spacing in all sweeps (the number of gates may differ) and raises an error otherwise. "per_sweep" writes sweeps with different geometries as they are, in a 2-D range(sweep, range) with the attributes meters_to_center_of_first_gate and meters_between_gates per sweep (CfRadial 1.4 Section 2.5). Sweeps with fewer gates continue their grid and have NaN measurements in the remaining gates. If all sweeps share the geometry, the usual 1-D range is written. xradar reads such files, other readers may not (e.g. Py-ART, ARM-DOE/pyart#1900).

xradar.io.to_cfradial2(dtree, filename, engine=None, timestep=None, deepcopy=False)[source]#

Save DataTree to CfRadial2 compliant file.

The input DataTree is never modified. All sweep rewrites and root attribute edits are applied to a copy, which is shallow by default.

Parameters:
  • dtree (xarray.DataTree) – DataTree with CfRadial2 groups.

  • filename (str) – output filename

Keyword Arguments:
  • timestep (int) – timestep of wanted volume, currently not used

  • engine (str) – Either netcdf4 or h5netcdf.

  • deepcopy (bool) – If True, work on a deep copy of dtree (the data is duplicated in memory). If False (default), work on a shallow copy, which shares the underlying data arrays with dtree but not its structure and attributes.

xradar.io.to_odim(dtree, filename, source=None, optional_how=False, compression='gzip', compression_opts=6)[source]#

Save DataTree to ODIM_H5/V2_2 compliant file.

Parameters:
Keyword Arguments:
  • source (str, optional) – Radar identifiers for what/source (see ODIM documentation), at least one of NOD, RAD or WMO. Defaults to the identifiers stored in the global attributes by the ODIM reader (wmo__id, node, site_name, wmo__originating_centre, wmo__wsi).

  • optional_how (boolean) – True to include optional how attributes, defaults to False

  • compression (str) – Compression filter name, defaults to “gzip”.

  • compression_opts (compression strategy) – options as needed by above filter, defaults to 6