ODIM_H5#

import xarray as xr
from open_radar_data import DATASETS

import xradar as xd

Download#

Fetching ODIM_H5 radar data file from open-radar-data repository.

filename = DATASETS.fetch("71_20181220_060628.pvol.h5")

xr.open_dataset#

Making use of the xarray odim backend. We also need to provide the group. We use CfRadial2 group access pattern.

ds = xr.open_dataset(filename, group="sweep_0", engine="odim")
display(ds)
<xarray.Dataset> Size: 40MB
Dimensions:            (azimuth: 360, range: 1200)
Coordinates:
  * azimuth            (azimuth) float32 1kB 0.5 1.5 2.5 ... 357.5 358.5 359.5
    elevation          (azimuth) float64 3kB ...
    time               (azimuth) datetime64[ns] 3kB ...
  * range              (range) float32 5kB 125.0 375.0 ... 2.996e+05 2.999e+05
    longitude          float64 8B ...
    latitude           float64 8B ...
    altitude           float64 8B ...
Data variables: (12/18)
    DBZH               (azimuth, range) float64 3MB ...
    DBZH_CLEAN         (azimuth, range) float64 3MB ...
    VRADDH             (azimuth, range) float64 3MB ...
    VRADH              (azimuth, range) float64 3MB ...
    WRADH              (azimuth, range) float64 3MB ...
    DBTH               (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 ...
    nyquist_velocity   float64 8B ...
Attributes:
    Conventions:         ODIM_H5/V2_2
    source:              radar
    site_name:           T/Hills
    radar_beam_width_h:  0.896
    radar_beam_width_v:  0.896
ds.sweep_fixed_angle.values
array(0.5)

Plot Time vs. Azimuth#

ds.azimuth.plot()
[<matplotlib.lines.Line2D at 0x7c2e4a6cf0e0>]
../_images/01fcb73f6b17d1a5a43409045ee2ba58e7f9d040ece275ef7b6de4006ace34a4.png

Plot Range vs. Time#

ds.DBZH.plot()
<matplotlib.collections.QuadMesh at 0x7c2e4a524d70>
../_images/90bc56b4b5efe2512bf40c129515bf82d44219752f854c6fce139c561d324690.png

Plot Range vs. Azimuth#

We need to sort by azimuth and specify the y-coordinate.

ds.DBZH.sortby("azimuth").plot(y="azimuth")
<matplotlib.collections.QuadMesh at 0x7c2e4235dd10>
../_images/90bc56b4b5efe2512bf40c129515bf82d44219752f854c6fce139c561d324690.png

backend_kwargs#

Beside first_dim there are several additional backend_kwargs for the odim 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.

?xd.io.OdimBackendEntrypoint
ds = xr.open_dataset(filename, group="sweep_0", engine="odim", first_dim="time")
display(ds)
<xarray.Dataset> Size: 40MB
Dimensions:            (time: 360, range: 1200)
Coordinates:
  * time               (time) datetime64[ns] 3kB 2018-12-20T06:06:28.04027776...
    elevation          (time) float64 3kB ...
    azimuth            (time) float32 1kB ...
  * range              (range) float32 5kB 125.0 375.0 ... 2.996e+05 2.999e+05
    longitude          float64 8B ...
    latitude           float64 8B ...
    altitude           float64 8B ...
Data variables: (12/18)
    DBZH               (time, range) float64 3MB ...
    DBZH_CLEAN         (time, range) float64 3MB ...
    VRADDH             (time, range) float64 3MB ...
    VRADH              (time, range) float64 3MB ...
    WRADH              (time, range) float64 3MB ...
    DBTH               (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 ...
    nyquist_velocity   float64 8B ...
Attributes:
    Conventions:         ODIM_H5/V2_2
    source:              radar
    site_name:           T/Hills
    radar_beam_width_h:  0.896
    radar_beam_width_v:  0.896

open_odim_datatree#

The same works analoguous with the datatree loader. But additionally we can provide a sweep string, number or list.

?xd.open_datatree
dtree = xd.open_datatree(filename, engine="odim", sweep=8)
display(dtree)
<xarray.DataTree>
Group: /
│   Dimensions:              (sweep: 1)
│   Coordinates:
│       longitude            float64 8B ...
│       altitude             float64 8B ...
│       latitude             float64 8B ...
│   Dimensions without coordinates: sweep
│   Data variables:
│       volume_number        int64 8B ...
│       platform_type        <U5 20B ...
│       instrument_type      <U5 20B ...
│       time_coverage_start  <U20 80B ...
│       time_coverage_end    <U20 80B ...
│       sweep_group_name     (sweep) int64 8B ...
│       sweep_fixed_angle    (sweep) float64 8B ...
│   Attributes:
│       Conventions:      ODIM_H5/V2_2
│       instrument_name:  None
│       version:          None
│       title:            None
│       institution:      None
│       references:       None
│       source:           radar
│       history:          None
│       comment:          im/exported using xradar
│       site_name:        T/Hills
└── Group: /sweep_0
        Dimensions:            (azimuth: 360, range: 590)
        Coordinates:
          * azimuth            (azimuth) float32 1kB 0.5 1.5 2.5 ... 357.5 358.5 359.5
            elevation          (azimuth) float64 3kB ...
            time               (azimuth) datetime64[ns] 3kB ...
          * range              (range) float32 2kB 125.0 375.0 ... 1.471e+05 1.474e+05
        Data variables: (12/18)
            DBZH               (azimuth, range) float64 2MB ...
            DBZH_CLEAN         (azimuth, range) float64 2MB ...
            VRADDH             (azimuth, range) float64 2MB ...
            VRADH              (azimuth, range) float64 2MB ...
            WRADH              (azimuth, range) float64 2MB ...
            DBTH               (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 ...
            nyquist_velocity   float64 8B ...

Plot Sweep Range vs. Time#

dtree["sweep_0"].dataset.DBZH.sortby("time").plot(y="time")
<matplotlib.collections.QuadMesh at 0x7c2e4214e0d0>
../_images/ee5fd6e252cc3cdf0829e5d9fba2119a2aa84a23aef61cb98025289771dd32a6.png

Plot Sweep Range vs. Azimuth#

dtree["sweep_0"].dataset.DBZH.plot()
<matplotlib.collections.QuadMesh at 0x7c2e4200ed50>
../_images/25471fcec47c915b9c1a83ae1b781058848d807d4c94093f0823f8e11b287d4b.png
dtree = xd.open_datatree(filename, engine="odim", sweep="sweep_8")
display(dtree)
<xarray.DataTree>
Group: /
│   Dimensions:              (sweep: 1)
│   Coordinates:
│       longitude            float64 8B ...
│       altitude             float64 8B ...
│       latitude             float64 8B ...
│   Dimensions without coordinates: sweep
│   Data variables:
│       volume_number        int64 8B ...
│       platform_type        <U5 20B ...
│       instrument_type      <U5 20B ...
│       time_coverage_start  <U20 80B ...
│       time_coverage_end    <U20 80B ...
│       sweep_group_name     (sweep) int64 8B ...
│       sweep_fixed_angle    (sweep) float64 8B ...
│   Attributes:
│       Conventions:      ODIM_H5/V2_2
│       instrument_name:  None
│       version:          None
│       title:            None
│       institution:      None
│       references:       None
│       source:           radar
│       history:          None
│       comment:          im/exported using xradar
│       site_name:        T/Hills
└── Group: /sweep_0
        Dimensions:            (azimuth: 360, range: 590)
        Coordinates:
          * azimuth            (azimuth) float32 1kB 0.5 1.5 2.5 ... 357.5 358.5 359.5
            elevation          (azimuth) float64 3kB ...
            time               (azimuth) datetime64[ns] 3kB ...
          * range              (range) float32 2kB 125.0 375.0 ... 1.471e+05 1.474e+05
        Data variables: (12/18)
            DBZH               (azimuth, range) float64 2MB ...
            DBZH_CLEAN         (azimuth, range) float64 2MB ...
            VRADDH             (azimuth, range) float64 2MB ...
            VRADH              (azimuth, range) float64 2MB ...
            WRADH              (azimuth, range) float64 2MB ...
            DBTH               (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 ...
            nyquist_velocity   float64 8B ...
dtree = xd.open_datatree(filename, engine="odim", sweep=[0, 1, 8])
display(dtree)
<xarray.DataTree>
Group: /
│   Dimensions:              (sweep: 3)
│   Coordinates:
│       longitude            float64 8B ...
│       altitude             float64 8B ...
│       latitude             float64 8B ...
│   Dimensions without coordinates: sweep
│   Data variables:
│       volume_number        int64 8B ...
│       platform_type        <U5 20B ...
│       instrument_type      <U5 20B ...
│       time_coverage_start  <U20 80B ...
│       time_coverage_end    <U20 80B ...
│       sweep_group_name     (sweep) int64 24B ...
│       sweep_fixed_angle    (sweep) float64 24B ...
│   Attributes:
│       Conventions:      ODIM_H5/V2_2
│       instrument_name:  None
│       version:          None
│       title:            None
│       institution:      None
│       references:       None
│       source:           radar
│       history:          None
│       comment:          im/exported using xradar
│       site_name:        T/Hills
├── Group: /sweep_0
│       Dimensions:            (azimuth: 360, range: 1200)
│       Coordinates:
│         * azimuth            (azimuth) float32 1kB 0.5 1.5 2.5 ... 357.5 358.5 359.5
│           elevation          (azimuth) float64 3kB ...
│           time               (azimuth) datetime64[ns] 3kB ...
│         * range              (range) float32 5kB 125.0 375.0 ... 2.996e+05 2.999e+05
│       Data variables: (12/18)
│           DBZH               (azimuth, range) float64 3MB ...
│           DBZH_CLEAN         (azimuth, range) float64 3MB ...
│           VRADDH             (azimuth, range) float64 3MB ...
│           VRADH              (azimuth, range) float64 3MB ...
│           WRADH              (azimuth, range) float64 3MB ...
│           DBTH               (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 ...
│           nyquist_velocity   float64 8B ...
├── Group: /sweep_1
│       Dimensions:            (azimuth: 360, range: 1200)
│       Coordinates:
│         * azimuth            (azimuth) float32 1kB 0.5 1.5 2.5 ... 357.5 358.5 359.5
│           elevation          (azimuth) float64 3kB ...
│           time               (azimuth) datetime64[ns] 3kB ...
│         * range              (range) float32 5kB 125.0 375.0 ... 2.996e+05 2.999e+05
│       Data variables: (12/18)
│           DBZH               (azimuth, range) float64 3MB ...
│           DBZH_CLEAN         (azimuth, range) float64 3MB ...
│           VRADDH             (azimuth, range) float64 3MB ...
│           VRADH              (azimuth, range) float64 3MB ...
│           WRADH              (azimuth, range) float64 3MB ...
│           DBTH               (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 ...
│           nyquist_velocity   float64 8B ...
└── Group: /sweep_2
        Dimensions:            (azimuth: 360, range: 590)
        Coordinates:
          * azimuth            (azimuth) float32 1kB 0.5 1.5 2.5 ... 357.5 358.5 359.5
            elevation          (azimuth) float64 3kB ...
            time               (azimuth) datetime64[ns] 3kB ...
          * range              (range) float32 2kB 125.0 375.0 ... 1.471e+05 1.474e+05
        Data variables: (12/18)
            DBZH               (azimuth, range) float64 2MB ...
            DBZH_CLEAN         (azimuth, range) float64 2MB ...
            VRADDH             (azimuth, range) float64 2MB ...
            VRADH              (azimuth, range) float64 2MB ...
            WRADH              (azimuth, range) float64 2MB ...
            DBTH               (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 ...
            nyquist_velocity   float64 8B ...
dtree = xd.open_datatree(filename, engine="odim", sweep=["sweep_0", "sweep_1", "sweep_8"])
display(dtree)
<xarray.DataTree>
Group: /
│   Dimensions:              (sweep: 3)
│   Coordinates:
│       longitude            float64 8B ...
│       altitude             float64 8B ...
│       latitude             float64 8B ...
│   Dimensions without coordinates: sweep
│   Data variables:
│       volume_number        int64 8B ...
│       platform_type        <U5 20B ...
│       instrument_type      <U5 20B ...
│       time_coverage_start  <U20 80B ...
│       time_coverage_end    <U20 80B ...
│       sweep_group_name     (sweep) int64 24B ...
│       sweep_fixed_angle    (sweep) float64 24B ...
│   Attributes:
│       Conventions:      ODIM_H5/V2_2
│       instrument_name:  None
│       version:          None
│       title:            None
│       institution:      None
│       references:       None
│       source:           radar
│       history:          None
│       comment:          im/exported using xradar
│       site_name:        T/Hills
├── Group: /sweep_0
│       Dimensions:            (azimuth: 360, range: 1200)
│       Coordinates:
│         * azimuth            (azimuth) float32 1kB 0.5 1.5 2.5 ... 357.5 358.5 359.5
│           elevation          (azimuth) float64 3kB ...
│           time               (azimuth) datetime64[ns] 3kB ...
│         * range              (range) float32 5kB 125.0 375.0 ... 2.996e+05 2.999e+05
│       Data variables: (12/18)
│           DBZH               (azimuth, range) float64 3MB ...
│           DBZH_CLEAN         (azimuth, range) float64 3MB ...
│           VRADDH             (azimuth, range) float64 3MB ...
│           VRADH              (azimuth, range) float64 3MB ...
│           WRADH              (azimuth, range) float64 3MB ...
│           DBTH               (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 ...
│           nyquist_velocity   float64 8B ...
├── Group: /sweep_1
│       Dimensions:            (azimuth: 360, range: 1200)
│       Coordinates:
│         * azimuth            (azimuth) float32 1kB 0.5 1.5 2.5 ... 357.5 358.5 359.5
│           elevation          (azimuth) float64 3kB ...
│           time               (azimuth) datetime64[ns] 3kB ...
│         * range              (range) float32 5kB 125.0 375.0 ... 2.996e+05 2.999e+05
│       Data variables: (12/18)
│           DBZH               (azimuth, range) float64 3MB ...
│           DBZH_CLEAN         (azimuth, range) float64 3MB ...
│           VRADDH             (azimuth, range) float64 3MB ...
│           VRADH              (azimuth, range) float64 3MB ...
│           WRADH              (azimuth, range) float64 3MB ...
│           DBTH               (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 ...
│           nyquist_velocity   float64 8B ...
└── Group: /sweep_2
        Dimensions:            (azimuth: 360, range: 590)
        Coordinates:
          * azimuth            (azimuth) float32 1kB 0.5 1.5 2.5 ... 357.5 358.5 359.5
            elevation          (azimuth) float64 3kB ...
            time               (azimuth) datetime64[ns] 3kB ...
          * range              (range) float32 2kB 125.0 375.0 ... 1.471e+05 1.474e+05
        Data variables: (12/18)
            DBZH               (azimuth, range) float64 2MB ...
            DBZH_CLEAN         (azimuth, range) float64 2MB ...
            VRADDH             (azimuth, range) float64 2MB ...
            VRADH              (azimuth, range) float64 2MB ...
            WRADH              (azimuth, range) float64 2MB ...
            DBTH               (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 ...
            nyquist_velocity   float64 8B ...

Optional groups: radar_parameters and radar_calibration#

With optional_groups=True the datatree also has the metadata groups. The ODIM_H5 reader fills them from the how attributes of the file (beamwH/V, antgainH/V, radconstH/V, NEZH/V and radomelossH/V), with the names of the data model.

dtree = xd.open_datatree(filename, engine="odim", sweep=0, optional_groups=True)
display(dtree["radar_parameters"].dataset)
<xarray.DatasetView> Size: 16B
Dimensions:             ()
Data variables:
    radar_beam_width_h  float64 8B ...
    radar_beam_width_v  float64 8B ...
import numpy as np

np.testing.assert_almost_equal(dtree["radar_parameters"].radar_beam_width_h, 0.896)
np.testing.assert_almost_equal(dtree["radar_parameters"].radar_beam_width_v, 0.896)

This file has no calibration attributes, so radar_calibration is empty. The groups hold one set of values: if the datasets of a file disagree about a value, that value is left out of the group and a warning lists it. Select the sweep whose values you need with sweep=.

display(dtree["radar_calibration"].dataset)
<xarray.DatasetView> Size: 0B
Dimensions:  ()
Data variables:
    *empty*