xarray GAMIC backend#

In this example, we read GAMIC (HDF5) data files using the xradar gamic backend.

[1]:
import glob
import wradlib as wrl
import warnings

warnings.filterwarnings("ignore")
import matplotlib.pyplot as plt
import numpy as np
import xradar as xd
import datatree as xt
import xarray as xr

try:
    get_ipython().run_line_magic("matplotlib inline")
except:
    plt.ion()

Load GAMIC HDF5 Volume Data#

[2]:
fpath = "hdf5/DWD-Vol-2_99999_20180601054047_00.h5"
f = wrl.util.get_wradlib_data_file(fpath)
vol = xd.io.open_gamic_datatree(f)
Downloading file 'hdf5/DWD-Vol-2_99999_20180601054047_00.h5' from 'https://github.com/wradlib/wradlib-data/raw/pooch/data/hdf5/DWD-Vol-2_99999_20180601054047_00.h5' to '/home/runner/work/wradlib/wradlib/wradlib-data'.

Inspect RadarVolume#

[3]:
display(vol)
<xarray.DatasetView>
Dimensions:              ()
Data variables:
    volume_number        int64 0
    platform_type        <U5 'fixed'
    instrument_type      <U5 'radar'
    time_coverage_start  <U20 '2018-06-01T05:40:47Z'
    time_coverage_end    <U20 '2018-06-01T05:44:16Z'
    longitude            float64 6.457
    altitude             float64 310.0
    latitude             float64 50.93
Attributes:
    Conventions:      None
    version:          None
    title:            None
    institution:      None
    references:       None
    source:           None
    history:          None
    comment:          im/exported using xradar
    instrument_name:  None

Inspect root group#

The sweep dimension contains the number of scans in this radar volume. Further the dataset consists of variables (location coordinates, time_coverage) and attributes (Conventions, metadata).

[4]:
vol.root
[4]:
<xarray.DatasetView>
Dimensions:              ()
Data variables:
    volume_number        int64 0
    platform_type        <U5 'fixed'
    instrument_type      <U5 'radar'
    time_coverage_start  <U20 '2018-06-01T05:40:47Z'
    time_coverage_end    <U20 '2018-06-01T05:44:16Z'
    longitude            float64 6.457
    altitude             float64 310.0
    latitude             float64 50.93
Attributes:
    Conventions:      None
    version:          None
    title:            None
    institution:      None
    references:       None
    source:           None
    history:          None
    comment:          im/exported using xradar
    instrument_name:  None

Inspect sweep group(s)#

The sweep-groups can be accessed via their respective keys. The dimensions consist of range and time with added coordinates azimuth, elevation, range and time. There will be variables like radar moments (DBZH etc.) and sweep-dependend metadata (like fixed_angle, sweep_mode etc.).

[5]:
display(vol["sweep_0"])
<xarray.DatasetView>
Dimensions:            (azimuth: 361, range: 360)
Coordinates:
  * azimuth            (azimuth) float64 0.5219 1.519 2.53 ... 357.5 358.5 359.5
    elevation          (azimuth) float64 ...
    time               (azimuth) datetime64[ns] 2018-06-01T05:40:57.362999808...
  * range              (range) float32 50.0 150.0 250.0 ... 3.585e+04 3.595e+04
    longitude          float64 ...
    latitude           float64 ...
    altitude           float64 ...
Data variables: (12/17)
    DBZH               (azimuth, range) float32 ...
    DBZV               (azimuth, range) float32 ...
    KDP                (azimuth, range) float32 ...
    RHOHV              (azimuth, range) float32 ...
    DBTH               (azimuth, range) float32 ...
    DBTV               (azimuth, range) float32 ...
    ...                 ...
    PHIDP              (azimuth, range) float32 ...
    sweep_mode         <U20 ...
    sweep_number       int64 ...
    prt_mode           <U7 ...
    follow_mode        <U7 ...
    sweep_fixed_angle  float64 ...

Georeferencing#

[6]:
swp = vol["sweep_0"].ds.copy()
swp = swp.assign_coords(sweep_mode=swp.sweep_mode)
[7]:
swp = swp.wrl.georef.georeference()
display(swp)
<xarray.Dataset>
Dimensions:            (azimuth: 361, range: 360)
Coordinates: (12/15)
  * azimuth            (azimuth) float64 0.5219 1.519 2.53 ... 357.5 358.5 359.5
    elevation          (azimuth) float64 28.0 28.0 28.0 28.0 ... 28.0 28.0 28.0
    time               (azimuth) datetime64[ns] 2018-06-01T05:40:57.362999808...
  * range              (range) float32 50.0 150.0 250.0 ... 3.585e+04 3.595e+04
    sweep_mode         <U20 'azimuth_surveillance'
    longitude          float64 6.457
    ...                 ...
    y                  (azimuth, range) float64 44.14 132.4 ... 3.168e+04
    z                  (azimuth, range) float64 333.5 380.4 ... 1.725e+04
    gr                 (azimuth, range) float64 44.11 132.4 ... 3.168e+04
    rays               (azimuth, range) float64 0.5219 0.5219 ... 359.5 359.5
    bins               (azimuth, range) float32 50.0 150.0 ... 3.595e+04
    spatial_ref        int64 0
Data variables: (12/16)
    DBZH               (azimuth, range) float32 ...
    DBZV               (azimuth, range) float32 ...
    KDP                (azimuth, range) float32 ...
    RHOHV              (azimuth, range) float32 ...
    DBTH               (azimuth, range) float32 ...
    DBTV               (azimuth, range) float32 ...
    ...                 ...
    WRADV              (azimuth, range) float32 ...
    PHIDP              (azimuth, range) float32 ...
    sweep_number       int64 ...
    prt_mode           <U7 ...
    follow_mode        <U7 ...
    sweep_fixed_angle  float64 ...