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)
Xarray BackendEntrypoint for CfRadial1 data. |
|
Open CfRadial1 dataset as |
- class xradar.io.backends.cfradial1.CfRadial1BackendEntrypoint[source]#
Bases:
BackendEntrypointXarray BackendEntrypoint for CfRadial1 data.
- Keyword Arguments:
first_dim (
str) – Can betimeorautofirst dimension. If set toauto, first dimension will be eitherazimuthorelevationdepending on type of sweep. Defaults toauto.reindex_coord (
dict, optional) – Defaults to None, no reindexing. Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked ifdecode_coords=True.reindex_angle (
dict, optional) – Deprecated, usereindex_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 toTrue.kwargs (
dict) – Additional kwargs are fed toxarray.open_dataset().
- guess_can_open(filename_or_obj)[source]#
CfRadial1 file (netCDF with
sweep_start_ray_indexand aConventionsorversionmentioning 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. Seeopen_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 (
boolordict-like, optional) – Replace fill values with NA and applyscale_factor/add_offsetdecoding. Seexarray.open_dataset(). Defaults toTrue.decode_times (
boolordict-like, optional) – Decode CF time variables (calendar, units) intonp.datetime64. Defaults toTrue.concat_characters (
boolordict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults toTrue.decode_coords (
boolor{"coordinates", "all"}, optional) – Decode the CFcoordinatesattribute. Defaults toTrue(equivalent to"coordinates").drop_variables (
stroriterableofstr, optional) – Names of variables to drop before processing.use_cftime (
bool, optional) – Forcecftimedecoding for time variables (instead ofnp.datetime64). Defaults toNone(auto).decode_timedelta (
bool, optional) – Decode CF timedelta variables. Default mirrorsdecode_timesunless the backend overrides it (cfradial1, cfradial2, and imd default toFalse).sweep (
int,str, orlistofint/str, optional) – Sweep selection.None(default) returns all sweeps. Anintor"sweep_N"string returns one sweep; a list returns the named subset.first_dim (
{"auto", "time"}, optional) – Leading dimension of each sweep dataset."auto"picksazimuth(PPI) orelevation(RHI);"time"keeps the raw time axis. Default"auto"("time"for cfradial2).optional (
bool, optional) – Include optional root variables when available. Defaults toTrue.optional_groups (
bool, optional) – Include the/radar_parameters,/georeferencing_correction, and/radar_calibrationmetadata subgroups under the root. Defaults toFalse.reindex_coord (
dict, optional) – Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked whendecode_coords=True. Defaults toNone(no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.fix_second_angle (
bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective withfirst_dim="auto". Defaults toFalse.site_coords (
bool, optional) – Attachlatitude/longitude/altitudeas coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults toTrue.netcdf_engine (
{"netcdf4", "h5netcdf"}, optional) – Underlying NetCDF engine used byxr.open_datasetto read the CfRadial1 file. Defaults to"netcdf4".
- Returns:
dict[str,xarray.Dataset]– CfRadial2 group paths (/,/sweep_N, optional/radar_parametersetc.) mapped to their datasets, ready forxarray.DataTree.from_dict().
- 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")orxr.open_datatree(file, engine="cfradial1")instead.- Parameters:
filename_or_obj (
str,Path, file-like orxarray.DataStore) – Strings and Path objects are interpreted as a path to a local or remote radar file- Keyword Arguments:
sweep (
int,listofint, optional) – Sweep number(s) to extract, default to first sweep. If None, all sweeps are extracted into a list.first_dim (
str) – Can betimeorautofirst dimension. If set toauto, first dimension will be eitherazimuthorelevationdepending on type of sweep. Defaults toauto.reindex_coord (
dict, optional) – Defaults to None, no reindexing. Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked ifdecode_coords=True.reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.fix_second_angle (
bool) – If True, fixes erroneous second angle data. Defaults toFalse.optional (
bool) – Import optional mandatory data and metadata, defaults toTrue.site_as_coords (
bool) – Attach radar site-coordinates to Dataset, defaults toTrue.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)
Xarray BackendEntrypoint for CfRadial2/FM301 grouped datasets. |
|
Open a CfRadial2-like grouped dataset as |
- class xradar.io.backends.cfradial2.CfRadial2BackendEntrypoint[source]#
Bases:
BackendEntrypointXarray BackendEntrypoint for CfRadial2/FM301 grouped datasets.
- Keyword Arguments:
sweep (
int,str,iterable, optional) – Sweep selection. Defaults to all available sweeps.first_dim (
str) – Can betimeorauto. Defaults totime.optional (
bool) – Keep optional root variables when available. Defaults toTrue.optional_groups (
bool) – Include root metadata subgroups if present. Defaults toFalse.kwargs (
dict) – Additional kwargs are fed toxarray.open_datatree().
- guess_can_open(filename_or_obj)[source]#
CfRadial2 file (netCDF/HDF5 with sweep groups, whose
Conventionsmention CF/Radial and whose root hassweep_group_nameandtime_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. Seeopen_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 (
boolordict-like, optional) – Replace fill values with NA and applyscale_factor/add_offsetdecoding. Seexarray.open_dataset(). Defaults toTrue.decode_times (
boolordict-like, optional) – Decode CF time variables (calendar, units) intonp.datetime64. Defaults toTrue.concat_characters (
boolordict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults toTrue.decode_coords (
boolor{"coordinates", "all"}, optional) – Decode the CFcoordinatesattribute. Defaults toTrue(equivalent to"coordinates").drop_variables (
stroriterableofstr, optional) – Names of variables to drop before processing.use_cftime (
bool, optional) – Forcecftimedecoding for time variables (instead ofnp.datetime64). Defaults toNone(auto).decode_timedelta (
bool, optional) – Decode CF timedelta variables. Default mirrorsdecode_timesunless the backend overrides it (cfradial1, cfradial2, and imd default toFalse).sweep (
int,str, orlistofint/str, optional) – Sweep selection.None(default) returns all sweeps. Anintor"sweep_N"string returns one sweep; a list returns the named subset.first_dim (
{"auto", "time"}, optional) – Leading dimension of each sweep dataset."auto"picksazimuth(PPI) orelevation(RHI);"time"keeps the raw time axis. Default"auto"("time"for cfradial2).optional (
bool, optional) – Include optional root variables when available. Defaults toTrue.optional_groups (
bool, optional) – Include the/radar_parameters,/georeferencing_correction, and/radar_calibrationmetadata subgroups under the root. Defaults toFalse.site_coords (
bool, optional) – Keeplatitude/longitude/altitudeas coordinates on the root dataset. CfRadial2 stores station coords at root by default; passFalseto drop them. Defaults toTrue.netcdf_engine (
str, optional) – netCDF engine used to read the file (e.g."netcdf4"or"h5netcdf"). Defaults toNone(xarray’s choice).
- Returns:
dict[str,xarray.Dataset]– CfRadial2 group paths (/,/sweep_N, optional/radar_parametersetc.) mapped to their datasets, ready forxarray.DataTree.from_dict().
- 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")orxr.open_datatree(file, engine="cfradial2")instead.- Parameters:
filename_or_obj (
strorPathLike) – Path or object understood byxarray.open_datatree().- Keyword Arguments:
sweep (
int,str,iterable, optional) – Sweep selection. Defaults to all available sweeps.first_dim (
str) – Can betimeorauto. Defaults totime.optional (
bool) – Keep optional root variables when available. Defaults toTrue.optional_groups (
bool) – Include root metadata subgroups if present. Defaults toFalse.**kwargs (
dict) – Additional keyword arguments passed toxarray.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)
Xarray BackendEntrypoint for GAMIC data. |
|
Open GAMIC HDF5 dataset as |
- class xradar.io.backends.gamic.GamicBackendEntrypoint[source]#
Bases:
BackendEntrypointXarray BackendEntrypoint for GAMIC data.
- Keyword Arguments:
first_dim (
str) – Can betimeorautofirst dimension. If set toauto, first dimension will be eitherazimuthorelevationdepending on type of sweep. Defaults toauto.reindex_coord (
dict, optional) – Defaults to None, no reindexing. Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked ifdecode_coords=True.reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.fix_second_angle (
bool) – For PPI only. If True, fixes erroneous second angle data. Defaults toFalse.site_as_coords (
bool) – Attach radar site-coordinates to Dataset, defaults toTrue.kwargs (
dict) – Additional kwargs are fed toxarray.open_dataset().
- 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. Seeopen_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 (
boolordict-like, optional) – Replace fill values with NA and applyscale_factor/add_offsetdecoding. Seexarray.open_dataset(). Defaults toTrue.decode_times (
boolordict-like, optional) – Decode CF time variables (calendar, units) intonp.datetime64. Defaults toTrue.concat_characters (
boolordict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults toTrue.decode_coords (
boolor{"coordinates", "all"}, optional) – Decode the CFcoordinatesattribute. Defaults toTrue(equivalent to"coordinates").drop_variables (
stroriterableofstr, optional) – Names of variables to drop before processing.use_cftime (
bool, optional) – Forcecftimedecoding for time variables (instead ofnp.datetime64). Defaults toNone(auto).decode_timedelta (
bool, optional) – Decode CF timedelta variables. Default mirrorsdecode_timesunless the backend overrides it (cfradial1, cfradial2, and imd default toFalse).sweep (
int,str, orlistofint/str, optional) – Sweep selection.None(default) returns all sweeps. Anintor"sweep_N"string returns one sweep; a list returns the named subset.first_dim (
{"auto", "time"}, optional) – Leading dimension of each sweep dataset."auto"picksazimuth(PPI) orelevation(RHI);"time"keeps the raw time axis. Default"auto"("time"for cfradial2).optional (
bool, optional) – Include optional root variables when available. Defaults toTrue.optional_groups (
bool, optional) – Include the/radar_parameters,/georeferencing_correction, and/radar_calibrationmetadata subgroups under the root. Defaults toFalse.format (
str, optional) – h5netcdf format string. Defaults toNone.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 toTrue.reindex_coord (
dict, optional) – Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked whendecode_coords=True. Defaults toNone(no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.fix_second_angle (
bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective withfirst_dim="auto". Defaults toFalse.site_coords (
bool, optional) – Attachlatitude/longitude/altitudeas coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults toTrue.
- Returns:
dict[str,xarray.Dataset]– CfRadial2 group paths (/,/sweep_N, optional/radar_parametersetc.) mapped to their datasets, ready forxarray.DataTree.from_dict().
- 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)
Xarray BackendEntrypoint for ODIM data. |
|
Open ODIM_H5 dataset as |
- class xradar.io.backends.odim.OdimBackendEntrypoint[source]#
Bases:
BackendEntrypointXarray BackendEntrypoint for ODIM data.
- Keyword Arguments:
first_dim (
str) – Can betimeorautofirst dimension. If set toauto, first dimension will be eitherazimuthorelevationdepending on type of sweep. Defaults toauto.reindex_coord (
dict, optional) – Defaults to None, no reindexing. Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked ifdecode_coords=True.reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.fix_second_angle (
bool) – If True, fixes erroneous second angle data. Defaults toFalse.site_as_coords (
bool) – Attach radar site-coordinates to Dataset, defaults toTrue.kwargs (
dict) – Additional kwargs are fed toxarray.open_dataset().
- 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, soclose()releases it. Seeopen_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 (
boolordict-like, optional) – Replace fill values with NA and applyscale_factor/add_offsetdecoding. Seexarray.open_dataset(). Defaults toTrue.decode_times (
boolordict-like, optional) – Decode CF time variables (calendar, units) intonp.datetime64. Defaults toTrue.concat_characters (
boolordict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults toTrue.decode_coords (
boolor{"coordinates", "all"}, optional) – Decode the CFcoordinatesattribute. Defaults toTrue(equivalent to"coordinates").drop_variables (
stroriterableofstr, optional) – Names of variables to drop before processing.use_cftime (
bool, optional) – Forcecftimedecoding for time variables (instead ofnp.datetime64). Defaults toNone(auto).decode_timedelta (
bool, optional) – Decode CF timedelta variables. Default mirrorsdecode_timesunless the backend overrides it (cfradial1, cfradial2, and imd default toFalse).sweep (
int,str, orlistofint/str, optional) – Sweep selection.None(default) returns all sweeps. Anintor"sweep_N"string returns one sweep; a list returns the named subset.first_dim (
{"auto", "time"}, optional) – Leading dimension of each sweep dataset."auto"picksazimuth(PPI) orelevation(RHI);"time"keeps the raw time axis. Default"auto"("time"for cfradial2).optional (
bool, optional) – Include optional root variables when available. Defaults toTrue.optional_groups (
bool, optional) – Include the/radar_parameters,/georeferencing_correction, and/radar_calibrationmetadata subgroups under the root. Defaults toFalse.format (
str, optional) – h5netcdf format string. Defaults toNone.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 toTrue.reindex_coord (
dict, optional) – Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked whendecode_coords=True. Defaults toNone(no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.fix_second_angle (
bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective withfirst_dim="auto". Defaults toFalse.site_coords (
bool, optional) – Attachlatitude/longitude/altitudeas coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults toTrue.
- Returns:
dict[str,xarray.Dataset]– CfRadial2 group paths (/,/sweep_N, optional/radar_parametersetc.) mapped to their datasets, ready forxarray.DataTree.from_dict().
- 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")orxr.open_datatree(file, engine="odim")instead.- Parameters:
filename_or_obj (
str,Path, file-like orDataStore) – Strings and Path objects are interpreted as a path to a local or remote radar file- Keyword Arguments:
sweep (
int,listofint, optional) – Sweep number(s) to extract, default to first sweep. If None, all sweeps are extracted into a list.first_dim (
str) – Can betimeorautofirst dimension. If set toauto, first dimension will be eitherazimuthorelevationdepending on type of sweep. Defaults toauto.reindex_coord (
dict, optional) – Defaults to None, no reindexing. Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked ifdecode_coords=True.reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.fix_second_angle (
bool) – If True, fixes erroneous second angle data. Defaults toFalse.site_as_coords (
bool) – Attach radar site-coordinates to Dataset, defaults toTrue.kwargs (
dict) – Additional kwargs are fed toxarray.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)
Xarray BackendEntrypoint for Furuno data. |
|
Open FURUNO dataset as |
- class xradar.io.backends.furuno.FurunoBackendEntrypoint[source]#
Bases:
BackendEntrypointXarray BackendEntrypoint for Furuno data.
- 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. Seeopen_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 (
boolordict-like, optional) – Replace fill values with NA and applyscale_factor/add_offsetdecoding. Seexarray.open_dataset(). Defaults toTrue.decode_times (
boolordict-like, optional) – Decode CF time variables (calendar, units) intonp.datetime64. Defaults toTrue.concat_characters (
boolordict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults toTrue.decode_coords (
boolor{"coordinates", "all"}, optional) – Decode the CFcoordinatesattribute. Defaults toTrue(equivalent to"coordinates").drop_variables (
stroriterableofstr, optional) – Names of variables to drop before processing.use_cftime (
bool, optional) – Forcecftimedecoding for time variables (instead ofnp.datetime64). Defaults toNone(auto).decode_timedelta (
bool, optional) – Decode CF timedelta variables. Default mirrorsdecode_timesunless the backend overrides it (cfradial1, cfradial2, and imd default toFalse).sweep (
int,str, orlistofint/str, optional) – Sweep selection.None(default) returns all sweeps. Anintor"sweep_N"string returns one sweep; a list returns the named subset.first_dim (
{"auto", "time"}, optional) – Leading dimension of each sweep dataset."auto"picksazimuth(PPI) orelevation(RHI);"time"keeps the raw time axis. Default"auto"("time"for cfradial2).optional (
bool, optional) – Include optional root variables when available. Defaults toTrue.optional_groups (
bool, optional) – Include the/radar_parameters,/georeferencing_correction, and/radar_calibrationmetadata subgroups under the root. Defaults toFalse.reindex_coord (
dict, optional) – Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked whendecode_coords=True. Defaults toNone(no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.fix_second_angle (
bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective withfirst_dim="auto". Defaults toFalse.site_coords (
bool, optional) – Attachlatitude/longitude/altitudeas coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults toTrue.obsmode (
intorNone, optional) – Override the file’s observation-mode flag (rare; only needed for files written by older firmware). Defaults toNone.
- Returns:
dict[str,xarray.Dataset]– CfRadial2 group paths (/,/sweep_N, optional/radar_parametersetc.) mapped to their datasets, ready forxarray.DataTree.from_dict().
- 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)
Xarray BackendEntrypoint for Rainbow5 data. |
|
Open Rainbow5 dataset as |
- class xradar.io.backends.rainbow.RainbowBackendEntrypoint[source]#
Bases:
BackendEntrypointXarray BackendEntrypoint for Rainbow5 data.
- 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. Seeopen_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 (
boolordict-like, optional) – Replace fill values with NA and applyscale_factor/add_offsetdecoding. Seexarray.open_dataset(). Defaults toTrue.decode_times (
boolordict-like, optional) – Decode CF time variables (calendar, units) intonp.datetime64. Defaults toTrue.concat_characters (
boolordict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults toTrue.decode_coords (
boolor{"coordinates", "all"}, optional) – Decode the CFcoordinatesattribute. Defaults toTrue(equivalent to"coordinates").drop_variables (
stroriterableofstr, optional) – Names of variables to drop before processing.use_cftime (
bool, optional) – Forcecftimedecoding for time variables (instead ofnp.datetime64). Defaults toNone(auto).decode_timedelta (
bool, optional) – Decode CF timedelta variables. Default mirrorsdecode_timesunless the backend overrides it (cfradial1, cfradial2, and imd default toFalse).sweep (
int,str, orlistofint/str, optional) – Sweep selection.None(default) returns all sweeps. Anintor"sweep_N"string returns one sweep; a list returns the named subset.first_dim (
{"auto", "time"}, optional) – Leading dimension of each sweep dataset."auto"picksazimuth(PPI) orelevation(RHI);"time"keeps the raw time axis. Default"auto"("time"for cfradial2).optional (
bool, optional) – Include optional root variables when available. Defaults toTrue.optional_groups (
bool, optional) – Include the/radar_parameters,/georeferencing_correction, and/radar_calibrationmetadata subgroups under the root. Defaults toFalse.reindex_coord (
dict, optional) – Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked whendecode_coords=True. Defaults toNone(no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.site_coords (
bool, optional) – Attachlatitude/longitude/altitudeas coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults toTrue.
- Returns:
dict[str,xarray.Dataset]– CfRadial2 group paths (/,/sweep_N, optional/radar_parametersetc.) mapped to their datasets, ready forxarray.DataTree.from_dict().
- 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.
Xarray BackendEntrypoint for IRIS/Sigmet data. |
|
Open Iris/Sigmet dataset as |
- class xradar.io.backends.iris.IrisBackendEntrypoint[source]#
Bases:
BackendEntrypointXarray BackendEntrypoint for IRIS/Sigmet data.
- 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. Seeopen_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 (
boolordict-like, optional) – Replace fill values with NA and applyscale_factor/add_offsetdecoding. Seexarray.open_dataset(). Defaults toTrue.decode_times (
boolordict-like, optional) – Decode CF time variables (calendar, units) intonp.datetime64. Defaults toTrue.concat_characters (
boolordict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults toTrue.decode_coords (
boolor{"coordinates", "all"}, optional) – Decode the CFcoordinatesattribute. Defaults toTrue(equivalent to"coordinates").drop_variables (
stroriterableofstr, optional) – Names of variables to drop before processing.use_cftime (
bool, optional) – Forcecftimedecoding for time variables (instead ofnp.datetime64). Defaults toNone(auto).decode_timedelta (
bool, optional) – Decode CF timedelta variables. Default mirrorsdecode_timesunless the backend overrides it (cfradial1, cfradial2, and imd default toFalse).sweep (
int,str, orlistofint/str, optional) – Sweep selection.None(default) returns all sweeps. Anintor"sweep_N"string returns one sweep; a list returns the named subset.first_dim (
{"auto", "time"}, optional) – Leading dimension of each sweep dataset."auto"picksazimuth(PPI) orelevation(RHI);"time"keeps the raw time axis. Default"auto"("time"for cfradial2).optional (
bool, optional) – Include optional root variables when available. Defaults toTrue.optional_groups (
bool, optional) – Include the/radar_parameters,/georeferencing_correction, and/radar_calibrationmetadata subgroups under the root. Defaults toFalse.reindex_coord (
dict, optional) – Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked whendecode_coords=True. Defaults toNone(no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.fix_second_angle (
bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective withfirst_dim="auto". Defaults toFalse.site_coords (
bool, optional) – Attachlatitude/longitude/altitudeas coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults toTrue.lock (
threading.LockorNone, optional) – Reader lock for thread-safe access. Defaults toNone.
- Returns:
dict[str,xarray.Dataset]– CfRadial2 group paths (/,/sweep_N, optional/radar_parametersetc.) mapped to their datasets, ready forxarray.DataTree.from_dict().
- 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.
Xarray BackendEntrypoint for Halo Photonics Doppler processed lidar data. |
|
Open Halo Photonics processed Doppler lidar dataset as |
- class xradar.io.backends.hpl.HPLBackendEntrypoint[source]#
Bases:
BackendEntrypointXarray BackendEntrypoint for Halo Photonics Doppler processed lidar data.
- Keyword Arguments:
first_dim (
str) – Can betimeorautofirst dimension. If set toauto, first dimension will be eitherazimuthorelevationdepending on type of sweep. Defaults toauto.site_as_coords (
bool) – Attach radar site-coordinates to Dataset, defaults toTrue.kwargs (
dict) – Additional kwargs are fed toxarray.open_dataset().
- 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. Seeopen_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 (
boolordict-like, optional) – Replace fill values with NA and applyscale_factor/add_offsetdecoding. Seexarray.open_dataset(). Defaults toTrue.decode_times (
boolordict-like, optional) – Decode CF time variables (calendar, units) intonp.datetime64. Defaults toTrue.concat_characters (
boolordict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults toTrue.decode_coords (
boolor{"coordinates", "all"}, optional) – Decode the CFcoordinatesattribute. Defaults toTrue(equivalent to"coordinates").drop_variables (
stroriterableofstr, optional) – Names of variables to drop before processing.use_cftime (
bool, optional) – Forcecftimedecoding for time variables (instead ofnp.datetime64). Defaults toNone(auto).decode_timedelta (
bool, optional) – Decode CF timedelta variables. Default mirrorsdecode_timesunless the backend overrides it (cfradial1, cfradial2, and imd default toFalse).sweep (
int,str, orlistofint/str, optional) – Sweep selection.None(default) returns all sweeps. Anintor"sweep_N"string returns one sweep; a list returns the named subset.first_dim (
{"auto", "time"}, optional) – Leading dimension of each sweep dataset."auto"picksazimuth(PPI) orelevation(RHI);"time"keeps the raw time axis. Default"auto"("time"for cfradial2).optional (
bool, optional) – Include optional root variables when available. Defaults toTrue.optional_groups (
bool, optional) – Include the/radar_parameters,/georeferencing_correction, and/radar_calibrationmetadata subgroups under the root. Defaults toFalse.format (
str, optional) – h5netcdf format string. Defaults toNone.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 toTrue.reindex_coord (
dict, optional) – Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked whendecode_coords=True. Defaults toNone(no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.site_coords (
bool, optional) – Attachlatitude/longitude/altitudeas coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults toTrue.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_parametersetc.) mapped to their datasets, ready forxarray.DataTree.from_dict().
- 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.
Xarray BackendEntrypoint for NEXRAD Level2 Data |
|
Open a NEXRAD Level2 dataset as |
- class xradar.io.backends.nexrad_level2.NexradLevel2BackendEntrypoint[source]#
Bases:
BackendEntrypointXarray BackendEntrypoint for NEXRAD Level2 Data
- 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. Seeopen_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 (
boolordict-like, optional) – Replace fill values with NA and applyscale_factor/add_offsetdecoding. Seexarray.open_dataset(). Defaults toTrue.decode_times (
boolordict-like, optional) – Decode CF time variables (calendar, units) intonp.datetime64. Defaults toTrue.concat_characters (
boolordict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults toTrue.decode_coords (
boolor{"coordinates", "all"}, optional) – Decode the CFcoordinatesattribute. Defaults toTrue(equivalent to"coordinates").drop_variables (
stroriterableofstr, optional) – Names of variables to drop before processing.use_cftime (
bool, optional) – Forcecftimedecoding for time variables (instead ofnp.datetime64). Defaults toNone(auto).decode_timedelta (
bool, optional) – Decode CF timedelta variables. Default mirrorsdecode_timesunless the backend overrides it (cfradial1, cfradial2, and imd default toFalse).sweep (
int,str, orlistofint/str, optional) – Sweep selection.None(default) returns all sweeps. Anintor"sweep_N"string returns one sweep; a list returns the named subset.first_dim (
{"auto", "time"}, optional) – Leading dimension of each sweep dataset."auto"picksazimuth(PPI) orelevation(RHI);"time"keeps the raw time axis. Default"auto"("time"for cfradial2).optional (
bool, optional) – Include optional root variables when available. Defaults toTrue.optional_groups (
bool, optional) – Include the/radar_parameters,/georeferencing_correction, and/radar_calibrationmetadata subgroups under the root. Defaults toFalse.reindex_coord (
dict, optional) – Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked whendecode_coords=True. Defaults toNone(no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.fix_second_angle (
bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective withfirst_dim="auto". Defaults toFalse.site_coords (
bool, optional) – Attachlatitude/longitude/altitudeas coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults toTrue.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.LockorNone, optional) – Reader lock for thread-safe access. Defaults toNone.
- Returns:
dict[str,xarray.Dataset]– CfRadial2 group paths (/,/sweep_N, optional/radar_parametersetc.) mapped to their datasets, ready forxarray.DataTree.from_dict().
- 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, orDataStore) – 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. Usemask_and_scale=Falseto 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 (
strorlistofstr, 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 (
intorlistofint, 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 keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(). Only used if decode_coords=True. Default is None (no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_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_correctionand/radar_calibrationmetadata 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.
Xarray BackendEntrypoint for DataMet data. |
|
Open DataMet dataset as |
- class xradar.io.backends.datamet.DataMetBackendEntrypoint[source]#
Bases:
BackendEntrypointXarray BackendEntrypoint for DataMet data.
- 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. Seeopen_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.gzarchive 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 (
boolordict-like, optional) – Replace fill values with NA and applyscale_factor/add_offsetdecoding. Seexarray.open_dataset(). Defaults toTrue.decode_times (
boolordict-like, optional) – Decode CF time variables (calendar, units) intonp.datetime64. Defaults toTrue.concat_characters (
boolordict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults toTrue.decode_coords (
boolor{"coordinates", "all"}, optional) – Decode the CFcoordinatesattribute. Defaults toTrue(equivalent to"coordinates").drop_variables (
stroriterableofstr, optional) – Names of variables to drop before processing.use_cftime (
bool, optional) – Forcecftimedecoding for time variables (instead ofnp.datetime64). Defaults toNone(auto).decode_timedelta (
bool, optional) – Decode CF timedelta variables. Default mirrorsdecode_timesunless the backend overrides it (cfradial1, cfradial2, and imd default toFalse).sweep (
int,str, orlistofint/str, optional) – Sweep selection.None(default) returns all sweeps. Anintor"sweep_N"string returns one sweep; a list returns the named subset.first_dim (
{"auto", "time"}, optional) – Leading dimension of each sweep dataset."auto"picksazimuth(PPI) orelevation(RHI);"time"keeps the raw time axis. Default"auto"("time"for cfradial2).optional (
bool, optional) – Include optional root variables when available. Defaults toTrue.optional_groups (
bool, optional) – Include the/radar_parameters,/georeferencing_correction, and/radar_calibrationmetadata subgroups under the root. Defaults toFalse.reindex_coord (
dict, optional) – Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked whendecode_coords=True. Defaults toNone(no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.site_coords (
bool, optional) – Attachlatitude/longitude/altitudeas coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults toTrue.
- Returns:
dict[str,xarray.Dataset]– CfRadial2 group paths (/,/sweep_N, optional/radar_parametersetc.) mapped to their datasets, ready forxarray.DataTree.from_dict().
- 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')
Xarray BackendEntrypoint for Metek MRR2 data. |
|
Open Metek MRR2 dataset as |
- class xradar.io.backends.metek.MRRBackendEntrypoint[source]#
Bases:
BackendEntrypointXarray BackendEntrypoint for Metek MRR2 data.
- Keyword Arguments:
first_dim (
str) – Can betimeorautofirst dimension. If set toauto, first dimension will be eitherazimuthorelevationdepending on type of sweep. Defaults toauto.site_as_coords (
bool) – Attach radar site-coordinates to Dataset, defaults toTrue.kwargs (
dict) – Additional kwargs are fed toxarray.open_dataset().
- 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. Seeopen_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_0group 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 (
boolordict-like, optional) – Replace fill values with NA and applyscale_factor/add_offsetdecoding. Seexarray.open_dataset(). Defaults toTrue.decode_times (
boolordict-like, optional) – Decode CF time variables (calendar, units) intonp.datetime64. Defaults toTrue.concat_characters (
boolordict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults toTrue.decode_coords (
boolor{"coordinates", "all"}, optional) – Decode the CFcoordinatesattribute. Defaults toTrue(equivalent to"coordinates").drop_variables (
stroriterableofstr, optional) – Names of variables to drop before processing.use_cftime (
bool, optional) – Forcecftimedecoding for time variables (instead ofnp.datetime64). Defaults toNone(auto).decode_timedelta (
bool, optional) – Decode CF timedelta variables. Default mirrorsdecode_timesunless the backend overrides it (cfradial1, cfradial2, and imd default toFalse).sweep (
int,str, orlistofint/str, optional) – Sweep selection.None(default) returns all sweeps. Anintor"sweep_N"string returns one sweep; a list returns the named subset.first_dim (
{"auto", "time"}, optional) – Leading dimension of each sweep dataset."auto"picksazimuth(PPI) orelevation(RHI);"time"keeps the raw time axis. Default"auto"("time"for cfradial2).optional (
bool, optional) – Include optional root variables when available. Defaults toTrue.optional_groups (
bool, optional) – Include the/radar_parameters,/georeferencing_correction, and/radar_calibrationmetadata subgroups under the root. Defaults toFalse.format (
str, optional) – h5netcdf format string. Defaults toNone.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 toTrue.site_coords (
bool, optional) – Attachlatitude/longitude/altitudeas coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults toTrue.
- Returns:
dict[str,xarray.Dataset]– CfRadial2 group paths (/,/sweep_N, optional/radar_parametersetc.) mapped to their datasets, ready forxarray.DataTree.from_dict().
- 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
Xarray BackendEntrypoint for Universal Format (UF) data. |
|
Open a Universal Format (UF) dataset as |
- class xradar.io.backends.uf.UFBackendEntrypoint[source]#
Bases:
BackendEntrypointXarray BackendEntrypoint for Universal Format (UF) data.
- 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. Seeopen_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 (
boolordict-like, optional) – Replace fill values with NA and applyscale_factor/add_offsetdecoding. Seexarray.open_dataset(). Defaults toTrue.decode_times (
boolordict-like, optional) – Decode CF time variables (calendar, units) intonp.datetime64. Defaults toTrue.concat_characters (
boolordict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults toTrue.decode_coords (
boolor{"coordinates", "all"}, optional) – Decode the CFcoordinatesattribute. Defaults toTrue(equivalent to"coordinates").drop_variables (
stroriterableofstr, optional) – Names of variables to drop before processing.use_cftime (
bool, optional) – Forcecftimedecoding for time variables (instead ofnp.datetime64). Defaults toNone(auto).decode_timedelta (
bool, optional) – Decode CF timedelta variables. Default mirrorsdecode_timesunless the backend overrides it (cfradial1, cfradial2, and imd default toFalse).sweep (
int,str, orlistofint/str, optional) – Sweep selection.None(default) returns all sweeps. Anintor"sweep_N"string returns one sweep; a list returns the named subset.first_dim (
{"auto", "time"}, optional) – Leading dimension of each sweep dataset."auto"picksazimuth(PPI) orelevation(RHI);"time"keeps the raw time axis. Default"auto"("time"for cfradial2).optional (
bool, optional) – Include optional root variables when available. Defaults toTrue.optional_groups (
bool, optional) – Include the/radar_parameters,/georeferencing_correction, and/radar_calibrationmetadata subgroups under the root. Defaults toFalse.reindex_coord (
dict, optional) – Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked whendecode_coords=True. Defaults toNone(no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.fix_second_angle (
bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective withfirst_dim="auto". Defaults toFalse.site_coords (
bool, optional) – Attachlatitude/longitude/altitudeas coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults toTrue.lock (
threading.LockorNone, optional) – Reader lock for thread-safe access. Defaults toNone.
- Returns:
dict[str,xarray.Dataset]– CfRadial2 group paths (/,/sweep_N, optional/radar_parametersetc.) mapped to their datasets, ready forxarray.DataTree.from_dict().
- 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, orDataStore) – 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 (
strorlistofstr, 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 (
intorlistofint, 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 keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(). Only used if decode_coords=True. Default is None (no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_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_correctionand/radar_calibrationmetadata groups. Default is False.lock (
threading.LockorNone, optional) – Lock used when reading the file. Default is None (the UF lock).kwargs (
dict) – Additional keyword arguments passed toxarray.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", ...])
Xarray BackendEntrypoint for India Meteorological Department (IMD) radar files. |
|
Open IMD radar file(s) as a |
|
Open a directory of IMD files as a multi-volume |
|
Group IMD sweep files into volumes by filename stem. |
- class xradar.io.backends.imd.IMDBackendEntrypoint[source]#
Bases:
BackendEntrypointXarray 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 sweepxarray.Dataset. To assemble a multi-sweep volume, useopen_imd_datatree()with a list of files.- Keyword Arguments:
first_dim (
str) – Can betimeorauto(default).autoselectsazimuth(PPI) orelevation(RHI) as the first dimension.reindex_coord (
dict, optional) – Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(). Defaults toNone(no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.site_as_coords (
bool) – If True (default), promotelatitude/longitude/altitudeto Dataset coordinates.
- description: ClassVar[str] = 'Open India Meteorological Department (IMD) radar NetCDF files in Xarray'#
- 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. Seeopen_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 (
boolordict-like, optional) – Replace fill values with NA and applyscale_factor/add_offsetdecoding. Seexarray.open_dataset(). Defaults toTrue.decode_times (
boolordict-like, optional) – Decode CF time variables (calendar, units) intonp.datetime64. Defaults toTrue.concat_characters (
boolordict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults toTrue.decode_coords (
boolor{"coordinates", "all"}, optional) – Decode the CFcoordinatesattribute. Defaults toTrue(equivalent to"coordinates").drop_variables (
stroriterableofstr, optional) – Names of variables to drop before processing.use_cftime (
bool, optional) – Forcecftimedecoding for time variables (instead ofnp.datetime64). Defaults toNone(auto).decode_timedelta (
bool, optional) – Decode CF timedelta variables. Default mirrorsdecode_timesunless the backend overrides it (cfradial1, cfradial2, and imd default toFalse).sweep (
int,str, orlistofint/str, optional) – Sweep selection.None(default) returns all sweeps. Anintor"sweep_N"string returns one sweep; a list returns the named subset.first_dim (
{"auto", "time"}, optional) – Leading dimension of each sweep dataset."auto"picksazimuth(PPI) orelevation(RHI);"time"keeps the raw time axis. Default"auto"("time"for cfradial2).optional_groups (
bool, optional) – Include the/radar_parameters,/georeferencing_correction, and/radar_calibrationmetadata subgroups under the root. Defaults toFalse.sweep (
int,strorlist, optional) – IMD files hold one sweep, so onlyNone,0or"sweep_0"are accepted. Defaults toNone.reindex_coord (
dict, optional) – Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked whendecode_coords=True. Defaults toNone(no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.site_coords (
bool, optional) – Attachlatitude/longitude/altitudeas coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults toTrue.
- Returns:
dict[str,xarray.Dataset]– CfRadial2 group paths (/,/sweep_N, optional/radar_parametersetc.) mapped to their datasets, ready forxarray.DataTree.from_dict().
- 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, oriterableofthose) –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 supportstime_coverage_start,time_coverage_end,min_angle,max_anglefiltering.
Note
When opening a single IMD sweep file as a DataTree, prefer
xd.open_datatree(file, engine="imd")(or the xarray-nativexr.open_datatree(file, engine="imd")). This function remains the documented API for the multi-file path because IMD volumes span multiple files, which theengine="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, orlist/tupleofthose) – 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 keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range().reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.site_as_coords (
bool) – Attach station variables as coordinates on sweep Datasets.site_coordsis accepted as an alias.optional_groups (
bool) – Include/radar_parameters,/georeferencing_correctionand/radar_calibrationsubgroups. Defaults toFalse. With multiple files the values the files disagree about are left out of the groups, with aUserWarning.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 andsweep_Nchildren.
- 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 viaopen_imd_datatree(), and nests them under zero-paddedvcp_NNchild nodes of a parent root.vcpstands 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, oriterableofthose) – Same asgroup_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, :keywordoptional_groups,min_angle,max_angle.:- Returns:
dtree (
xarray.DataTree) –Root with
vcp_NNchildren, 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.
Find the xradar engine which can open the given file. |
|
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.AR2Vfor NEXRAD Level II,ODIM_H5conventions in HDF5 files), seelist_xradar_engines().- Parameters:
filename_or_obj (
str,os.PathLike,bytesor 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")
- class xradar.io.backends.CfRadial1BackendEntrypoint[source]#
Bases:
BackendEntrypointXarray BackendEntrypoint for CfRadial1 data.
- Keyword Arguments:
first_dim (
str) – Can betimeorautofirst dimension. If set toauto, first dimension will be eitherazimuthorelevationdepending on type of sweep. Defaults toauto.reindex_coord (
dict, optional) – Defaults to None, no reindexing. Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked ifdecode_coords=True.reindex_angle (
dict, optional) – Deprecated, usereindex_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 toTrue.kwargs (
dict) – Additional kwargs are fed toxarray.open_dataset().
- guess_can_open(filename_or_obj)[source]#
CfRadial1 file (netCDF with
sweep_start_ray_indexand aConventionsorversionmentioning 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. Seeopen_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 (
boolordict-like, optional) – Replace fill values with NA and applyscale_factor/add_offsetdecoding. Seexarray.open_dataset(). Defaults toTrue.decode_times (
boolordict-like, optional) – Decode CF time variables (calendar, units) intonp.datetime64. Defaults toTrue.concat_characters (
boolordict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults toTrue.decode_coords (
boolor{"coordinates", "all"}, optional) – Decode the CFcoordinatesattribute. Defaults toTrue(equivalent to"coordinates").drop_variables (
stroriterableofstr, optional) – Names of variables to drop before processing.use_cftime (
bool, optional) – Forcecftimedecoding for time variables (instead ofnp.datetime64). Defaults toNone(auto).decode_timedelta (
bool, optional) – Decode CF timedelta variables. Default mirrorsdecode_timesunless the backend overrides it (cfradial1, cfradial2, and imd default toFalse).sweep (
int,str, orlistofint/str, optional) – Sweep selection.None(default) returns all sweeps. Anintor"sweep_N"string returns one sweep; a list returns the named subset.first_dim (
{"auto", "time"}, optional) – Leading dimension of each sweep dataset."auto"picksazimuth(PPI) orelevation(RHI);"time"keeps the raw time axis. Default"auto"("time"for cfradial2).optional (
bool, optional) – Include optional root variables when available. Defaults toTrue.optional_groups (
bool, optional) – Include the/radar_parameters,/georeferencing_correction, and/radar_calibrationmetadata subgroups under the root. Defaults toFalse.reindex_coord (
dict, optional) – Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked whendecode_coords=True. Defaults toNone(no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.fix_second_angle (
bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective withfirst_dim="auto". Defaults toFalse.site_coords (
bool, optional) – Attachlatitude/longitude/altitudeas coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults toTrue.netcdf_engine (
{"netcdf4", "h5netcdf"}, optional) – Underlying NetCDF engine used byxr.open_datasetto read the CfRadial1 file. Defaults to"netcdf4".
- Returns:
dict[str,xarray.Dataset]– CfRadial2 group paths (/,/sweep_N, optional/radar_parametersetc.) mapped to their datasets, ready forxarray.DataTree.from_dict().
- class xradar.io.backends.CfRadial2BackendEntrypoint[source]#
Bases:
BackendEntrypointXarray BackendEntrypoint for CfRadial2/FM301 grouped datasets.
- Keyword Arguments:
sweep (
int,str,iterable, optional) – Sweep selection. Defaults to all available sweeps.first_dim (
str) – Can betimeorauto. Defaults totime.optional (
bool) – Keep optional root variables when available. Defaults toTrue.optional_groups (
bool) – Include root metadata subgroups if present. Defaults toFalse.kwargs (
dict) – Additional kwargs are fed toxarray.open_datatree().
- guess_can_open(filename_or_obj)[source]#
CfRadial2 file (netCDF/HDF5 with sweep groups, whose
Conventionsmention CF/Radial and whose root hassweep_group_nameandtime_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. Seeopen_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 (
boolordict-like, optional) – Replace fill values with NA and applyscale_factor/add_offsetdecoding. Seexarray.open_dataset(). Defaults toTrue.decode_times (
boolordict-like, optional) – Decode CF time variables (calendar, units) intonp.datetime64. Defaults toTrue.concat_characters (
boolordict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults toTrue.decode_coords (
boolor{"coordinates", "all"}, optional) – Decode the CFcoordinatesattribute. Defaults toTrue(equivalent to"coordinates").drop_variables (
stroriterableofstr, optional) – Names of variables to drop before processing.use_cftime (
bool, optional) – Forcecftimedecoding for time variables (instead ofnp.datetime64). Defaults toNone(auto).decode_timedelta (
bool, optional) – Decode CF timedelta variables. Default mirrorsdecode_timesunless the backend overrides it (cfradial1, cfradial2, and imd default toFalse).sweep (
int,str, orlistofint/str, optional) – Sweep selection.None(default) returns all sweeps. Anintor"sweep_N"string returns one sweep; a list returns the named subset.first_dim (
{"auto", "time"}, optional) – Leading dimension of each sweep dataset."auto"picksazimuth(PPI) orelevation(RHI);"time"keeps the raw time axis. Default"auto"("time"for cfradial2).optional (
bool, optional) – Include optional root variables when available. Defaults toTrue.optional_groups (
bool, optional) – Include the/radar_parameters,/georeferencing_correction, and/radar_calibrationmetadata subgroups under the root. Defaults toFalse.site_coords (
bool, optional) – Keeplatitude/longitude/altitudeas coordinates on the root dataset. CfRadial2 stores station coords at root by default; passFalseto drop them. Defaults toTrue.netcdf_engine (
str, optional) – netCDF engine used to read the file (e.g."netcdf4"or"h5netcdf"). Defaults toNone(xarray’s choice).
- Returns:
dict[str,xarray.Dataset]– CfRadial2 group paths (/,/sweep_N, optional/radar_parametersetc.) mapped to their datasets, ready forxarray.DataTree.from_dict().
- class xradar.io.backends.DataMetBackendEntrypoint[source]#
Bases:
BackendEntrypointXarray BackendEntrypoint for DataMet data.
- 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. Seeopen_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.gzarchive 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 (
boolordict-like, optional) – Replace fill values with NA and applyscale_factor/add_offsetdecoding. Seexarray.open_dataset(). Defaults toTrue.decode_times (
boolordict-like, optional) – Decode CF time variables (calendar, units) intonp.datetime64. Defaults toTrue.concat_characters (
boolordict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults toTrue.decode_coords (
boolor{"coordinates", "all"}, optional) – Decode the CFcoordinatesattribute. Defaults toTrue(equivalent to"coordinates").drop_variables (
stroriterableofstr, optional) – Names of variables to drop before processing.use_cftime (
bool, optional) – Forcecftimedecoding for time variables (instead ofnp.datetime64). Defaults toNone(auto).decode_timedelta (
bool, optional) – Decode CF timedelta variables. Default mirrorsdecode_timesunless the backend overrides it (cfradial1, cfradial2, and imd default toFalse).sweep (
int,str, orlistofint/str, optional) – Sweep selection.None(default) returns all sweeps. Anintor"sweep_N"string returns one sweep; a list returns the named subset.first_dim (
{"auto", "time"}, optional) – Leading dimension of each sweep dataset."auto"picksazimuth(PPI) orelevation(RHI);"time"keeps the raw time axis. Default"auto"("time"for cfradial2).optional (
bool, optional) – Include optional root variables when available. Defaults toTrue.optional_groups (
bool, optional) – Include the/radar_parameters,/georeferencing_correction, and/radar_calibrationmetadata subgroups under the root. Defaults toFalse.reindex_coord (
dict, optional) – Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked whendecode_coords=True. Defaults toNone(no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.site_coords (
bool, optional) – Attachlatitude/longitude/altitudeas coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults toTrue.
- Returns:
dict[str,xarray.Dataset]– CfRadial2 group paths (/,/sweep_N, optional/radar_parametersetc.) mapped to their datasets, ready forxarray.DataTree.from_dict().
- class xradar.io.backends.FurunoBackendEntrypoint[source]#
Bases:
BackendEntrypointXarray BackendEntrypoint for Furuno data.
- 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. Seeopen_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 (
boolordict-like, optional) – Replace fill values with NA and applyscale_factor/add_offsetdecoding. Seexarray.open_dataset(). Defaults toTrue.decode_times (
boolordict-like, optional) – Decode CF time variables (calendar, units) intonp.datetime64. Defaults toTrue.concat_characters (
boolordict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults toTrue.decode_coords (
boolor{"coordinates", "all"}, optional) – Decode the CFcoordinatesattribute. Defaults toTrue(equivalent to"coordinates").drop_variables (
stroriterableofstr, optional) – Names of variables to drop before processing.use_cftime (
bool, optional) – Forcecftimedecoding for time variables (instead ofnp.datetime64). Defaults toNone(auto).decode_timedelta (
bool, optional) – Decode CF timedelta variables. Default mirrorsdecode_timesunless the backend overrides it (cfradial1, cfradial2, and imd default toFalse).sweep (
int,str, orlistofint/str, optional) – Sweep selection.None(default) returns all sweeps. Anintor"sweep_N"string returns one sweep; a list returns the named subset.first_dim (
{"auto", "time"}, optional) – Leading dimension of each sweep dataset."auto"picksazimuth(PPI) orelevation(RHI);"time"keeps the raw time axis. Default"auto"("time"for cfradial2).optional (
bool, optional) – Include optional root variables when available. Defaults toTrue.optional_groups (
bool, optional) – Include the/radar_parameters,/georeferencing_correction, and/radar_calibrationmetadata subgroups under the root. Defaults toFalse.reindex_coord (
dict, optional) – Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked whendecode_coords=True. Defaults toNone(no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.fix_second_angle (
bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective withfirst_dim="auto". Defaults toFalse.site_coords (
bool, optional) – Attachlatitude/longitude/altitudeas coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults toTrue.obsmode (
intorNone, optional) – Override the file’s observation-mode flag (rare; only needed for files written by older firmware). Defaults toNone.
- Returns:
dict[str,xarray.Dataset]– CfRadial2 group paths (/,/sweep_N, optional/radar_parametersetc.) mapped to their datasets, ready forxarray.DataTree.from_dict().
- class xradar.io.backends.GamicBackendEntrypoint[source]#
Bases:
BackendEntrypointXarray BackendEntrypoint for GAMIC data.
- Keyword Arguments:
first_dim (
str) – Can betimeorautofirst dimension. If set toauto, first dimension will be eitherazimuthorelevationdepending on type of sweep. Defaults toauto.reindex_coord (
dict, optional) – Defaults to None, no reindexing. Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked ifdecode_coords=True.reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.fix_second_angle (
bool) – For PPI only. If True, fixes erroneous second angle data. Defaults toFalse.site_as_coords (
bool) – Attach radar site-coordinates to Dataset, defaults toTrue.kwargs (
dict) – Additional kwargs are fed toxarray.open_dataset().
- 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. Seeopen_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 (
boolordict-like, optional) – Replace fill values with NA and applyscale_factor/add_offsetdecoding. Seexarray.open_dataset(). Defaults toTrue.decode_times (
boolordict-like, optional) – Decode CF time variables (calendar, units) intonp.datetime64. Defaults toTrue.concat_characters (
boolordict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults toTrue.decode_coords (
boolor{"coordinates", "all"}, optional) – Decode the CFcoordinatesattribute. Defaults toTrue(equivalent to"coordinates").drop_variables (
stroriterableofstr, optional) – Names of variables to drop before processing.use_cftime (
bool, optional) – Forcecftimedecoding for time variables (instead ofnp.datetime64). Defaults toNone(auto).decode_timedelta (
bool, optional) – Decode CF timedelta variables. Default mirrorsdecode_timesunless the backend overrides it (cfradial1, cfradial2, and imd default toFalse).sweep (
int,str, orlistofint/str, optional) – Sweep selection.None(default) returns all sweeps. Anintor"sweep_N"string returns one sweep; a list returns the named subset.first_dim (
{"auto", "time"}, optional) – Leading dimension of each sweep dataset."auto"picksazimuth(PPI) orelevation(RHI);"time"keeps the raw time axis. Default"auto"("time"for cfradial2).optional (
bool, optional) – Include optional root variables when available. Defaults toTrue.optional_groups (
bool, optional) – Include the/radar_parameters,/georeferencing_correction, and/radar_calibrationmetadata subgroups under the root. Defaults toFalse.format (
str, optional) – h5netcdf format string. Defaults toNone.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 toTrue.reindex_coord (
dict, optional) – Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked whendecode_coords=True. Defaults toNone(no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.fix_second_angle (
bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective withfirst_dim="auto". Defaults toFalse.site_coords (
bool, optional) – Attachlatitude/longitude/altitudeas coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults toTrue.
- Returns:
dict[str,xarray.Dataset]– CfRadial2 group paths (/,/sweep_N, optional/radar_parametersetc.) mapped to their datasets, ready forxarray.DataTree.from_dict().
- class xradar.io.backends.HPLBackendEntrypoint[source]#
Bases:
BackendEntrypointXarray BackendEntrypoint for Halo Photonics Doppler processed lidar data.
- Keyword Arguments:
first_dim (
str) – Can betimeorautofirst dimension. If set toauto, first dimension will be eitherazimuthorelevationdepending on type of sweep. Defaults toauto.site_as_coords (
bool) – Attach radar site-coordinates to Dataset, defaults toTrue.kwargs (
dict) – Additional kwargs are fed toxarray.open_dataset().
- 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. Seeopen_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 (
boolordict-like, optional) – Replace fill values with NA and applyscale_factor/add_offsetdecoding. Seexarray.open_dataset(). Defaults toTrue.decode_times (
boolordict-like, optional) – Decode CF time variables (calendar, units) intonp.datetime64. Defaults toTrue.concat_characters (
boolordict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults toTrue.decode_coords (
boolor{"coordinates", "all"}, optional) – Decode the CFcoordinatesattribute. Defaults toTrue(equivalent to"coordinates").drop_variables (
stroriterableofstr, optional) – Names of variables to drop before processing.use_cftime (
bool, optional) – Forcecftimedecoding for time variables (instead ofnp.datetime64). Defaults toNone(auto).decode_timedelta (
bool, optional) – Decode CF timedelta variables. Default mirrorsdecode_timesunless the backend overrides it (cfradial1, cfradial2, and imd default toFalse).sweep (
int,str, orlistofint/str, optional) – Sweep selection.None(default) returns all sweeps. Anintor"sweep_N"string returns one sweep; a list returns the named subset.first_dim (
{"auto", "time"}, optional) – Leading dimension of each sweep dataset."auto"picksazimuth(PPI) orelevation(RHI);"time"keeps the raw time axis. Default"auto"("time"for cfradial2).optional (
bool, optional) – Include optional root variables when available. Defaults toTrue.optional_groups (
bool, optional) – Include the/radar_parameters,/georeferencing_correction, and/radar_calibrationmetadata subgroups under the root. Defaults toFalse.format (
str, optional) – h5netcdf format string. Defaults toNone.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 toTrue.reindex_coord (
dict, optional) – Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked whendecode_coords=True. Defaults toNone(no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.site_coords (
bool, optional) – Attachlatitude/longitude/altitudeas coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults toTrue.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_parametersetc.) mapped to their datasets, ready forxarray.DataTree.from_dict().
- class xradar.io.backends.IMDBackendEntrypoint[source]#
Bases:
BackendEntrypointXarray 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 sweepxarray.Dataset. To assemble a multi-sweep volume, useopen_imd_datatree()with a list of files.- Keyword Arguments:
first_dim (
str) – Can betimeorauto(default).autoselectsazimuth(PPI) orelevation(RHI) as the first dimension.reindex_coord (
dict, optional) – Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(). Defaults toNone(no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.site_as_coords (
bool) – If True (default), promotelatitude/longitude/altitudeto Dataset coordinates.
- description: ClassVar[str] = 'Open India Meteorological Department (IMD) radar NetCDF files in Xarray'#
- 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. Seeopen_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 (
boolordict-like, optional) – Replace fill values with NA and applyscale_factor/add_offsetdecoding. Seexarray.open_dataset(). Defaults toTrue.decode_times (
boolordict-like, optional) – Decode CF time variables (calendar, units) intonp.datetime64. Defaults toTrue.concat_characters (
boolordict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults toTrue.decode_coords (
boolor{"coordinates", "all"}, optional) – Decode the CFcoordinatesattribute. Defaults toTrue(equivalent to"coordinates").drop_variables (
stroriterableofstr, optional) – Names of variables to drop before processing.use_cftime (
bool, optional) – Forcecftimedecoding for time variables (instead ofnp.datetime64). Defaults toNone(auto).decode_timedelta (
bool, optional) – Decode CF timedelta variables. Default mirrorsdecode_timesunless the backend overrides it (cfradial1, cfradial2, and imd default toFalse).sweep (
int,str, orlistofint/str, optional) – Sweep selection.None(default) returns all sweeps. Anintor"sweep_N"string returns one sweep; a list returns the named subset.first_dim (
{"auto", "time"}, optional) – Leading dimension of each sweep dataset."auto"picksazimuth(PPI) orelevation(RHI);"time"keeps the raw time axis. Default"auto"("time"for cfradial2).optional_groups (
bool, optional) – Include the/radar_parameters,/georeferencing_correction, and/radar_calibrationmetadata subgroups under the root. Defaults toFalse.sweep (
int,strorlist, optional) – IMD files hold one sweep, so onlyNone,0or"sweep_0"are accepted. Defaults toNone.reindex_coord (
dict, optional) – Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked whendecode_coords=True. Defaults toNone(no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.site_coords (
bool, optional) – Attachlatitude/longitude/altitudeas coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults toTrue.
- Returns:
dict[str,xarray.Dataset]– CfRadial2 group paths (/,/sweep_N, optional/radar_parametersetc.) mapped to their datasets, ready forxarray.DataTree.from_dict().
- class xradar.io.backends.IrisBackendEntrypoint[source]#
Bases:
BackendEntrypointXarray BackendEntrypoint for IRIS/Sigmet data.
- 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. Seeopen_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 (
boolordict-like, optional) – Replace fill values with NA and applyscale_factor/add_offsetdecoding. Seexarray.open_dataset(). Defaults toTrue.decode_times (
boolordict-like, optional) – Decode CF time variables (calendar, units) intonp.datetime64. Defaults toTrue.concat_characters (
boolordict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults toTrue.decode_coords (
boolor{"coordinates", "all"}, optional) – Decode the CFcoordinatesattribute. Defaults toTrue(equivalent to"coordinates").drop_variables (
stroriterableofstr, optional) – Names of variables to drop before processing.use_cftime (
bool, optional) – Forcecftimedecoding for time variables (instead ofnp.datetime64). Defaults toNone(auto).decode_timedelta (
bool, optional) – Decode CF timedelta variables. Default mirrorsdecode_timesunless the backend overrides it (cfradial1, cfradial2, and imd default toFalse).sweep (
int,str, orlistofint/str, optional) – Sweep selection.None(default) returns all sweeps. Anintor"sweep_N"string returns one sweep; a list returns the named subset.first_dim (
{"auto", "time"}, optional) – Leading dimension of each sweep dataset."auto"picksazimuth(PPI) orelevation(RHI);"time"keeps the raw time axis. Default"auto"("time"for cfradial2).optional (
bool, optional) – Include optional root variables when available. Defaults toTrue.optional_groups (
bool, optional) – Include the/radar_parameters,/georeferencing_correction, and/radar_calibrationmetadata subgroups under the root. Defaults toFalse.reindex_coord (
dict, optional) – Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked whendecode_coords=True. Defaults toNone(no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.fix_second_angle (
bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective withfirst_dim="auto". Defaults toFalse.site_coords (
bool, optional) – Attachlatitude/longitude/altitudeas coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults toTrue.lock (
threading.LockorNone, optional) – Reader lock for thread-safe access. Defaults toNone.
- Returns:
dict[str,xarray.Dataset]– CfRadial2 group paths (/,/sweep_N, optional/radar_parametersetc.) mapped to their datasets, ready forxarray.DataTree.from_dict().
- class xradar.io.backends.MRRBackendEntrypoint[source]#
Bases:
BackendEntrypointXarray BackendEntrypoint for Metek MRR2 data.
- Keyword Arguments:
first_dim (
str) – Can betimeorautofirst dimension. If set toauto, first dimension will be eitherazimuthorelevationdepending on type of sweep. Defaults toauto.site_as_coords (
bool) – Attach radar site-coordinates to Dataset, defaults toTrue.kwargs (
dict) – Additional kwargs are fed toxarray.open_dataset().
- 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. Seeopen_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_0group 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 (
boolordict-like, optional) – Replace fill values with NA and applyscale_factor/add_offsetdecoding. Seexarray.open_dataset(). Defaults toTrue.decode_times (
boolordict-like, optional) – Decode CF time variables (calendar, units) intonp.datetime64. Defaults toTrue.concat_characters (
boolordict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults toTrue.decode_coords (
boolor{"coordinates", "all"}, optional) – Decode the CFcoordinatesattribute. Defaults toTrue(equivalent to"coordinates").drop_variables (
stroriterableofstr, optional) – Names of variables to drop before processing.use_cftime (
bool, optional) – Forcecftimedecoding for time variables (instead ofnp.datetime64). Defaults toNone(auto).decode_timedelta (
bool, optional) – Decode CF timedelta variables. Default mirrorsdecode_timesunless the backend overrides it (cfradial1, cfradial2, and imd default toFalse).sweep (
int,str, orlistofint/str, optional) – Sweep selection.None(default) returns all sweeps. Anintor"sweep_N"string returns one sweep; a list returns the named subset.first_dim (
{"auto", "time"}, optional) – Leading dimension of each sweep dataset."auto"picksazimuth(PPI) orelevation(RHI);"time"keeps the raw time axis. Default"auto"("time"for cfradial2).optional (
bool, optional) – Include optional root variables when available. Defaults toTrue.optional_groups (
bool, optional) – Include the/radar_parameters,/georeferencing_correction, and/radar_calibrationmetadata subgroups under the root. Defaults toFalse.format (
str, optional) – h5netcdf format string. Defaults toNone.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 toTrue.site_coords (
bool, optional) – Attachlatitude/longitude/altitudeas coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults toTrue.
- Returns:
dict[str,xarray.Dataset]– CfRadial2 group paths (/,/sweep_N, optional/radar_parametersetc.) mapped to their datasets, ready forxarray.DataTree.from_dict().
- class xradar.io.backends.NexradLevel2BackendEntrypoint[source]#
Bases:
BackendEntrypointXarray BackendEntrypoint for NEXRAD Level2 Data
- 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. Seeopen_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 (
boolordict-like, optional) – Replace fill values with NA and applyscale_factor/add_offsetdecoding. Seexarray.open_dataset(). Defaults toTrue.decode_times (
boolordict-like, optional) – Decode CF time variables (calendar, units) intonp.datetime64. Defaults toTrue.concat_characters (
boolordict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults toTrue.decode_coords (
boolor{"coordinates", "all"}, optional) – Decode the CFcoordinatesattribute. Defaults toTrue(equivalent to"coordinates").drop_variables (
stroriterableofstr, optional) – Names of variables to drop before processing.use_cftime (
bool, optional) – Forcecftimedecoding for time variables (instead ofnp.datetime64). Defaults toNone(auto).decode_timedelta (
bool, optional) – Decode CF timedelta variables. Default mirrorsdecode_timesunless the backend overrides it (cfradial1, cfradial2, and imd default toFalse).sweep (
int,str, orlistofint/str, optional) – Sweep selection.None(default) returns all sweeps. Anintor"sweep_N"string returns one sweep; a list returns the named subset.first_dim (
{"auto", "time"}, optional) – Leading dimension of each sweep dataset."auto"picksazimuth(PPI) orelevation(RHI);"time"keeps the raw time axis. Default"auto"("time"for cfradial2).optional (
bool, optional) – Include optional root variables when available. Defaults toTrue.optional_groups (
bool, optional) – Include the/radar_parameters,/georeferencing_correction, and/radar_calibrationmetadata subgroups under the root. Defaults toFalse.reindex_coord (
dict, optional) – Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked whendecode_coords=True. Defaults toNone(no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.fix_second_angle (
bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective withfirst_dim="auto". Defaults toFalse.site_coords (
bool, optional) – Attachlatitude/longitude/altitudeas coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults toTrue.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.LockorNone, optional) – Reader lock for thread-safe access. Defaults toNone.
- Returns:
dict[str,xarray.Dataset]– CfRadial2 group paths (/,/sweep_N, optional/radar_parametersetc.) mapped to their datasets, ready forxarray.DataTree.from_dict().
- class xradar.io.backends.OdimBackendEntrypoint[source]#
Bases:
BackendEntrypointXarray BackendEntrypoint for ODIM data.
- Keyword Arguments:
first_dim (
str) – Can betimeorautofirst dimension. If set toauto, first dimension will be eitherazimuthorelevationdepending on type of sweep. Defaults toauto.reindex_coord (
dict, optional) – Defaults to None, no reindexing. Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked ifdecode_coords=True.reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.fix_second_angle (
bool) – If True, fixes erroneous second angle data. Defaults toFalse.site_as_coords (
bool) – Attach radar site-coordinates to Dataset, defaults toTrue.kwargs (
dict) – Additional kwargs are fed toxarray.open_dataset().
- 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, soclose()releases it. Seeopen_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 (
boolordict-like, optional) – Replace fill values with NA and applyscale_factor/add_offsetdecoding. Seexarray.open_dataset(). Defaults toTrue.decode_times (
boolordict-like, optional) – Decode CF time variables (calendar, units) intonp.datetime64. Defaults toTrue.concat_characters (
boolordict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults toTrue.decode_coords (
boolor{"coordinates", "all"}, optional) – Decode the CFcoordinatesattribute. Defaults toTrue(equivalent to"coordinates").drop_variables (
stroriterableofstr, optional) – Names of variables to drop before processing.use_cftime (
bool, optional) – Forcecftimedecoding for time variables (instead ofnp.datetime64). Defaults toNone(auto).decode_timedelta (
bool, optional) – Decode CF timedelta variables. Default mirrorsdecode_timesunless the backend overrides it (cfradial1, cfradial2, and imd default toFalse).sweep (
int,str, orlistofint/str, optional) – Sweep selection.None(default) returns all sweeps. Anintor"sweep_N"string returns one sweep; a list returns the named subset.first_dim (
{"auto", "time"}, optional) – Leading dimension of each sweep dataset."auto"picksazimuth(PPI) orelevation(RHI);"time"keeps the raw time axis. Default"auto"("time"for cfradial2).optional (
bool, optional) – Include optional root variables when available. Defaults toTrue.optional_groups (
bool, optional) – Include the/radar_parameters,/georeferencing_correction, and/radar_calibrationmetadata subgroups under the root. Defaults toFalse.format (
str, optional) – h5netcdf format string. Defaults toNone.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 toTrue.reindex_coord (
dict, optional) – Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked whendecode_coords=True. Defaults toNone(no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.fix_second_angle (
bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective withfirst_dim="auto". Defaults toFalse.site_coords (
bool, optional) – Attachlatitude/longitude/altitudeas coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults toTrue.
- Returns:
dict[str,xarray.Dataset]– CfRadial2 group paths (/,/sweep_N, optional/radar_parametersetc.) mapped to their datasets, ready forxarray.DataTree.from_dict().
- class xradar.io.backends.RainbowBackendEntrypoint[source]#
Bases:
BackendEntrypointXarray BackendEntrypoint for Rainbow5 data.
- 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. Seeopen_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 (
boolordict-like, optional) – Replace fill values with NA and applyscale_factor/add_offsetdecoding. Seexarray.open_dataset(). Defaults toTrue.decode_times (
boolordict-like, optional) – Decode CF time variables (calendar, units) intonp.datetime64. Defaults toTrue.concat_characters (
boolordict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults toTrue.decode_coords (
boolor{"coordinates", "all"}, optional) – Decode the CFcoordinatesattribute. Defaults toTrue(equivalent to"coordinates").drop_variables (
stroriterableofstr, optional) – Names of variables to drop before processing.use_cftime (
bool, optional) – Forcecftimedecoding for time variables (instead ofnp.datetime64). Defaults toNone(auto).decode_timedelta (
bool, optional) – Decode CF timedelta variables. Default mirrorsdecode_timesunless the backend overrides it (cfradial1, cfradial2, and imd default toFalse).sweep (
int,str, orlistofint/str, optional) – Sweep selection.None(default) returns all sweeps. Anintor"sweep_N"string returns one sweep; a list returns the named subset.first_dim (
{"auto", "time"}, optional) – Leading dimension of each sweep dataset."auto"picksazimuth(PPI) orelevation(RHI);"time"keeps the raw time axis. Default"auto"("time"for cfradial2).optional (
bool, optional) – Include optional root variables when available. Defaults toTrue.optional_groups (
bool, optional) – Include the/radar_parameters,/georeferencing_correction, and/radar_calibrationmetadata subgroups under the root. Defaults toFalse.reindex_coord (
dict, optional) – Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked whendecode_coords=True. Defaults toNone(no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.site_coords (
bool, optional) – Attachlatitude/longitude/altitudeas coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults toTrue.
- Returns:
dict[str,xarray.Dataset]– CfRadial2 group paths (/,/sweep_N, optional/radar_parametersetc.) mapped to their datasets, ready forxarray.DataTree.from_dict().
- class xradar.io.backends.UFBackendEntrypoint[source]#
Bases:
BackendEntrypointXarray BackendEntrypoint for Universal Format (UF) data.
- 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. Seeopen_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 (
boolordict-like, optional) – Replace fill values with NA and applyscale_factor/add_offsetdecoding. Seexarray.open_dataset(). Defaults toTrue.decode_times (
boolordict-like, optional) – Decode CF time variables (calendar, units) intonp.datetime64. Defaults toTrue.concat_characters (
boolordict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults toTrue.decode_coords (
boolor{"coordinates", "all"}, optional) – Decode the CFcoordinatesattribute. Defaults toTrue(equivalent to"coordinates").drop_variables (
stroriterableofstr, optional) – Names of variables to drop before processing.use_cftime (
bool, optional) – Forcecftimedecoding for time variables (instead ofnp.datetime64). Defaults toNone(auto).decode_timedelta (
bool, optional) – Decode CF timedelta variables. Default mirrorsdecode_timesunless the backend overrides it (cfradial1, cfradial2, and imd default toFalse).sweep (
int,str, orlistofint/str, optional) – Sweep selection.None(default) returns all sweeps. Anintor"sweep_N"string returns one sweep; a list returns the named subset.first_dim (
{"auto", "time"}, optional) – Leading dimension of each sweep dataset."auto"picksazimuth(PPI) orelevation(RHI);"time"keeps the raw time axis. Default"auto"("time"for cfradial2).optional (
bool, optional) – Include optional root variables when available. Defaults toTrue.optional_groups (
bool, optional) – Include the/radar_parameters,/georeferencing_correction, and/radar_calibrationmetadata subgroups under the root. Defaults toFalse.reindex_coord (
dict, optional) – Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked whendecode_coords=True. Defaults toNone(no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.fix_second_angle (
bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective withfirst_dim="auto". Defaults toFalse.site_coords (
bool, optional) – Attachlatitude/longitude/altitudeas coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults toTrue.lock (
threading.LockorNone, optional) – Reader lock for thread-safe access. Defaults toNone.
- Returns:
dict[str,xarray.Dataset]– CfRadial2 group paths (/,/sweep_N, optional/radar_parametersetc.) mapped to their datasets, ready forxarray.DataTree.from_dict().
- 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.AR2Vfor NEXRAD Level II,ODIM_H5conventions in HDF5 files), seelist_xradar_engines().- Parameters:
filename_or_obj (
str,os.PathLike,bytesor 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, oriterableofthose) –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.
- 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")orxr.open_datatree(file, engine="cfradial1")instead.- Parameters:
filename_or_obj (
str,Path, file-like orxarray.DataStore) – Strings and Path objects are interpreted as a path to a local or remote radar file- Keyword Arguments:
sweep (
int,listofint, optional) – Sweep number(s) to extract, default to first sweep. If None, all sweeps are extracted into a list.first_dim (
str) – Can betimeorautofirst dimension. If set toauto, first dimension will be eitherazimuthorelevationdepending on type of sweep. Defaults toauto.reindex_coord (
dict, optional) – Defaults to None, no reindexing. Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked ifdecode_coords=True.reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.fix_second_angle (
bool) – If True, fixes erroneous second angle data. Defaults toFalse.optional (
bool) – Import optional mandatory data and metadata, defaults toTrue.site_as_coords (
bool) – Attach radar site-coordinates to Dataset, defaults toTrue.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")orxr.open_datatree(file, engine="cfradial2")instead.- Parameters:
filename_or_obj (
strorPathLike) – Path or object understood byxarray.open_datatree().- Keyword Arguments:
sweep (
int,str,iterable, optional) – Sweep selection. Defaults to all available sweeps.first_dim (
str) – Can betimeorauto. Defaults totime.optional (
bool) – Keep optional root variables when available. Defaults toTrue.optional_groups (
bool) – Include root metadata subgroups if present. Defaults toFalse.**kwargs (
dict) – Additional keyword arguments passed toxarray.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 supportstime_coverage_start,time_coverage_end,min_angle,max_anglefiltering.
Note
When opening a single IMD sweep file as a DataTree, prefer
xd.open_datatree(file, engine="imd")(or the xarray-nativexr.open_datatree(file, engine="imd")). This function remains the documented API for the multi-file path because IMD volumes span multiple files, which theengine="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, orlist/tupleofthose) – 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 keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range().reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.site_as_coords (
bool) – Attach station variables as coordinates on sweep Datasets.site_coordsis accepted as an alias.optional_groups (
bool) – Include/radar_parameters,/georeferencing_correctionand/radar_calibrationsubgroups. Defaults toFalse. With multiple files the values the files disagree about are left out of the groups, with aUserWarning.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 andsweep_Nchildren.
- 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 viaopen_imd_datatree(), and nests them under zero-paddedvcp_NNchild nodes of a parent root.vcpstands 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, oriterableofthose) – Same asgroup_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, :keywordoptional_groups,min_angle,max_angle.:- Returns:
dtree (
xarray.DataTree) –Root with
vcp_NNchildren, 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, orDataStore) – 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. Usemask_and_scale=Falseto 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 (
strorlistofstr, 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 (
intorlistofint, 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 keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(). Only used if decode_coords=True. Default is None (no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_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_correctionand/radar_calibrationmetadata 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")orxr.open_datatree(file, engine="odim")instead.- Parameters:
filename_or_obj (
str,Path, file-like orDataStore) – Strings and Path objects are interpreted as a path to a local or remote radar file- Keyword Arguments:
sweep (
int,listofint, optional) – Sweep number(s) to extract, default to first sweep. If None, all sweeps are extracted into a list.first_dim (
str) – Can betimeorautofirst dimension. If set toauto, first dimension will be eitherazimuthorelevationdepending on type of sweep. Defaults toauto.reindex_coord (
dict, optional) – Defaults to None, no reindexing. Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked ifdecode_coords=True.reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.fix_second_angle (
bool) – If True, fixes erroneous second angle data. Defaults toFalse.site_as_coords (
bool) – Attach radar site-coordinates to Dataset, defaults toTrue.kwargs (
dict) – Additional kwargs are fed toxarray.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, orDataStore) – 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 (
strorlistofstr, 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 (
intorlistofint, 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 keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(). Only used if decode_coords=True. Default is None (no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_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_correctionand/radar_calibrationmetadata groups. Default is False.lock (
threading.LockorNone, optional) – Lock used when reading the file. Default is None (the UF lock).kwargs (
dict) – Additional keyword arguments passed toxarray.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)
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 usedengine (
str) – Either netcdf4 or h5netcdf.deepcopy (
bool) – If True, work on a deep copy ofdtree(the data is duplicated in memory). If False (default), work on a shallow copy, which shares the underlying data arrays withdtreebut 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)
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:
dtree (
xarray.DataTree)filename (
str) – output filename
- Keyword Arguments:
source (
str, optional) – Radar identifiers forwhat/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 Falsecompression (
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 onerange(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-Drange(sweep, range)with the attributesmeters_to_center_of_first_gateandmeters_between_gatesper 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-Drangeis 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 usedengine (
str) – Either netcdf4 or h5netcdf.deepcopy (
bool) – If True, work on a deep copy ofdtree(the data is duplicated in memory). If False (default), work on a shallow copy, which shares the underlying data arrays withdtreebut 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:
dtree (
xarray.DataTree)filename (
str) – output filename
- Keyword Arguments:
source (
str, optional) – Radar identifiers forwhat/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 Falsecompression (
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:
BackendEntrypointXarray BackendEntrypoint for CfRadial1 data.
- Keyword Arguments:
first_dim (
str) – Can betimeorautofirst dimension. If set toauto, first dimension will be eitherazimuthorelevationdepending on type of sweep. Defaults toauto.reindex_coord (
dict, optional) – Defaults to None, no reindexing. Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked ifdecode_coords=True.reindex_angle (
dict, optional) – Deprecated, usereindex_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 toTrue.kwargs (
dict) – Additional kwargs are fed toxarray.open_dataset().
- guess_can_open(filename_or_obj)[source]#
CfRadial1 file (netCDF with
sweep_start_ray_indexand aConventionsorversionmentioning 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. Seeopen_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 (
boolordict-like, optional) – Replace fill values with NA and applyscale_factor/add_offsetdecoding. Seexarray.open_dataset(). Defaults toTrue.decode_times (
boolordict-like, optional) – Decode CF time variables (calendar, units) intonp.datetime64. Defaults toTrue.concat_characters (
boolordict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults toTrue.decode_coords (
boolor{"coordinates", "all"}, optional) – Decode the CFcoordinatesattribute. Defaults toTrue(equivalent to"coordinates").drop_variables (
stroriterableofstr, optional) – Names of variables to drop before processing.use_cftime (
bool, optional) – Forcecftimedecoding for time variables (instead ofnp.datetime64). Defaults toNone(auto).decode_timedelta (
bool, optional) – Decode CF timedelta variables. Default mirrorsdecode_timesunless the backend overrides it (cfradial1, cfradial2, and imd default toFalse).sweep (
int,str, orlistofint/str, optional) – Sweep selection.None(default) returns all sweeps. Anintor"sweep_N"string returns one sweep; a list returns the named subset.first_dim (
{"auto", "time"}, optional) – Leading dimension of each sweep dataset."auto"picksazimuth(PPI) orelevation(RHI);"time"keeps the raw time axis. Default"auto"("time"for cfradial2).optional (
bool, optional) – Include optional root variables when available. Defaults toTrue.optional_groups (
bool, optional) – Include the/radar_parameters,/georeferencing_correction, and/radar_calibrationmetadata subgroups under the root. Defaults toFalse.reindex_coord (
dict, optional) – Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked whendecode_coords=True. Defaults toNone(no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.fix_second_angle (
bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective withfirst_dim="auto". Defaults toFalse.site_coords (
bool, optional) – Attachlatitude/longitude/altitudeas coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults toTrue.netcdf_engine (
{"netcdf4", "h5netcdf"}, optional) – Underlying NetCDF engine used byxr.open_datasetto read the CfRadial1 file. Defaults to"netcdf4".
- Returns:
dict[str,xarray.Dataset]– CfRadial2 group paths (/,/sweep_N, optional/radar_parametersetc.) mapped to their datasets, ready forxarray.DataTree.from_dict().
- class xradar.io.CfRadial2BackendEntrypoint[source]#
Bases:
BackendEntrypointXarray BackendEntrypoint for CfRadial2/FM301 grouped datasets.
- Keyword Arguments:
sweep (
int,str,iterable, optional) – Sweep selection. Defaults to all available sweeps.first_dim (
str) – Can betimeorauto. Defaults totime.optional (
bool) – Keep optional root variables when available. Defaults toTrue.optional_groups (
bool) – Include root metadata subgroups if present. Defaults toFalse.kwargs (
dict) – Additional kwargs are fed toxarray.open_datatree().
- guess_can_open(filename_or_obj)[source]#
CfRadial2 file (netCDF/HDF5 with sweep groups, whose
Conventionsmention CF/Radial and whose root hassweep_group_nameandtime_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. Seeopen_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 (
boolordict-like, optional) – Replace fill values with NA and applyscale_factor/add_offsetdecoding. Seexarray.open_dataset(). Defaults toTrue.decode_times (
boolordict-like, optional) – Decode CF time variables (calendar, units) intonp.datetime64. Defaults toTrue.concat_characters (
boolordict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults toTrue.decode_coords (
boolor{"coordinates", "all"}, optional) – Decode the CFcoordinatesattribute. Defaults toTrue(equivalent to"coordinates").drop_variables (
stroriterableofstr, optional) – Names of variables to drop before processing.use_cftime (
bool, optional) – Forcecftimedecoding for time variables (instead ofnp.datetime64). Defaults toNone(auto).decode_timedelta (
bool, optional) – Decode CF timedelta variables. Default mirrorsdecode_timesunless the backend overrides it (cfradial1, cfradial2, and imd default toFalse).sweep (
int,str, orlistofint/str, optional) – Sweep selection.None(default) returns all sweeps. Anintor"sweep_N"string returns one sweep; a list returns the named subset.first_dim (
{"auto", "time"}, optional) – Leading dimension of each sweep dataset."auto"picksazimuth(PPI) orelevation(RHI);"time"keeps the raw time axis. Default"auto"("time"for cfradial2).optional (
bool, optional) – Include optional root variables when available. Defaults toTrue.optional_groups (
bool, optional) – Include the/radar_parameters,/georeferencing_correction, and/radar_calibrationmetadata subgroups under the root. Defaults toFalse.site_coords (
bool, optional) – Keeplatitude/longitude/altitudeas coordinates on the root dataset. CfRadial2 stores station coords at root by default; passFalseto drop them. Defaults toTrue.netcdf_engine (
str, optional) – netCDF engine used to read the file (e.g."netcdf4"or"h5netcdf"). Defaults toNone(xarray’s choice).
- Returns:
dict[str,xarray.Dataset]– CfRadial2 group paths (/,/sweep_N, optional/radar_parametersetc.) mapped to their datasets, ready forxarray.DataTree.from_dict().
- class xradar.io.DataMetBackendEntrypoint[source]#
Bases:
BackendEntrypointXarray BackendEntrypoint for DataMet data.
- 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. Seeopen_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.gzarchive 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 (
boolordict-like, optional) – Replace fill values with NA and applyscale_factor/add_offsetdecoding. Seexarray.open_dataset(). Defaults toTrue.decode_times (
boolordict-like, optional) – Decode CF time variables (calendar, units) intonp.datetime64. Defaults toTrue.concat_characters (
boolordict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults toTrue.decode_coords (
boolor{"coordinates", "all"}, optional) – Decode the CFcoordinatesattribute. Defaults toTrue(equivalent to"coordinates").drop_variables (
stroriterableofstr, optional) – Names of variables to drop before processing.use_cftime (
bool, optional) – Forcecftimedecoding for time variables (instead ofnp.datetime64). Defaults toNone(auto).decode_timedelta (
bool, optional) – Decode CF timedelta variables. Default mirrorsdecode_timesunless the backend overrides it (cfradial1, cfradial2, and imd default toFalse).sweep (
int,str, orlistofint/str, optional) – Sweep selection.None(default) returns all sweeps. Anintor"sweep_N"string returns one sweep; a list returns the named subset.first_dim (
{"auto", "time"}, optional) – Leading dimension of each sweep dataset."auto"picksazimuth(PPI) orelevation(RHI);"time"keeps the raw time axis. Default"auto"("time"for cfradial2).optional (
bool, optional) – Include optional root variables when available. Defaults toTrue.optional_groups (
bool, optional) – Include the/radar_parameters,/georeferencing_correction, and/radar_calibrationmetadata subgroups under the root. Defaults toFalse.reindex_coord (
dict, optional) – Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked whendecode_coords=True. Defaults toNone(no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.site_coords (
bool, optional) – Attachlatitude/longitude/altitudeas coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults toTrue.
- Returns:
dict[str,xarray.Dataset]– CfRadial2 group paths (/,/sweep_N, optional/radar_parametersetc.) mapped to their datasets, ready forxarray.DataTree.from_dict().
- class xradar.io.FurunoBackendEntrypoint[source]#
Bases:
BackendEntrypointXarray BackendEntrypoint for Furuno data.
- 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. Seeopen_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 (
boolordict-like, optional) – Replace fill values with NA and applyscale_factor/add_offsetdecoding. Seexarray.open_dataset(). Defaults toTrue.decode_times (
boolordict-like, optional) – Decode CF time variables (calendar, units) intonp.datetime64. Defaults toTrue.concat_characters (
boolordict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults toTrue.decode_coords (
boolor{"coordinates", "all"}, optional) – Decode the CFcoordinatesattribute. Defaults toTrue(equivalent to"coordinates").drop_variables (
stroriterableofstr, optional) – Names of variables to drop before processing.use_cftime (
bool, optional) – Forcecftimedecoding for time variables (instead ofnp.datetime64). Defaults toNone(auto).decode_timedelta (
bool, optional) – Decode CF timedelta variables. Default mirrorsdecode_timesunless the backend overrides it (cfradial1, cfradial2, and imd default toFalse).sweep (
int,str, orlistofint/str, optional) – Sweep selection.None(default) returns all sweeps. Anintor"sweep_N"string returns one sweep; a list returns the named subset.first_dim (
{"auto", "time"}, optional) – Leading dimension of each sweep dataset."auto"picksazimuth(PPI) orelevation(RHI);"time"keeps the raw time axis. Default"auto"("time"for cfradial2).optional (
bool, optional) – Include optional root variables when available. Defaults toTrue.optional_groups (
bool, optional) – Include the/radar_parameters,/georeferencing_correction, and/radar_calibrationmetadata subgroups under the root. Defaults toFalse.reindex_coord (
dict, optional) – Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked whendecode_coords=True. Defaults toNone(no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.fix_second_angle (
bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective withfirst_dim="auto". Defaults toFalse.site_coords (
bool, optional) – Attachlatitude/longitude/altitudeas coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults toTrue.obsmode (
intorNone, optional) – Override the file’s observation-mode flag (rare; only needed for files written by older firmware). Defaults toNone.
- Returns:
dict[str,xarray.Dataset]– CfRadial2 group paths (/,/sweep_N, optional/radar_parametersetc.) mapped to their datasets, ready forxarray.DataTree.from_dict().
- class xradar.io.GamicBackendEntrypoint[source]#
Bases:
BackendEntrypointXarray BackendEntrypoint for GAMIC data.
- Keyword Arguments:
first_dim (
str) – Can betimeorautofirst dimension. If set toauto, first dimension will be eitherazimuthorelevationdepending on type of sweep. Defaults toauto.reindex_coord (
dict, optional) – Defaults to None, no reindexing. Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked ifdecode_coords=True.reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.fix_second_angle (
bool) – For PPI only. If True, fixes erroneous second angle data. Defaults toFalse.site_as_coords (
bool) – Attach radar site-coordinates to Dataset, defaults toTrue.kwargs (
dict) – Additional kwargs are fed toxarray.open_dataset().
- 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. Seeopen_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 (
boolordict-like, optional) – Replace fill values with NA and applyscale_factor/add_offsetdecoding. Seexarray.open_dataset(). Defaults toTrue.decode_times (
boolordict-like, optional) – Decode CF time variables (calendar, units) intonp.datetime64. Defaults toTrue.concat_characters (
boolordict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults toTrue.decode_coords (
boolor{"coordinates", "all"}, optional) – Decode the CFcoordinatesattribute. Defaults toTrue(equivalent to"coordinates").drop_variables (
stroriterableofstr, optional) – Names of variables to drop before processing.use_cftime (
bool, optional) – Forcecftimedecoding for time variables (instead ofnp.datetime64). Defaults toNone(auto).decode_timedelta (
bool, optional) – Decode CF timedelta variables. Default mirrorsdecode_timesunless the backend overrides it (cfradial1, cfradial2, and imd default toFalse).sweep (
int,str, orlistofint/str, optional) – Sweep selection.None(default) returns all sweeps. Anintor"sweep_N"string returns one sweep; a list returns the named subset.first_dim (
{"auto", "time"}, optional) – Leading dimension of each sweep dataset."auto"picksazimuth(PPI) orelevation(RHI);"time"keeps the raw time axis. Default"auto"("time"for cfradial2).optional (
bool, optional) – Include optional root variables when available. Defaults toTrue.optional_groups (
bool, optional) – Include the/radar_parameters,/georeferencing_correction, and/radar_calibrationmetadata subgroups under the root. Defaults toFalse.format (
str, optional) – h5netcdf format string. Defaults toNone.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 toTrue.reindex_coord (
dict, optional) – Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked whendecode_coords=True. Defaults toNone(no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.fix_second_angle (
bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective withfirst_dim="auto". Defaults toFalse.site_coords (
bool, optional) – Attachlatitude/longitude/altitudeas coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults toTrue.
- Returns:
dict[str,xarray.Dataset]– CfRadial2 group paths (/,/sweep_N, optional/radar_parametersetc.) mapped to their datasets, ready forxarray.DataTree.from_dict().
- class xradar.io.HPLBackendEntrypoint[source]#
Bases:
BackendEntrypointXarray BackendEntrypoint for Halo Photonics Doppler processed lidar data.
- Keyword Arguments:
first_dim (
str) – Can betimeorautofirst dimension. If set toauto, first dimension will be eitherazimuthorelevationdepending on type of sweep. Defaults toauto.site_as_coords (
bool) – Attach radar site-coordinates to Dataset, defaults toTrue.kwargs (
dict) – Additional kwargs are fed toxarray.open_dataset().
- 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. Seeopen_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 (
boolordict-like, optional) – Replace fill values with NA and applyscale_factor/add_offsetdecoding. Seexarray.open_dataset(). Defaults toTrue.decode_times (
boolordict-like, optional) – Decode CF time variables (calendar, units) intonp.datetime64. Defaults toTrue.concat_characters (
boolordict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults toTrue.decode_coords (
boolor{"coordinates", "all"}, optional) – Decode the CFcoordinatesattribute. Defaults toTrue(equivalent to"coordinates").drop_variables (
stroriterableofstr, optional) – Names of variables to drop before processing.use_cftime (
bool, optional) – Forcecftimedecoding for time variables (instead ofnp.datetime64). Defaults toNone(auto).decode_timedelta (
bool, optional) – Decode CF timedelta variables. Default mirrorsdecode_timesunless the backend overrides it (cfradial1, cfradial2, and imd default toFalse).sweep (
int,str, orlistofint/str, optional) – Sweep selection.None(default) returns all sweeps. Anintor"sweep_N"string returns one sweep; a list returns the named subset.first_dim (
{"auto", "time"}, optional) – Leading dimension of each sweep dataset."auto"picksazimuth(PPI) orelevation(RHI);"time"keeps the raw time axis. Default"auto"("time"for cfradial2).optional (
bool, optional) – Include optional root variables when available. Defaults toTrue.optional_groups (
bool, optional) – Include the/radar_parameters,/georeferencing_correction, and/radar_calibrationmetadata subgroups under the root. Defaults toFalse.format (
str, optional) – h5netcdf format string. Defaults toNone.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 toTrue.reindex_coord (
dict, optional) – Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked whendecode_coords=True. Defaults toNone(no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.site_coords (
bool, optional) – Attachlatitude/longitude/altitudeas coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults toTrue.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_parametersetc.) mapped to their datasets, ready forxarray.DataTree.from_dict().
- class xradar.io.IMDBackendEntrypoint[source]#
Bases:
BackendEntrypointXarray 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 sweepxarray.Dataset. To assemble a multi-sweep volume, useopen_imd_datatree()with a list of files.- Keyword Arguments:
first_dim (
str) – Can betimeorauto(default).autoselectsazimuth(PPI) orelevation(RHI) as the first dimension.reindex_coord (
dict, optional) – Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(). Defaults toNone(no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.site_as_coords (
bool) – If True (default), promotelatitude/longitude/altitudeto Dataset coordinates.
- description: ClassVar[str] = 'Open India Meteorological Department (IMD) radar NetCDF files in Xarray'#
- 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. Seeopen_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 (
boolordict-like, optional) – Replace fill values with NA and applyscale_factor/add_offsetdecoding. Seexarray.open_dataset(). Defaults toTrue.decode_times (
boolordict-like, optional) – Decode CF time variables (calendar, units) intonp.datetime64. Defaults toTrue.concat_characters (
boolordict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults toTrue.decode_coords (
boolor{"coordinates", "all"}, optional) – Decode the CFcoordinatesattribute. Defaults toTrue(equivalent to"coordinates").drop_variables (
stroriterableofstr, optional) – Names of variables to drop before processing.use_cftime (
bool, optional) – Forcecftimedecoding for time variables (instead ofnp.datetime64). Defaults toNone(auto).decode_timedelta (
bool, optional) – Decode CF timedelta variables. Default mirrorsdecode_timesunless the backend overrides it (cfradial1, cfradial2, and imd default toFalse).sweep (
int,str, orlistofint/str, optional) – Sweep selection.None(default) returns all sweeps. Anintor"sweep_N"string returns one sweep; a list returns the named subset.first_dim (
{"auto", "time"}, optional) – Leading dimension of each sweep dataset."auto"picksazimuth(PPI) orelevation(RHI);"time"keeps the raw time axis. Default"auto"("time"for cfradial2).optional_groups (
bool, optional) – Include the/radar_parameters,/georeferencing_correction, and/radar_calibrationmetadata subgroups under the root. Defaults toFalse.sweep (
int,strorlist, optional) – IMD files hold one sweep, so onlyNone,0or"sweep_0"are accepted. Defaults toNone.reindex_coord (
dict, optional) – Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked whendecode_coords=True. Defaults toNone(no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.site_coords (
bool, optional) – Attachlatitude/longitude/altitudeas coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults toTrue.
- Returns:
dict[str,xarray.Dataset]– CfRadial2 group paths (/,/sweep_N, optional/radar_parametersetc.) mapped to their datasets, ready forxarray.DataTree.from_dict().
- class xradar.io.IrisBackendEntrypoint[source]#
Bases:
BackendEntrypointXarray BackendEntrypoint for IRIS/Sigmet data.
- 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. Seeopen_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 (
boolordict-like, optional) – Replace fill values with NA and applyscale_factor/add_offsetdecoding. Seexarray.open_dataset(). Defaults toTrue.decode_times (
boolordict-like, optional) – Decode CF time variables (calendar, units) intonp.datetime64. Defaults toTrue.concat_characters (
boolordict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults toTrue.decode_coords (
boolor{"coordinates", "all"}, optional) – Decode the CFcoordinatesattribute. Defaults toTrue(equivalent to"coordinates").drop_variables (
stroriterableofstr, optional) – Names of variables to drop before processing.use_cftime (
bool, optional) – Forcecftimedecoding for time variables (instead ofnp.datetime64). Defaults toNone(auto).decode_timedelta (
bool, optional) – Decode CF timedelta variables. Default mirrorsdecode_timesunless the backend overrides it (cfradial1, cfradial2, and imd default toFalse).sweep (
int,str, orlistofint/str, optional) – Sweep selection.None(default) returns all sweeps. Anintor"sweep_N"string returns one sweep; a list returns the named subset.first_dim (
{"auto", "time"}, optional) – Leading dimension of each sweep dataset."auto"picksazimuth(PPI) orelevation(RHI);"time"keeps the raw time axis. Default"auto"("time"for cfradial2).optional (
bool, optional) – Include optional root variables when available. Defaults toTrue.optional_groups (
bool, optional) – Include the/radar_parameters,/georeferencing_correction, and/radar_calibrationmetadata subgroups under the root. Defaults toFalse.reindex_coord (
dict, optional) – Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked whendecode_coords=True. Defaults toNone(no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.fix_second_angle (
bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective withfirst_dim="auto". Defaults toFalse.site_coords (
bool, optional) – Attachlatitude/longitude/altitudeas coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults toTrue.lock (
threading.LockorNone, optional) – Reader lock for thread-safe access. Defaults toNone.
- Returns:
dict[str,xarray.Dataset]– CfRadial2 group paths (/,/sweep_N, optional/radar_parametersetc.) mapped to their datasets, ready forxarray.DataTree.from_dict().
- class xradar.io.MRRBackendEntrypoint[source]#
Bases:
BackendEntrypointXarray BackendEntrypoint for Metek MRR2 data.
- Keyword Arguments:
first_dim (
str) – Can betimeorautofirst dimension. If set toauto, first dimension will be eitherazimuthorelevationdepending on type of sweep. Defaults toauto.site_as_coords (
bool) – Attach radar site-coordinates to Dataset, defaults toTrue.kwargs (
dict) – Additional kwargs are fed toxarray.open_dataset().
- 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. Seeopen_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_0group 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 (
boolordict-like, optional) – Replace fill values with NA and applyscale_factor/add_offsetdecoding. Seexarray.open_dataset(). Defaults toTrue.decode_times (
boolordict-like, optional) – Decode CF time variables (calendar, units) intonp.datetime64. Defaults toTrue.concat_characters (
boolordict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults toTrue.decode_coords (
boolor{"coordinates", "all"}, optional) – Decode the CFcoordinatesattribute. Defaults toTrue(equivalent to"coordinates").drop_variables (
stroriterableofstr, optional) – Names of variables to drop before processing.use_cftime (
bool, optional) – Forcecftimedecoding for time variables (instead ofnp.datetime64). Defaults toNone(auto).decode_timedelta (
bool, optional) – Decode CF timedelta variables. Default mirrorsdecode_timesunless the backend overrides it (cfradial1, cfradial2, and imd default toFalse).sweep (
int,str, orlistofint/str, optional) – Sweep selection.None(default) returns all sweeps. Anintor"sweep_N"string returns one sweep; a list returns the named subset.first_dim (
{"auto", "time"}, optional) – Leading dimension of each sweep dataset."auto"picksazimuth(PPI) orelevation(RHI);"time"keeps the raw time axis. Default"auto"("time"for cfradial2).optional (
bool, optional) – Include optional root variables when available. Defaults toTrue.optional_groups (
bool, optional) – Include the/radar_parameters,/georeferencing_correction, and/radar_calibrationmetadata subgroups under the root. Defaults toFalse.format (
str, optional) – h5netcdf format string. Defaults toNone.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 toTrue.site_coords (
bool, optional) – Attachlatitude/longitude/altitudeas coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults toTrue.
- Returns:
dict[str,xarray.Dataset]– CfRadial2 group paths (/,/sweep_N, optional/radar_parametersetc.) mapped to their datasets, ready forxarray.DataTree.from_dict().
- class xradar.io.NexradLevel2BackendEntrypoint[source]#
Bases:
BackendEntrypointXarray BackendEntrypoint for NEXRAD Level2 Data
- 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. Seeopen_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 (
boolordict-like, optional) – Replace fill values with NA and applyscale_factor/add_offsetdecoding. Seexarray.open_dataset(). Defaults toTrue.decode_times (
boolordict-like, optional) – Decode CF time variables (calendar, units) intonp.datetime64. Defaults toTrue.concat_characters (
boolordict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults toTrue.decode_coords (
boolor{"coordinates", "all"}, optional) – Decode the CFcoordinatesattribute. Defaults toTrue(equivalent to"coordinates").drop_variables (
stroriterableofstr, optional) – Names of variables to drop before processing.use_cftime (
bool, optional) – Forcecftimedecoding for time variables (instead ofnp.datetime64). Defaults toNone(auto).decode_timedelta (
bool, optional) – Decode CF timedelta variables. Default mirrorsdecode_timesunless the backend overrides it (cfradial1, cfradial2, and imd default toFalse).sweep (
int,str, orlistofint/str, optional) – Sweep selection.None(default) returns all sweeps. Anintor"sweep_N"string returns one sweep; a list returns the named subset.first_dim (
{"auto", "time"}, optional) – Leading dimension of each sweep dataset."auto"picksazimuth(PPI) orelevation(RHI);"time"keeps the raw time axis. Default"auto"("time"for cfradial2).optional (
bool, optional) – Include optional root variables when available. Defaults toTrue.optional_groups (
bool, optional) – Include the/radar_parameters,/georeferencing_correction, and/radar_calibrationmetadata subgroups under the root. Defaults toFalse.reindex_coord (
dict, optional) – Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked whendecode_coords=True. Defaults toNone(no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.fix_second_angle (
bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective withfirst_dim="auto". Defaults toFalse.site_coords (
bool, optional) – Attachlatitude/longitude/altitudeas coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults toTrue.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.LockorNone, optional) – Reader lock for thread-safe access. Defaults toNone.
- Returns:
dict[str,xarray.Dataset]– CfRadial2 group paths (/,/sweep_N, optional/radar_parametersetc.) mapped to their datasets, ready forxarray.DataTree.from_dict().
- class xradar.io.OdimBackendEntrypoint[source]#
Bases:
BackendEntrypointXarray BackendEntrypoint for ODIM data.
- Keyword Arguments:
first_dim (
str) – Can betimeorautofirst dimension. If set toauto, first dimension will be eitherazimuthorelevationdepending on type of sweep. Defaults toauto.reindex_coord (
dict, optional) – Defaults to None, no reindexing. Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked ifdecode_coords=True.reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.fix_second_angle (
bool) – If True, fixes erroneous second angle data. Defaults toFalse.site_as_coords (
bool) – Attach radar site-coordinates to Dataset, defaults toTrue.kwargs (
dict) – Additional kwargs are fed toxarray.open_dataset().
- 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, soclose()releases it. Seeopen_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 (
boolordict-like, optional) – Replace fill values with NA and applyscale_factor/add_offsetdecoding. Seexarray.open_dataset(). Defaults toTrue.decode_times (
boolordict-like, optional) – Decode CF time variables (calendar, units) intonp.datetime64. Defaults toTrue.concat_characters (
boolordict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults toTrue.decode_coords (
boolor{"coordinates", "all"}, optional) – Decode the CFcoordinatesattribute. Defaults toTrue(equivalent to"coordinates").drop_variables (
stroriterableofstr, optional) – Names of variables to drop before processing.use_cftime (
bool, optional) – Forcecftimedecoding for time variables (instead ofnp.datetime64). Defaults toNone(auto).decode_timedelta (
bool, optional) – Decode CF timedelta variables. Default mirrorsdecode_timesunless the backend overrides it (cfradial1, cfradial2, and imd default toFalse).sweep (
int,str, orlistofint/str, optional) – Sweep selection.None(default) returns all sweeps. Anintor"sweep_N"string returns one sweep; a list returns the named subset.first_dim (
{"auto", "time"}, optional) – Leading dimension of each sweep dataset."auto"picksazimuth(PPI) orelevation(RHI);"time"keeps the raw time axis. Default"auto"("time"for cfradial2).optional (
bool, optional) – Include optional root variables when available. Defaults toTrue.optional_groups (
bool, optional) – Include the/radar_parameters,/georeferencing_correction, and/radar_calibrationmetadata subgroups under the root. Defaults toFalse.format (
str, optional) – h5netcdf format string. Defaults toNone.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 toTrue.reindex_coord (
dict, optional) – Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked whendecode_coords=True. Defaults toNone(no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.fix_second_angle (
bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective withfirst_dim="auto". Defaults toFalse.site_coords (
bool, optional) – Attachlatitude/longitude/altitudeas coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults toTrue.
- Returns:
dict[str,xarray.Dataset]– CfRadial2 group paths (/,/sweep_N, optional/radar_parametersetc.) mapped to their datasets, ready forxarray.DataTree.from_dict().
- class xradar.io.RainbowBackendEntrypoint[source]#
Bases:
BackendEntrypointXarray BackendEntrypoint for Rainbow5 data.
- 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. Seeopen_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 (
boolordict-like, optional) – Replace fill values with NA and applyscale_factor/add_offsetdecoding. Seexarray.open_dataset(). Defaults toTrue.decode_times (
boolordict-like, optional) – Decode CF time variables (calendar, units) intonp.datetime64. Defaults toTrue.concat_characters (
boolordict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults toTrue.decode_coords (
boolor{"coordinates", "all"}, optional) – Decode the CFcoordinatesattribute. Defaults toTrue(equivalent to"coordinates").drop_variables (
stroriterableofstr, optional) – Names of variables to drop before processing.use_cftime (
bool, optional) – Forcecftimedecoding for time variables (instead ofnp.datetime64). Defaults toNone(auto).decode_timedelta (
bool, optional) – Decode CF timedelta variables. Default mirrorsdecode_timesunless the backend overrides it (cfradial1, cfradial2, and imd default toFalse).sweep (
int,str, orlistofint/str, optional) – Sweep selection.None(default) returns all sweeps. Anintor"sweep_N"string returns one sweep; a list returns the named subset.first_dim (
{"auto", "time"}, optional) – Leading dimension of each sweep dataset."auto"picksazimuth(PPI) orelevation(RHI);"time"keeps the raw time axis. Default"auto"("time"for cfradial2).optional (
bool, optional) – Include optional root variables when available. Defaults toTrue.optional_groups (
bool, optional) – Include the/radar_parameters,/georeferencing_correction, and/radar_calibrationmetadata subgroups under the root. Defaults toFalse.reindex_coord (
dict, optional) – Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked whendecode_coords=True. Defaults toNone(no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.site_coords (
bool, optional) – Attachlatitude/longitude/altitudeas coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults toTrue.
- Returns:
dict[str,xarray.Dataset]– CfRadial2 group paths (/,/sweep_N, optional/radar_parametersetc.) mapped to their datasets, ready forxarray.DataTree.from_dict().
- class xradar.io.UFBackendEntrypoint[source]#
Bases:
BackendEntrypointXarray BackendEntrypoint for Universal Format (UF) data.
- 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. Seeopen_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 (
boolordict-like, optional) – Replace fill values with NA and applyscale_factor/add_offsetdecoding. Seexarray.open_dataset(). Defaults toTrue.decode_times (
boolordict-like, optional) – Decode CF time variables (calendar, units) intonp.datetime64. Defaults toTrue.concat_characters (
boolordict-like, optional) – Concatenate character arrays into strings along their trailing dimension. Defaults toTrue.decode_coords (
boolor{"coordinates", "all"}, optional) – Decode the CFcoordinatesattribute. Defaults toTrue(equivalent to"coordinates").drop_variables (
stroriterableofstr, optional) – Names of variables to drop before processing.use_cftime (
bool, optional) – Forcecftimedecoding for time variables (instead ofnp.datetime64). Defaults toNone(auto).decode_timedelta (
bool, optional) – Decode CF timedelta variables. Default mirrorsdecode_timesunless the backend overrides it (cfradial1, cfradial2, and imd default toFalse).sweep (
int,str, orlistofint/str, optional) – Sweep selection.None(default) returns all sweeps. Anintor"sweep_N"string returns one sweep; a list returns the named subset.first_dim (
{"auto", "time"}, optional) – Leading dimension of each sweep dataset."auto"picksazimuth(PPI) orelevation(RHI);"time"keeps the raw time axis. Default"auto"("time"for cfradial2).optional (
bool, optional) – Include optional root variables when available. Defaults toTrue.optional_groups (
bool, optional) – Include the/radar_parameters,/georeferencing_correction, and/radar_calibrationmetadata subgroups under the root. Defaults toFalse.reindex_coord (
dict, optional) – Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked whendecode_coords=True. Defaults toNone(no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.fix_second_angle (
bool, optional) – Correct erroneous secondary-angle values (azimuth on RHI, elevation on PPI). Only effective withfirst_dim="auto". Defaults toFalse.site_coords (
bool, optional) – Attachlatitude/longitude/altitudeas coordinates on the root dataset (and on per-sweep datasets where the backend supports it). Defaults toTrue.lock (
threading.LockorNone, optional) – Reader lock for thread-safe access. Defaults toNone.
- Returns:
dict[str,xarray.Dataset]– CfRadial2 group paths (/,/sweep_N, optional/radar_parametersetc.) mapped to their datasets, ready forxarray.DataTree.from_dict().
- 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.AR2Vfor NEXRAD Level II,ODIM_H5conventions in HDF5 files), seelist_xradar_engines().- Parameters:
filename_or_obj (
str,os.PathLike,bytesor 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, oriterableofthose) –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.open_cfradial1_datatree(filename_or_obj, **kwargs)[source]#
Open CfRadial1 dataset as
xarray.DataTree.Deprecated since version Use:
xd.open_datatree(file, engine="cfradial1")orxr.open_datatree(file, engine="cfradial1")instead.- Parameters:
filename_or_obj (
str,Path, file-like orxarray.DataStore) – Strings and Path objects are interpreted as a path to a local or remote radar file- Keyword Arguments:
sweep (
int,listofint, optional) – Sweep number(s) to extract, default to first sweep. If None, all sweeps are extracted into a list.first_dim (
str) – Can betimeorautofirst dimension. If set toauto, first dimension will be eitherazimuthorelevationdepending on type of sweep. Defaults toauto.reindex_coord (
dict, optional) – Defaults to None, no reindexing. Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked ifdecode_coords=True.reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.fix_second_angle (
bool) – If True, fixes erroneous second angle data. Defaults toFalse.optional (
bool) – Import optional mandatory data and metadata, defaults toTrue.site_as_coords (
bool) – Attach radar site-coordinates to Dataset, defaults toTrue.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")orxr.open_datatree(file, engine="cfradial2")instead.- Parameters:
filename_or_obj (
strorPathLike) – Path or object understood byxarray.open_datatree().- Keyword Arguments:
sweep (
int,str,iterable, optional) – Sweep selection. Defaults to all available sweeps.first_dim (
str) – Can betimeorauto. Defaults totime.optional (
bool) – Keep optional root variables when available. Defaults toTrue.optional_groups (
bool) – Include root metadata subgroups if present. Defaults toFalse.**kwargs (
dict) – Additional keyword arguments passed toxarray.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
engineor, without it, the one found byxradar.io.discover_engine(). This works for all radar formats, including the netCDF/HDF5 based ones (ODIM_H5, GAMIC, CfRadial) whichxarray.open_datatree()withoutenginehands 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 argumentstime_coverage_start,time_coverage_end,min_angle,max_angleandvolume_numberofxradar.util.create_volume()select and label the sweeps, all other arguments are used for each file.- Parameters:
filename_or_obj (
str,Path, file-like orlistofstrorPath) – 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 withxradar.io.discover_engine()(raisesValueErrorif no xradar engine can open it).**kwargs – Keyword arguments for
xarray.open_datatree(): xarray options such aschunksorcache, and the backend options documented on the engine’sopen_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 supportstime_coverage_start,time_coverage_end,min_angle,max_anglefiltering.
Note
When opening a single IMD sweep file as a DataTree, prefer
xd.open_datatree(file, engine="imd")(or the xarray-nativexr.open_datatree(file, engine="imd")). This function remains the documented API for the multi-file path because IMD volumes span multiple files, which theengine="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, orlist/tupleofthose) – 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 keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range().reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.site_as_coords (
bool) – Attach station variables as coordinates on sweep Datasets.site_coordsis accepted as an alias.optional_groups (
bool) – Include/radar_parameters,/georeferencing_correctionand/radar_calibrationsubgroups. Defaults toFalse. With multiple files the values the files disagree about are left out of the groups, with aUserWarning.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 andsweep_Nchildren.
- 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 viaopen_imd_datatree(), and nests them under zero-paddedvcp_NNchild nodes of a parent root.vcpstands 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, oriterableofthose) – Same asgroup_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, :keywordoptional_groups,min_angle,max_angle.:- Returns:
dtree (
xarray.DataTree) –Root with
vcp_NNchildren, 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, orDataStore) – 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. Usemask_and_scale=Falseto 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 (
strorlistofstr, 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 (
intorlistofint, 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 keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(). Only used if decode_coords=True. Default is None (no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_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_correctionand/radar_calibrationmetadata 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")orxr.open_datatree(file, engine="odim")instead.- Parameters:
filename_or_obj (
str,Path, file-like orDataStore) – Strings and Path objects are interpreted as a path to a local or remote radar file- Keyword Arguments:
sweep (
int,listofint, optional) – Sweep number(s) to extract, default to first sweep. If None, all sweeps are extracted into a list.first_dim (
str) – Can betimeorautofirst dimension. If set toauto, first dimension will be eitherazimuthorelevationdepending on type of sweep. Defaults toauto.reindex_coord (
dict, optional) – Defaults to None, no reindexing. Nested dict with optional keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(), e.g.dict(angle=dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1)). Only invoked ifdecode_coords=True.reindex_angle (
dict, optional) – Deprecated, usereindex_coord=dict(angle=...)instead.fix_second_angle (
bool) – If True, fixes erroneous second angle data. Defaults toFalse.site_as_coords (
bool) – Attach radar site-coordinates to Dataset, defaults toTrue.kwargs (
dict) – Additional kwargs are fed toxarray.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, orDataStore) – 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 (
strorlistofstr, 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 (
intorlistofint, 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 keysangleandrangeholding the kwargs forxradar.util.reindex_angle()andxradar.util.reindex_range(). Only used if decode_coords=True. Default is None (no reindexing).reindex_angle (
dict, optional) – Deprecated, usereindex_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_correctionand/radar_calibrationmetadata groups. Default is False.lock (
threading.LockorNone, optional) – Lock used when reading the file. Default is None (the UF lock).kwargs (
dict) – Additional keyword arguments passed toxarray.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 onerange(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-Drange(sweep, range)with the attributesmeters_to_center_of_first_gateandmeters_between_gatesper 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-Drangeis 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 usedengine (
str) – Either netcdf4 or h5netcdf.deepcopy (
bool) – If True, work on a deep copy ofdtree(the data is duplicated in memory). If False (default), work on a shallow copy, which shares the underlying data arrays withdtreebut 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:
dtree (
xarray.DataTree)filename (
str) – output filename
- Keyword Arguments:
source (
str, optional) – Radar identifiers forwhat/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 Falsecompression (
str) – Compression filter name, defaults to “gzip”.compression_opts (
compression strategy) – options as needed by above filter, defaults to 6