xradar is in an early stage of development, please report any issues here!

ODIM_H5#

[1]:
import xarray as xr
import xradar as xd
from open_radar_data import DATASETS

Download#

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

[2]:
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.

[3]:
ds = xr.open_dataset(filename, group="sweep_0", engine="odim")
display(ds)
<xarray.Dataset> Size: 21MB
Dimensions:            (azimuth: 360, range: 1200)
Coordinates:
    elevation          (azimuth) float32 1kB ...
    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 ...
  * azimuth            (azimuth) float32 1kB 0.5 1.5 2.5 ... 357.5 358.5 359.5
Data variables: (12/17)
    DBZH               (azimuth, range) float32 2MB ...
    DBZH_CLEAN         (azimuth, range) float32 2MB ...
    VRADDH             (azimuth, range) float32 2MB ...
    VRADH              (azimuth, range) float32 2MB ...
    WRADH              (azimuth, range) float32 2MB ...
    TH                 (azimuth, range) float32 2MB ...
    ...                 ...
    CLASS              (azimuth, range) float32 2MB ...
    sweep_mode         <U20 80B ...
    sweep_number       int64 8B ...
    prt_mode           <U7 28B ...
    follow_mode        <U7 28B ...
    sweep_fixed_angle  float64 8B ...

Plot Time vs. Azimuth#

[4]:
ds.azimuth.plot()
[4]:
[<matplotlib.lines.Line2D at 0x7f7c4ded2510>]
../_images/notebooks_ODIM_H5_7_1.png

Plot Range vs. Time#

[5]:
ds.DBZH.plot()
[5]:
<matplotlib.collections.QuadMesh at 0x7f7c4d8c4990>
../_images/notebooks_ODIM_H5_9_1.png

Plot Range vs. Azimuth#

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

[6]:
ds.DBZH.sortby("azimuth").plot(y="azimuth")
[6]:
<matplotlib.collections.QuadMesh at 0x7f7c44cbe510>
../_images/notebooks_ODIM_H5_11_1.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.

[7]:
?xd.io.OdimBackendEntrypoint
[8]:
ds = xr.open_dataset(filename, group="sweep_0", engine="odim", first_dim="time")
display(ds)
<xarray.Dataset> Size: 21MB
Dimensions:            (time: 360, range: 1200)
Coordinates:
    elevation          (time) float32 1kB ...
  * time               (time) datetime64[ns] 3kB 2018-12-20T06:06:28.04027776...
  * range              (range) float32 5kB 125.0 375.0 ... 2.996e+05 2.999e+05
    longitude          float64 8B ...
    latitude           float64 8B ...
    altitude           float64 8B ...
    azimuth            (time) float32 1kB ...
Data variables: (12/17)
    DBZH               (time, range) float32 2MB ...
    DBZH_CLEAN         (time, range) float32 2MB ...
    VRADDH             (time, range) float32 2MB ...
    VRADH              (time, range) float32 2MB ...
    WRADH              (time, range) float32 2MB ...
    TH                 (time, range) float32 2MB ...
    ...                 ...
    CLASS              (time, range) float32 2MB ...
    sweep_mode         <U20 80B ...
    sweep_number       int64 8B ...
    prt_mode           <U7 28B ...
    follow_mode        <U7 28B ...
    sweep_fixed_angle  float64 8B ...

open_odim_datatree#

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

[9]:
?xd.io.open_odim_datatree
[10]:
dtree = xd.io.open_odim_datatree(filename, sweep=8)
display(dtree)
<xarray.DatasetView> Size: 232B
Dimensions:              ()
Data variables:
    volume_number        int64 8B 0
    platform_type        <U5 20B 'fixed'
    instrument_type      <U5 20B 'radar'
    time_coverage_start  <U20 80B '2018-12-20T06:09:21Z'
    time_coverage_end    <U20 80B '2018-12-20T06:09:34Z'
    longitude            float64 8B 151.2
    altitude             float64 8B 195.0
    latitude             float64 8B -33.7
Attributes:
    Conventions:      ODIM_H5/V2_2
    instrument_name:  None
    version:          None
    title:            None
    institution:      None
    references:       None
    source:           None
    history:          None
    comment:          im/exported using xradar

Plot Sweep Range vs. Time#

[11]:
dtree["sweep_0"].ds.DBZH.sortby("time").plot(y="time")
[11]:
<matplotlib.collections.QuadMesh at 0x7f7c3e7b8cd0>
../_images/notebooks_ODIM_H5_19_1.png

Plot Sweep Range vs. Azimuth#

[12]:
dtree["sweep_0"].ds.DBZH.plot()
[12]:
<matplotlib.collections.QuadMesh at 0x7f7c3e36fd90>
../_images/notebooks_ODIM_H5_21_1.png
[13]:
dtree = xd.io.open_odim_datatree(filename, sweep="sweep_8")
display(dtree)
<xarray.DatasetView> Size: 232B
Dimensions:              ()
Data variables:
    volume_number        int64 8B 0
    platform_type        <U5 20B 'fixed'
    instrument_type      <U5 20B 'radar'
    time_coverage_start  <U20 80B '2018-12-20T06:09:21Z'
    time_coverage_end    <U20 80B '2018-12-20T06:09:34Z'
    longitude            float64 8B 151.2
    altitude             float64 8B 195.0
    latitude             float64 8B -33.7
Attributes:
    Conventions:      ODIM_H5/V2_2
    instrument_name:  None
    version:          None
    title:            None
    institution:      None
    references:       None
    source:           None
    history:          None
    comment:          im/exported using xradar
[14]:
dtree = xd.io.open_odim_datatree(filename, sweep=[0, 1, 8])
display(dtree)
<xarray.DatasetView> Size: 232B
Dimensions:              ()
Data variables:
    volume_number        int64 8B 0
    platform_type        <U5 20B 'fixed'
    instrument_type      <U5 20B 'radar'
    time_coverage_start  <U20 80B '2018-12-20T06:06:59Z'
    time_coverage_end    <U20 80B '2018-12-20T06:09:48Z'
    longitude            float64 8B 151.2
    altitude             float64 8B 195.0
    latitude             float64 8B -33.7
Attributes:
    Conventions:      ODIM_H5/V2_2
    instrument_name:  None
    version:          None
    title:            None
    institution:      None
    references:       None
    source:           None
    history:          None
    comment:          im/exported using xradar
[15]:
dtree = xd.io.open_odim_datatree(filename, sweep=["sweep_0", "sweep_1", "sweep_8"])
display(dtree)
<xarray.DatasetView> Size: 232B
Dimensions:              ()
Data variables:
    volume_number        int64 8B 0
    platform_type        <U5 20B 'fixed'
    instrument_type      <U5 20B 'radar'
    time_coverage_start  <U20 80B '2018-12-20T06:06:28Z'
    time_coverage_end    <U20 80B '2018-12-20T06:09:34Z'
    longitude            float64 8B 151.2
    altitude             float64 8B 195.0
    latitude             float64 8B -33.7
Attributes:
    Conventions:      ODIM_H5/V2_2
    instrument_name:  None
    version:          None
    title:            None
    institution:      None
    references:       None
    source:           None
    history:          None
    comment:          im/exported using xradar