Universal Format (UF)#
import cmweather # noqa
import xarray as xr
from open_radar_data import DATASETS
import xradar as xd
Download#
Fetching Universal Format radar data file from open-radar-data repository.
import atexit
from pathlib import Path
from tempfile import TemporaryDirectory
tmpdir_obj = TemporaryDirectory()
atexit.register(tmpdir_obj.cleanup) # remove even if you forget
tmpdir = Path(tmpdir_obj.name)
def get_temp_file(fname):
import gzip
import shutil
fnamei = Path(DATASETS.fetch(fname))
fnameo = tmpdir / fnamei.stem
with gzip.open(fnamei) as fin:
with open(fnameo, "wb") as fout:
shutil.copyfileobj(fin, fout)
fout.flush()
fout.close()
return fnameo
fname = get_temp_file("20110427_164233_rvp8-rel_v001_SUR.uf.gz")
xr.open_dataset#
Making use of the xarray uf backend. We also need to provide the group. Note, that we are using CfRadial2 group access pattern.
ds = xr.open_dataset(fname, group="sweep_0", engine="uf")
display(ds)
<xarray.Dataset> Size: 23MB
Dimensions: (azimuth: 318, range: 997)
Coordinates:
* azimuth (azimuth) float64 3kB 22.88 23.88 24.91 ... 338.9 339.9
elevation (azimuth) float64 3kB ...
time (azimuth) datetime64[us] 3kB ...
* range (range) float32 4kB -436.5 -311.5 ... 1.239e+05 1.241e+05
longitude float64 8B ...
latitude float64 8B ...
altitude int64 8B ...
Data variables: (12/14)
DBZH (azimuth, range) float64 3MB ...
DBTH (azimuth, range) float64 3MB ...
VRADH (azimuth, range) float64 3MB ...
WRADH (azimuth, range) float64 3MB ...
ZDR (azimuth, range) float64 3MB ...
KDP (azimuth, range) float64 3MB ...
... ...
RHOHV (azimuth, range) float64 3MB ...
sweep_mode <U20 80B ...
sweep_number int64 8B ...
prt_mode <U7 28B ...
follow_mode <U7 28B ...
sweep_fixed_angle float64 8B ...
Attributes:
source: Sigmet/UF
site_name: MAX
instrument_name: rvp8-rel
comment: Sigmet Iimport numpy as np
np.testing.assert_almost_equal(ds.sweep_fixed_angle.values, 0.703125)
Plot Time vs. Azimuth#
ds.azimuth.plot()
[<matplotlib.lines.Line2D at 0x7991431765d0>]
Plot Range vs. Time#
We need to sort by time and specify the y-coordinate.
ds.DBZH.sortby("time").plot(y="time", cmap="HomeyerRainbow")
<matplotlib.collections.QuadMesh at 0x79914302a120>
Plot Range vs. Azimuth#
ds.DBZH.plot(cmap="HomeyerRainbow")
<matplotlib.collections.QuadMesh at 0x79913ad06ad0>
backend_kwargs#
Beside first_dim there are several additional backend_kwargs for the uf backend, which handle different aspects of angle alignment. This comes into play, when azimuth and/or elevation arrays are not evenly spacend and other issues.
help(xd.io.UFBackendEntrypoint)
Help on class UFBackendEntrypoint in module xradar.io.backends.uf:
class UFBackendEntrypoint(xarray.backends.common.BackendEntrypoint)
| Xarray BackendEntrypoint for Universal Format (UF) data.
|
| Method resolution order:
| UFBackendEntrypoint
| xarray.backends.common.BackendEntrypoint
| builtins.object
|
| Methods defined here:
|
| guess_can_open(self, filename_or_obj)
| Universal Format, ``UF`` at the start of the first record.
|
| open_dataset(
| self,
| 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
| )
| Backend open_dataset method used by Xarray in :py:func:`~xarray.open_dataset`.
|
| open_datatree(self, filename_or_obj, **kwargs)
| Open a Universal Format (UF) file as :py:class:`xarray.DataTree`. See :meth:`open_groups_as_dict` for keyword arguments.
|
| open_groups_as_dict(
| self,
| 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
| )
| Open a Universal Format (UF) file as a CfRadial2-shaped dict of group datasets.
|
| Parameters
| ----------
| filename_or_obj : str, Path, or file-like
| Path or file-like object understood by the underlying reader.
| mask_and_scale : bool or dict-like, optional
| Replace fill values with NA and apply ``scale_factor``/``add_offset``
| decoding. See :py:func:`xarray.open_dataset`. Defaults to ``True``.
| decode_times : bool or dict-like, optional
| Decode CF time variables (calendar, units) into ``np.datetime64``.
| Defaults to ``True``.
| concat_characters : bool or dict-like, optional
| Concatenate character arrays into strings along their trailing
| dimension. Defaults to ``True``.
| decode_coords : bool or {"coordinates", "all"}, optional
| Decode the CF ``coordinates`` attribute. Defaults to ``True``
| (equivalent to ``"coordinates"``).
| drop_variables : str or iterable of str, optional
| Names of variables to drop before processing.
| use_cftime : bool, optional
| Force ``cftime`` decoding for time variables (instead of
| ``np.datetime64``). Defaults to ``None`` (auto).
| decode_timedelta : bool, optional
| Decode CF timedelta variables. Default mirrors ``decode_times``
| unless the backend overrides it (cfradial1, cfradial2, and imd
| default to ``False``).
| sweep : int, str, or list of int/str, optional
| Sweep selection. ``None`` (default) returns all sweeps. An ``int``
| or ``"sweep_N"`` string returns one sweep; a list returns the
| named subset.
| first_dim : {"auto", "time"}, optional
| Leading dimension of each sweep dataset. ``"auto"`` picks
| ``azimuth`` (PPI) or ``elevation`` (RHI); ``"time"`` keeps the
| raw time axis. Default ``"auto"`` (``"time"`` for cfradial2).
| optional : bool, optional
| Include optional root variables when available. Defaults to ``True``.
| optional_groups : bool, optional
| Include the ``/radar_parameters``, ``/georeferencing_correction``,
| and ``/radar_calibration`` metadata subgroups under the root.
| Defaults to ``False``.
| reindex_coord : dict, optional
| Nested dict with optional keys ``angle`` and ``range`` holding the
| kwargs for :func:`xradar.util.reindex_angle` and
| :func:`xradar.util.reindex_range`, e.g. ``dict(angle=dict(start_angle=0,
| stop_angle=360, angle_res=1.0, direction=1))``. Only invoked when
| ``decode_coords=True``. Defaults to ``None`` (no reindexing).
| reindex_angle : dict, optional
| Deprecated, use ``reindex_coord=dict(angle=...)`` instead.
| fix_second_angle : bool, optional
| Correct erroneous secondary-angle values (azimuth on RHI,
| elevation on PPI). Only effective with ``first_dim="auto"``.
| Defaults to ``False``.
| site_coords : bool, optional
| Attach ``latitude``/``longitude``/``altitude`` as coordinates on
| the root dataset (and on per-sweep datasets where the backend
| supports it). Defaults to ``True``.
| lock : threading.Lock or None, optional
| Reader lock for thread-safe access. Defaults to ``None``.
|
| Returns
| -------
| dict[str, xarray.Dataset]
| CfRadial2 group paths (``/``, ``/sweep_N``, optional
| ``/radar_parameters`` etc.) mapped to their datasets,
| ready for :py:meth:`xarray.DataTree.from_dict`.
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __annotations__ = {}
|
| description = 'Open Universal Format (UF) files in Xarray'
|
| open_dataset_parameters = ('filename_or_obj', 'mask_and_scale', 'decod...
|
| supports_groups = True
|
| url = 'https://xradar.rtfd.io/latest/io.html#uf-data-i-o'
|
| ----------------------------------------------------------------------
| Methods inherited from xarray.backends.common.BackendEntrypoint:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from xarray.backends.common.BackendEntrypoint:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
ds = xr.open_dataset(fname, group="sweep_0", engine="uf", first_dim="time")
display(ds)
<xarray.Dataset> Size: 23MB
Dimensions: (time: 318, range: 997)
Coordinates:
* time (time) datetime64[us] 3kB 2011-04-27T16:42:32.749970 ....
azimuth (time) float64 3kB ...
elevation (time) float64 3kB ...
* range (range) float32 4kB -436.5 -311.5 ... 1.239e+05 1.241e+05
longitude float64 8B ...
latitude float64 8B ...
altitude int64 8B ...
Data variables: (12/14)
DBZH (time, range) float64 3MB ...
DBTH (time, range) float64 3MB ...
VRADH (time, range) float64 3MB ...
WRADH (time, range) float64 3MB ...
ZDR (time, range) float64 3MB ...
KDP (time, range) float64 3MB ...
... ...
RHOHV (time, range) float64 3MB ...
sweep_mode <U20 80B ...
sweep_number int64 8B ...
prt_mode <U7 28B ...
follow_mode <U7 28B ...
sweep_fixed_angle float64 8B ...
Attributes:
source: Sigmet/UF
site_name: MAX
instrument_name: rvp8-rel
comment: Sigmet Iopen_uf_datatree#
The same works analoguous with the datatree loader. But additionally we can provide a sweep string, number or list.
help(xd.open_datatree)
Help on function open_datatree in module xradar.io:
open_datatree(filename_or_obj, *, engine=None, **kwargs)
Open a radar file as :py:class:`xarray.DataTree`.
The engine is the given ``engine`` or, without it, the one found by
:func:`xradar.io.discover_engine`. This works for all radar formats,
including the netCDF/HDF5 based ones (ODIM_H5, GAMIC, CfRadial) which
:py:func:`xarray.open_datatree` without ``engine`` hands to xarray's own
netCDF/HDF5 backends.
A list of files is stacked into one volume (see
:func:`xradar.util.create_volume`): this is for formats which write one
sweep per file, e.g. IMD or IRIS/Sigmet files of single sweeps. All files
need the same engine, the sweeps of all files are sorted by time and
numbered in this order. The keyword arguments ``time_coverage_start``,
``time_coverage_end``, ``min_angle``, ``max_angle`` and ``volume_number``
of :func:`xradar.util.create_volume` select and label the sweeps, all other
arguments are used for each file.
Parameters
----------
filename_or_obj : str, Path, file-like or list of str or Path
Path to the radar file, or the paths of files with one sweep each.
engine : str, optional
Backend engine name (e.g., ``"odim"``, ``"cfradial1"``, ``"nexradlevel2"``).
Default is to discover the engine from the file with
:func:`xradar.io.discover_engine` (raises ``ValueError`` if no xradar
engine can open it).
**kwargs
Keyword arguments for :py:func:`xarray.open_datatree`: xarray options
such as ``chunks`` or ``cache``, and the backend options documented on
the engine's ``open_groups_as_dict`` (``sweep``, ``first_dim``, ...).
Returns
-------
dtree : xarray.DataTree
DataTree with CfRadial2 group structure.
Examples
--------
>>> import xradar as xd
>>> dtree = xd.open_datatree("file.h5", engine="odim")
>>> dtree = xd.open_datatree("file.h5") # engine discovered
>>> volume = xd.open_datatree(["sweep_1.nc", "sweep_2.nc"]) # stacked sweeps
dtree = xd.open_datatree(fname, engine="uf", sweep=4)
display(dtree)
<xarray.DataTree>
Group: /
│ Dimensions: ()
│ Coordinates:
│ longitude float64 8B ...
│ altitude int64 8B ...
│ latitude float64 8B ...
│ Data variables:
│ volume_number int64 8B ...
│ platform_type <U5 20B ...
│ instrument_type <U5 20B ...
│ time_coverage_start <U20 80B ...
│ time_coverage_end <U20 80B ...
│ Attributes:
│ Conventions: None
│ instrument_name: rvp8-rel
│ version: None
│ title: None
│ institution: None
│ references: None
│ source: Sigmet/UF
│ history: None
│ comment: Sigmet I
│ site_name: MAX
└── Group: /sweep_4
Dimensions: (azimuth: 318, range: 997)
Coordinates:
* azimuth (azimuth) float64 3kB 22.86 23.86 24.88 ... 338.9 339.9
elevation (azimuth) float64 3kB ...
time (azimuth) datetime64[us] 3kB ...
* range (range) float32 4kB -436.5 -311.5 ... 1.239e+05 1.241e+05
Data variables: (12/14)
DBZH (azimuth, range) float64 3MB ...
DBTH (azimuth, range) float64 3MB ...
VRADH (azimuth, range) float64 3MB ...
WRADH (azimuth, range) float64 3MB ...
ZDR (azimuth, range) float64 3MB ...
KDP (azimuth, range) float64 3MB ...
... ...
RHOHV (azimuth, range) float64 3MB ...
sweep_mode <U20 80B ...
sweep_number int64 8B ...
prt_mode <U7 28B ...
follow_mode <U7 28B ...
sweep_fixed_angle float64 8B ...Plot Sweep Range vs. Time#
dtree["sweep_4"].ds.DBZH.sortby("time").plot(y="time", cmap="HomeyerRainbow")
<matplotlib.collections.QuadMesh at 0x799143c11590>
Plot Sweep Range vs. Azimuth#
dtree["sweep_4"].ds.DBZH.plot(cmap="HomeyerRainbow")
<matplotlib.collections.QuadMesh at 0x79912851a710>
dtree = xd.open_datatree(fname, engine="uf", sweep="sweep_8")
display(dtree)
<xarray.DataTree>
Group: /
│ Dimensions: ()
│ Coordinates:
│ longitude float64 8B ...
│ altitude int64 8B ...
│ latitude float64 8B ...
│ Data variables:
│ volume_number int64 8B ...
│ platform_type <U5 20B ...
│ instrument_type <U5 20B ...
│ time_coverage_start <U20 80B ...
│ time_coverage_end <U20 80B ...
│ Attributes:
│ Conventions: None
│ instrument_name: rvp8-rel
│ version: None
│ title: None
│ institution: None
│ references: None
│ source: Sigmet/UF
│ history: None
│ comment: Sigmet I
│ site_name: MAX
└── Group: /sweep_8
Dimensions: (azimuth: 329, range: 919)
Coordinates:
* azimuth (azimuth) float64 3kB 0.875 1.875 21.88 ... 358.9 359.9
elevation (azimuth) float64 3kB ...
time (azimuth) datetime64[us] 3kB ...
* range (range) float32 4kB -436.5 -311.5 ... 1.142e+05 1.143e+05
Data variables: (12/14)
DBZH (azimuth, range) float64 2MB ...
DBTH (azimuth, range) float64 2MB ...
VRADH (azimuth, range) float64 2MB ...
WRADH (azimuth, range) float64 2MB ...
ZDR (azimuth, range) float64 2MB ...
KDP (azimuth, range) float64 2MB ...
... ...
RHOHV (azimuth, range) float64 2MB ...
sweep_mode <U20 80B ...
sweep_number int64 8B ...
prt_mode <U7 28B ...
follow_mode <U7 28B ...
sweep_fixed_angle float64 8B ...dtree = xd.open_datatree(fname, engine="uf", sweep=[0, 1, 8])
display(dtree)
<xarray.DataTree>
Group: /
│ Dimensions: ()
│ Coordinates:
│ longitude float64 8B ...
│ altitude int64 8B ...
│ latitude float64 8B ...
│ Data variables:
│ volume_number int64 8B ...
│ platform_type <U5 20B ...
│ instrument_type <U5 20B ...
│ time_coverage_start <U20 80B ...
│ time_coverage_end <U20 80B ...
│ Attributes:
│ Conventions: None
│ instrument_name: rvp8-rel
│ version: None
│ title: None
│ institution: None
│ references: None
│ source: Sigmet/UF
│ history: None
│ comment: Sigmet I
│ site_name: MAX
├── Group: /sweep_0
│ Dimensions: (azimuth: 318, range: 997)
│ Coordinates:
│ * azimuth (azimuth) float64 3kB 22.88 23.88 24.91 ... 338.9 339.9
│ elevation (azimuth) float64 3kB ...
│ time (azimuth) datetime64[us] 3kB ...
│ * range (range) float32 4kB -436.5 -311.5 ... 1.239e+05 1.241e+05
│ Data variables: (12/14)
│ DBZH (azimuth, range) float64 3MB ...
│ DBTH (azimuth, range) float64 3MB ...
│ VRADH (azimuth, range) float64 3MB ...
│ WRADH (azimuth, range) float64 3MB ...
│ ZDR (azimuth, range) float64 3MB ...
│ KDP (azimuth, range) float64 3MB ...
│ ... ...
│ RHOHV (azimuth, range) float64 3MB ...
│ sweep_mode <U20 80B ...
│ sweep_number int64 8B ...
│ prt_mode <U7 28B ...
│ follow_mode <U7 28B ...
│ sweep_fixed_angle float64 8B ...
├── Group: /sweep_1
│ Dimensions: (azimuth: 319, range: 997)
│ Coordinates:
│ * azimuth (azimuth) float64 3kB 21.88 22.86 23.89 ... 338.9 339.9
│ elevation (azimuth) float64 3kB ...
│ time (azimuth) datetime64[us] 3kB ...
│ * range (range) float32 4kB -436.5 -311.5 ... 1.239e+05 1.241e+05
│ Data variables: (12/14)
│ DBZH (azimuth, range) float64 3MB ...
│ DBTH (azimuth, range) float64 3MB ...
│ VRADH (azimuth, range) float64 3MB ...
│ WRADH (azimuth, range) float64 3MB ...
│ ZDR (azimuth, range) float64 3MB ...
│ KDP (azimuth, range) float64 3MB ...
│ ... ...
│ RHOHV (azimuth, range) float64 3MB ...
│ sweep_mode <U20 80B ...
│ sweep_number int64 8B ...
│ prt_mode <U7 28B ...
│ follow_mode <U7 28B ...
│ sweep_fixed_angle float64 8B ...
└── Group: /sweep_8
Dimensions: (azimuth: 329, range: 919)
Coordinates:
* azimuth (azimuth) float64 3kB 0.875 1.875 21.88 ... 358.9 359.9
elevation (azimuth) float64 3kB ...
time (azimuth) datetime64[us] 3kB ...
* range (range) float32 4kB -436.5 -311.5 ... 1.142e+05 1.143e+05
Data variables: (12/14)
DBZH (azimuth, range) float64 2MB ...
DBTH (azimuth, range) float64 2MB ...
VRADH (azimuth, range) float64 2MB ...
WRADH (azimuth, range) float64 2MB ...
ZDR (azimuth, range) float64 2MB ...
KDP (azimuth, range) float64 2MB ...
... ...
RHOHV (azimuth, range) float64 2MB ...
sweep_mode <U20 80B ...
sweep_number int64 8B ...
prt_mode <U7 28B ...
follow_mode <U7 28B ...
sweep_fixed_angle float64 8B ...dtree["sweep_0"]["sweep_fixed_angle"].values
array(0.703125)
dtree["sweep_8"]["sweep_fixed_angle"].values
array(10.)
dtree = xd.open_datatree(fname, engine="uf")
display(dtree)
<xarray.DataTree>
Group: /
│ Dimensions: ()
│ Coordinates:
│ longitude float64 8B ...
│ altitude int64 8B ...
│ latitude float64 8B ...
│ Data variables:
│ volume_number int64 8B ...
│ platform_type <U5 20B ...
│ instrument_type <U5 20B ...
│ time_coverage_start <U20 80B ...
│ time_coverage_end <U20 80B ...
│ Attributes:
│ Conventions: None
│ instrument_name: rvp8-rel
│ version: None
│ title: None
│ institution: None
│ references: None
│ source: Sigmet/UF
│ history: None
│ comment: Sigmet I
│ site_name: MAX
├── Group: /sweep_0
│ Dimensions: (azimuth: 318, range: 997)
│ Coordinates:
│ * azimuth (azimuth) float64 3kB 22.88 23.88 24.91 ... 338.9 339.9
│ elevation (azimuth) float64 3kB ...
│ time (azimuth) datetime64[us] 3kB ...
│ * range (range) float32 4kB -436.5 -311.5 ... 1.239e+05 1.241e+05
│ Data variables: (12/14)
│ DBZH (azimuth, range) float64 3MB ...
│ DBTH (azimuth, range) float64 3MB ...
│ VRADH (azimuth, range) float64 3MB ...
│ WRADH (azimuth, range) float64 3MB ...
│ ZDR (azimuth, range) float64 3MB ...
│ KDP (azimuth, range) float64 3MB ...
│ ... ...
│ RHOHV (azimuth, range) float64 3MB ...
│ sweep_mode <U20 80B ...
│ sweep_number int64 8B ...
│ prt_mode <U7 28B ...
│ follow_mode <U7 28B ...
│ sweep_fixed_angle float64 8B ...
├── Group: /sweep_1
│ Dimensions: (azimuth: 319, range: 997)
│ Coordinates:
│ * azimuth (azimuth) float64 3kB 21.88 22.86 23.89 ... 338.9 339.9
│ elevation (azimuth) float64 3kB ...
│ time (azimuth) datetime64[us] 3kB ...
│ * range (range) float32 4kB -436.5 -311.5 ... 1.239e+05 1.241e+05
│ Data variables: (12/14)
│ DBZH (azimuth, range) float64 3MB ...
│ DBTH (azimuth, range) float64 3MB ...
│ VRADH (azimuth, range) float64 3MB ...
│ WRADH (azimuth, range) float64 3MB ...
│ ZDR (azimuth, range) float64 3MB ...
│ KDP (azimuth, range) float64 3MB ...
│ ... ...
│ RHOHV (azimuth, range) float64 3MB ...
│ sweep_mode <U20 80B ...
│ sweep_number int64 8B ...
│ prt_mode <U7 28B ...
│ follow_mode <U7 28B ...
│ sweep_fixed_angle float64 8B ...
├── Group: /sweep_2
│ Dimensions: (azimuth: 319, range: 997)
│ Coordinates:
│ * azimuth (azimuth) float64 3kB 21.88 22.88 23.89 ... 338.9 339.9
│ elevation (azimuth) float64 3kB ...
│ time (azimuth) datetime64[us] 3kB ...
│ * range (range) float32 4kB -436.5 -311.5 ... 1.239e+05 1.241e+05
│ Data variables: (12/14)
│ DBZH (azimuth, range) float64 3MB ...
│ DBTH (azimuth, range) float64 3MB ...
│ VRADH (azimuth, range) float64 3MB ...
│ WRADH (azimuth, range) float64 3MB ...
│ ZDR (azimuth, range) float64 3MB ...
│ KDP (azimuth, range) float64 3MB ...
│ ... ...
│ RHOHV (azimuth, range) float64 3MB ...
│ sweep_mode <U20 80B ...
│ sweep_number int64 8B ...
│ prt_mode <U7 28B ...
│ follow_mode <U7 28B ...
│ sweep_fixed_angle float64 8B ...
├── Group: /sweep_3
│ Dimensions: (azimuth: 318, range: 997)
│ Coordinates:
│ * azimuth (azimuth) float64 3kB 22.86 23.86 24.86 ... 338.9 339.9
│ elevation (azimuth) float64 3kB ...
│ time (azimuth) datetime64[us] 3kB ...
│ * range (range) float32 4kB -436.5 -311.5 ... 1.239e+05 1.241e+05
│ Data variables: (12/14)
│ DBZH (azimuth, range) float64 3MB ...
│ DBTH (azimuth, range) float64 3MB ...
│ VRADH (azimuth, range) float64 3MB ...
│ WRADH (azimuth, range) float64 3MB ...
│ ZDR (azimuth, range) float64 3MB ...
│ KDP (azimuth, range) float64 3MB ...
│ ... ...
│ RHOHV (azimuth, range) float64 3MB ...
│ sweep_mode <U20 80B ...
│ sweep_number int64 8B ...
│ prt_mode <U7 28B ...
│ follow_mode <U7 28B ...
│ sweep_fixed_angle float64 8B ...
├── Group: /sweep_4
│ Dimensions: (azimuth: 318, range: 997)
│ Coordinates:
│ * azimuth (azimuth) float64 3kB 22.86 23.86 24.88 ... 338.9 339.9
│ elevation (azimuth) float64 3kB ...
│ time (azimuth) datetime64[us] 3kB ...
│ * range (range) float32 4kB -436.5 -311.5 ... 1.239e+05 1.241e+05
│ Data variables: (12/14)
│ DBZH (azimuth, range) float64 3MB ...
│ DBTH (azimuth, range) float64 3MB ...
│ VRADH (azimuth, range) float64 3MB ...
│ WRADH (azimuth, range) float64 3MB ...
│ ZDR (azimuth, range) float64 3MB ...
│ KDP (azimuth, range) float64 3MB ...
│ ... ...
│ RHOHV (azimuth, range) float64 3MB ...
│ sweep_mode <U20 80B ...
│ sweep_number int64 8B ...
│ prt_mode <U7 28B ...
│ follow_mode <U7 28B ...
│ sweep_fixed_angle float64 8B ...
├── Group: /sweep_5
│ Dimensions: (azimuth: 318, range: 997)
│ Coordinates:
│ * azimuth (azimuth) float64 3kB 22.88 23.86 24.88 ... 338.9 339.9
│ elevation (azimuth) float64 3kB ...
│ time (azimuth) datetime64[us] 3kB ...
│ * range (range) float32 4kB -436.5 -311.5 ... 1.239e+05 1.241e+05
│ Data variables: (12/14)
│ DBZH (azimuth, range) float64 3MB ...
│ DBTH (azimuth, range) float64 3MB ...
│ VRADH (azimuth, range) float64 3MB ...
│ WRADH (azimuth, range) float64 3MB ...
│ ZDR (azimuth, range) float64 3MB ...
│ KDP (azimuth, range) float64 3MB ...
│ ... ...
│ RHOHV (azimuth, range) float64 3MB ...
│ sweep_mode <U20 80B ...
│ sweep_number int64 8B ...
│ prt_mode <U7 28B ...
│ follow_mode <U7 28B ...
│ sweep_fixed_angle float64 8B ...
...
├── Group: /sweep_8
│ Dimensions: (azimuth: 329, range: 919)
│ Coordinates:
│ * azimuth (azimuth) float64 3kB 0.875 1.875 21.88 ... 358.9 359.9
│ elevation (azimuth) float64 3kB ...
│ time (azimuth) datetime64[us] 3kB ...
│ * range (range) float32 4kB -436.5 -311.5 ... 1.142e+05 1.143e+05
│ Data variables: (12/14)
│ DBZH (azimuth, range) float64 2MB ...
│ DBTH (azimuth, range) float64 2MB ...
│ VRADH (azimuth, range) float64 2MB ...
│ WRADH (azimuth, range) float64 2MB ...
│ ZDR (azimuth, range) float64 2MB ...
│ KDP (azimuth, range) float64 2MB ...
│ ... ...
│ RHOHV (azimuth, range) float64 2MB ...
│ sweep_mode <U20 80B ...
│ sweep_number int64 8B ...
│ prt_mode <U7 28B ...
│ follow_mode <U7 28B ...
│ sweep_fixed_angle float64 8B ...
├── Group: /sweep_9
│ Dimensions: (azimuth: 351, range: 766)
│ Coordinates:
│ * azimuth (azimuth) float64 3kB 0.875 1.844 2.875 ... 358.8 359.8
│ elevation (azimuth) float64 3kB ...
│ time (azimuth) datetime64[us] 3kB ...
│ * range (range) float32 3kB -436.5 -311.5 ... 9.506e+04 9.519e+04
│ Data variables: (12/14)
│ DBZH (azimuth, range) float64 2MB ...
│ DBTH (azimuth, range) float64 2MB ...
│ VRADH (azimuth, range) float64 2MB ...
│ WRADH (azimuth, range) float64 2MB ...
│ ZDR (azimuth, range) float64 2MB ...
│ KDP (azimuth, range) float64 2MB ...
│ ... ...
│ RHOHV (azimuth, range) float64 2MB ...
│ sweep_mode <U20 80B ...
│ sweep_number int64 8B ...
│ prt_mode <U7 28B ...
│ follow_mode <U7 28B ...
│ sweep_fixed_angle float64 8B ...
├── Group: /sweep_10
│ Dimensions: (azimuth: 360, range: 658)
│ Coordinates:
│ * azimuth (azimuth) float64 3kB 0.875 1.875 2.859 ... 358.9 359.9
│ elevation (azimuth) float64 3kB ...
│ time (azimuth) datetime64[us] 3kB ...
│ * range (range) float32 3kB -436.5 -311.5 ... 8.156e+04 8.169e+04
│ Data variables: (12/14)
│ DBZH (azimuth, range) float64 2MB ...
│ DBTH (azimuth, range) float64 2MB ...
│ VRADH (azimuth, range) float64 2MB ...
│ WRADH (azimuth, range) float64 2MB ...
│ ZDR (azimuth, range) float64 2MB ...
│ KDP (azimuth, range) float64 2MB ...
│ ... ...
│ RHOHV (azimuth, range) float64 2MB ...
│ sweep_mode <U20 80B ...
│ sweep_number int64 8B ...
│ prt_mode <U7 28B ...
│ follow_mode <U7 28B ...
│ sweep_fixed_angle float64 8B ...
├── Group: /sweep_11
│ Dimensions: (azimuth: 360, range: 577)
│ Coordinates:
│ * azimuth (azimuth) float64 3kB 0.8438 1.859 2.828 ... 358.9 359.8
│ elevation (azimuth) float64 3kB ...
│ time (azimuth) datetime64[us] 3kB ...
│ * range (range) float32 2kB -436.5 -311.5 ... 7.144e+04 7.156e+04
│ Data variables: (12/14)
│ DBZH (azimuth, range) float64 2MB ...
│ DBTH (azimuth, range) float64 2MB ...
│ VRADH (azimuth, range) float64 2MB ...
│ WRADH (azimuth, range) float64 2MB ...
│ ZDR (azimuth, range) float64 2MB ...
│ KDP (azimuth, range) float64 2MB ...
│ ... ...
│ RHOHV (azimuth, range) float64 2MB ...
│ sweep_mode <U20 80B ...
│ sweep_number int64 8B ...
│ prt_mode <U7 28B ...
│ follow_mode <U7 28B ...
│ sweep_fixed_angle float64 8B ...
├── Group: /sweep_12
│ Dimensions: (azimuth: 360, range: 476)
│ Coordinates:
│ * azimuth (azimuth) float64 3kB 0.8438 1.891 2.875 ... 358.9 359.9
│ elevation (azimuth) float64 3kB ...
│ time (azimuth) datetime64[us] 3kB ...
│ * range (range) float32 2kB -436.5 -311.5 ... 5.881e+04 5.894e+04
│ Data variables: (12/14)
│ DBZH (azimuth, range) float64 1MB ...
│ DBTH (azimuth, range) float64 1MB ...
│ VRADH (azimuth, range) float64 1MB ...
│ WRADH (azimuth, range) float64 1MB ...
│ ZDR (azimuth, range) float64 1MB ...
│ KDP (azimuth, range) float64 1MB ...
│ ... ...
│ RHOHV (azimuth, range) float64 1MB ...
│ sweep_mode <U20 80B ...
│ sweep_number int64 8B ...
│ prt_mode <U7 28B ...
│ follow_mode <U7 28B ...
│ sweep_fixed_angle float64 8B ...
└── Group: /sweep_13
Dimensions: (azimuth: 360, range: 422)
Coordinates:
* azimuth (azimuth) float64 3kB 0.875 1.844 2.844 ... 358.9 359.9
elevation (azimuth) float64 3kB ...
time (azimuth) datetime64[us] 3kB ...
* range (range) float32 2kB -436.5 -311.5 ... 5.206e+04 5.219e+04
Data variables: (12/14)
DBZH (azimuth, range) float64 1MB ...
DBTH (azimuth, range) float64 1MB ...
VRADH (azimuth, range) float64 1MB ...
WRADH (azimuth, range) float64 1MB ...
ZDR (azimuth, range) float64 1MB ...
KDP (azimuth, range) float64 1MB ...
... ...
RHOHV (azimuth, range) float64 1MB ...
sweep_mode <U20 80B ...
sweep_number int64 8B ...
prt_mode <U7 28B ...
follow_mode <U7 28B ...
sweep_fixed_angle float64 8B ...dtree["sweep_1"]
<xarray.DataTree 'sweep_1'>
Group: /sweep_1
Dimensions: (azimuth: 319, range: 997)
Coordinates:
* azimuth (azimuth) float64 3kB 21.88 22.86 23.89 ... 338.9 339.9
elevation (azimuth) float64 3kB ...
time (azimuth) datetime64[us] 3kB ...
* range (range) float32 4kB -436.5 -311.5 ... 1.239e+05 1.241e+05
Data variables: (12/14)
DBZH (azimuth, range) float64 3MB ...
DBTH (azimuth, range) float64 3MB ...
VRADH (azimuth, range) float64 3MB ...
WRADH (azimuth, range) float64 3MB ...
ZDR (azimuth, range) float64 3MB ...
KDP (azimuth, range) float64 3MB ...
... ...
RHOHV (azimuth, range) float64 3MB ...
sweep_mode <U20 80B ...
sweep_number int64 8B ...
prt_mode <U7 28B ...
follow_mode <U7 28B ...
sweep_fixed_angle float64 8B ...clean up#
import time
for node in dtree.values():
if hasattr(node, "close"):
node.close()
for file in tmpdir.iterdir():
if file.is_file():
for _ in range(5):
try:
file.unlink()
break
except PermissionError:
time.sleep(0.5)