GAMIC#
import xarray as xr
from open_radar_data import DATASETS
import xradar as xd
Download#
Fetching GAMIC radar data file from open-radar-data repository.
filename = DATASETS.fetch("DWD-Vol-2_99999_20180601054047_00.h5")
xr.open_dataset#
Making use of the xarray gamic backend. We also need to provide the group. Note, that we are using CfRadial2 group access pattern.
ds = xr.open_dataset(filename, group="sweep_9", engine="gamic")
display(ds)
<xarray.Dataset> Size: 17MB
Dimensions: (azimuth: 360, range: 1000)
Coordinates:
* azimuth (azimuth) float64 3kB 0.5109 1.519 2.519 ... 358.5 359.5
elevation (azimuth) float64 3kB ...
time (azimuth) datetime64[ns] 3kB ...
* range (range) float32 4kB 75.0 225.0 ... 1.498e+05 1.499e+05
longitude float64 8B ...
latitude float64 8B ...
altitude float64 8B ...
Data variables: (12/18)
DBZH (azimuth, range) float32 1MB ...
DBZV (azimuth, range) float32 1MB ...
KDP (azimuth, range) float32 1MB ...
RHOHV (azimuth, range) float32 1MB ...
DBTH (azimuth, range) float32 1MB ...
DBTV (azimuth, range) float32 1MB ...
... ...
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:
source: gamic
antenna_gain_h: 43.0
antenna_gain_v: 43.0
rx_loss_h: 3.0
rx_loss_v: 3.0
noise_power_h: -3.40133
noise_power_v: -3.13518
radar_beam_width_h: 1.0
radar_beam_width_v: 1.0Plot Time vs. Azimuth#
ds.azimuth.plot()
[<matplotlib.lines.Line2D at 0x7d939fc22e40>]
Plot Range vs. Time#
ds.DBZH.plot()
<matplotlib.collections.QuadMesh at 0x7d939fa74c20>
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 0x7d939792d6d0>
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.
help(xd.io.GamicBackendEntrypoint)
Help on class GamicBackendEntrypoint in module xradar.io.backends.gamic:
class GamicBackendEntrypoint(xarray.backends.common.BackendEntrypoint)
| Xarray BackendEntrypoint for GAMIC data.
|
| Keyword Arguments
| -----------------
| first_dim : str
| Can be ``time`` or ``auto`` first dimension. If set to ``auto``,
| first dimension will be either ``azimuth`` or ``elevation`` depending on
| type of sweep. Defaults to ``auto``.
| reindex_coord : dict, optional
| Defaults to None, no reindexing. 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 if ``decode_coords=True``.
| reindex_angle : dict, optional
| Deprecated, use ``reindex_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 to ``True``.
| kwargs : dict
| Additional kwargs are fed to :py:func:`xarray.open_dataset`.
|
| Method resolution order:
| GamicBackendEntrypoint
| xarray.backends.common.BackendEntrypoint
| builtins.object
|
| Methods defined here:
|
| guess_can_open(self, filename_or_obj)
| GAMIC HDF5 file (``what`` and ``scan0`` groups).
|
| 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,
| 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
| )
| Backend open_dataset method used by Xarray in :py:func:`~xarray.open_dataset`.
|
| open_datatree(self, filename_or_obj, **kwargs)
| Open a GAMIC HDF5 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,
| 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
| )
| 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 : 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``.
| format : str, optional
| h5netcdf format string. Defaults to ``None``.
| 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 to ``True``.
| 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``.
|
| 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:
|
| description = 'Open GAMIC HDF5 (.h5, .hdf5, .mvol) using h5netcdf in X...
|
| open_dataset_parameters = ('filename_or_obj', 'mask_and_scale', 'decod...
|
| supports_groups = True
|
| url = 'https://xradar.rtfd.io/en/latest/io.html#gamic-hdf5'
|
| ----------------------------------------------------------------------
| 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
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from xarray.backends.common.BackendEntrypoint:
|
| __annotations__ = {}
ds = xr.open_dataset(filename, group="sweep_9", engine="gamic", first_dim="time")
display(ds)
<xarray.Dataset> Size: 17MB
Dimensions: (time: 360, range: 1000)
Coordinates:
* time (time) datetime64[ns] 3kB 2018-06-01T05:43:40.504000 ....
elevation (time) float64 3kB ...
azimuth (time) float64 3kB ...
* range (range) float32 4kB 75.0 225.0 ... 1.498e+05 1.499e+05
longitude float64 8B ...
latitude float64 8B ...
altitude float64 8B ...
Data variables: (12/18)
DBZH (time, range) float32 1MB ...
DBZV (time, range) float32 1MB ...
KDP (time, range) float32 1MB ...
RHOHV (time, range) float32 1MB ...
DBTH (time, range) float32 1MB ...
DBTV (time, range) float32 1MB ...
... ...
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:
source: gamic
antenna_gain_h: 43.0
antenna_gain_v: 43.0
rx_loss_h: 3.0
rx_loss_v: 3.0
noise_power_h: -3.40133
noise_power_v: -3.13518
radar_beam_width_h: 1.0
radar_beam_width_v: 1.0open_odim_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(filename, engine="gamic", 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_fixed_angle (sweep) float64 8B ...
│ sweep_group_name (sweep) int64 8B ...
│ Attributes:
│ Conventions: None
│ instrument_name: None
│ version: None
│ title: None
│ institution: None
│ references: None
│ source: gamic
│ history: None
│ comment: im/exported using xradar
└── Group: /sweep_0
Dimensions: (azimuth: 360, range: 1000)
Coordinates:
* azimuth (azimuth) float64 3kB 0.5191 1.516 2.516 ... 358.5 359.5
elevation (azimuth) float64 3kB ...
time (azimuth) datetime64[ns] 3kB ...
* range (range) float32 4kB 75.0 225.0 ... 1.498e+05 1.499e+05
Data variables: (12/18)
DBZH (azimuth, range) float32 1MB ...
DBZV (azimuth, range) float32 1MB ...
KDP (azimuth, range) float32 1MB ...
RHOHV (azimuth, range) float32 1MB ...
DBTH (azimuth, range) float32 1MB ...
DBTV (azimuth, range) float32 1MB ...
... ...
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 0x7d93979cbb10>
Plot Sweep Range vs. Azimuth#
dtree["sweep_0"].dataset.DBZH.plot()
<matplotlib.collections.QuadMesh at 0x7d93978ccb90>
dtree = xd.open_datatree(filename, engine="gamic", 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_fixed_angle (sweep) float64 8B ...
│ sweep_group_name (sweep) int64 8B ...
│ Attributes:
│ Conventions: None
│ instrument_name: None
│ version: None
│ title: None
│ institution: None
│ references: None
│ source: gamic
│ history: None
│ comment: im/exported using xradar
└── Group: /sweep_0
Dimensions: (azimuth: 360, range: 1000)
Coordinates:
* azimuth (azimuth) float64 3kB 0.5191 1.516 2.516 ... 358.5 359.5
elevation (azimuth) float64 3kB ...
time (azimuth) datetime64[ns] 3kB ...
* range (range) float32 4kB 75.0 225.0 ... 1.498e+05 1.499e+05
Data variables: (12/18)
DBZH (azimuth, range) float32 1MB ...
DBZV (azimuth, range) float32 1MB ...
KDP (azimuth, range) float32 1MB ...
RHOHV (azimuth, range) float32 1MB ...
DBTH (azimuth, range) float32 1MB ...
DBTV (azimuth, range) float32 1MB ...
... ...
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="gamic", 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_fixed_angle (sweep) float64 24B ...
│ sweep_group_name (sweep) int64 24B ...
│ Attributes:
│ Conventions: None
│ instrument_name: None
│ version: None
│ title: None
│ institution: None
│ references: None
│ source: gamic
│ history: None
│ comment: im/exported using xradar
├── Group: /sweep_0
│ Dimensions: (azimuth: 361, range: 360)
│ Coordinates:
│ * azimuth (azimuth) float64 3kB 0.5219 1.519 2.53 ... 358.5 359.5
│ elevation (azimuth) float64 3kB ...
│ time (azimuth) datetime64[ns] 3kB ...
│ * range (range) float32 1kB 50.0 150.0 ... 3.585e+04 3.595e+04
│ Data variables: (12/18)
│ DBZH (azimuth, range) float32 520kB ...
│ DBZV (azimuth, range) float32 520kB ...
│ KDP (azimuth, range) float32 520kB ...
│ RHOHV (azimuth, range) float32 520kB ...
│ DBTH (azimuth, range) float32 520kB ...
│ DBTV (azimuth, range) float32 520kB ...
│ ... ...
│ 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: 361, range: 500)
│ Coordinates:
│ * azimuth (azimuth) float64 3kB 0.5246 1.533 2.543 ... 358.5 359.5
│ elevation (azimuth) float64 3kB ...
│ time (azimuth) datetime64[ns] 3kB ...
│ * range (range) float32 2kB 50.0 150.0 ... 4.985e+04 4.995e+04
│ Data variables: (12/18)
│ DBZH (azimuth, range) float32 722kB ...
│ DBZV (azimuth, range) float32 722kB ...
│ KDP (azimuth, range) float32 722kB ...
│ RHOHV (azimuth, range) float32 722kB ...
│ DBTH (azimuth, range) float32 722kB ...
│ DBTV (azimuth, range) float32 722kB ...
│ ... ...
│ 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: 1000)
Coordinates:
* azimuth (azimuth) float64 3kB 0.5191 1.516 2.516 ... 358.5 359.5
elevation (azimuth) float64 3kB ...
time (azimuth) datetime64[ns] 3kB ...
* range (range) float32 4kB 75.0 225.0 ... 1.498e+05 1.499e+05
Data variables: (12/18)
DBZH (azimuth, range) float32 1MB ...
DBZV (azimuth, range) float32 1MB ...
KDP (azimuth, range) float32 1MB ...
RHOHV (azimuth, range) float32 1MB ...
DBTH (azimuth, range) float32 1MB ...
DBTV (azimuth, range) float32 1MB ...
... ...
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="gamic", sweep=["sweep_1", "sweep_2", "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_fixed_angle (sweep) float64 24B ...
│ sweep_group_name (sweep) int64 24B ...
│ Attributes:
│ Conventions: None
│ instrument_name: None
│ version: None
│ title: None
│ institution: None
│ references: None
│ source: gamic
│ history: None
│ comment: im/exported using xradar
├── Group: /sweep_0
│ Dimensions: (azimuth: 361, range: 500)
│ Coordinates:
│ * azimuth (azimuth) float64 3kB 0.5246 1.533 2.543 ... 358.5 359.5
│ elevation (azimuth) float64 3kB ...
│ time (azimuth) datetime64[ns] 3kB ...
│ * range (range) float32 2kB 50.0 150.0 ... 4.985e+04 4.995e+04
│ Data variables: (12/18)
│ DBZH (azimuth, range) float32 722kB ...
│ DBZV (azimuth, range) float32 722kB ...
│ KDP (azimuth, range) float32 722kB ...
│ RHOHV (azimuth, range) float32 722kB ...
│ DBTH (azimuth, range) float32 722kB ...
│ DBTV (azimuth, range) float32 722kB ...
│ ... ...
│ 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: 361, range: 620)
│ Coordinates:
│ * azimuth (azimuth) float64 3kB 0.5191 1.524 2.527 ... 358.5 359.5
│ elevation (azimuth) float64 3kB ...
│ time (azimuth) datetime64[ns] 3kB ...
│ * range (range) float32 2kB 50.0 150.0 ... 6.185e+04 6.195e+04
│ Data variables: (12/18)
│ DBZH (azimuth, range) float32 895kB ...
│ DBZV (azimuth, range) float32 895kB ...
│ KDP (azimuth, range) float32 895kB ...
│ RHOHV (azimuth, range) float32 895kB ...
│ DBTH (azimuth, range) float32 895kB ...
│ DBTV (azimuth, range) float32 895kB ...
│ ... ...
│ 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: 1000)
Coordinates:
* azimuth (azimuth) float64 3kB 0.5191 1.516 2.516 ... 358.5 359.5
elevation (azimuth) float64 3kB ...
time (azimuth) datetime64[ns] 3kB ...
* range (range) float32 4kB 75.0 225.0 ... 1.498e+05 1.499e+05
Data variables: (12/18)
DBZH (azimuth, range) float32 1MB ...
DBZV (azimuth, range) float32 1MB ...
KDP (azimuth, range) float32 1MB ...
RHOHV (azimuth, range) float32 1MB ...
DBTH (azimuth, range) float32 1MB ...
DBTV (azimuth, range) float32 1MB ...
... ...
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 GAMIC reader fills them from the /how attributes of the file (beam widths in radar_parameters, antenna gain, receiver loss and noise power in radar_calibration).
dtree = xd.open_datatree(filename, engine="gamic", sweep=0, optional_groups=True)
display(dtree["radar_parameters"].dataset)
display(dtree["radar_calibration"].dataset)
<xarray.DatasetView> Size: 16B
Dimensions: ()
Data variables:
radar_beam_width_h float64 8B ...
radar_beam_width_v float64 8B ...<xarray.DatasetView> Size: 48B
Dimensions: ()
Data variables:
antenna_gain_h float64 8B ...
antenna_gain_v float64 8B ...
noise_power_h float64 8B ...
noise_power_v float64 8B ...
rx_loss_h float64 8B ...
rx_loss_v float64 8B ...The same with the xarray API:
dtree = xr.open_datatree(filename, engine="gamic", sweep=0, optional_groups=True)
assert dtree["radar_calibration"].antenna_gain_h.attrs["units"] == "dB"
import warnings
with warnings.catch_warnings(record=True) as caught:
warnings.simplefilter("always")
dtree = xr.open_datatree(filename, engine="gamic", optional_groups=True)
print([str(w.message) for w in caught if "differ" in str(w.message)])
assert "noise_power_h" not in dtree["radar_calibration"]
assert dtree["radar_calibration"].antenna_gain_h == 43.0
['xradar: radar_calibration values differ between the sweeps (noise_power_h, noise_power_v) and are left out of the group; use ``sweep=`` to select the sweep whose values you need.']
import numpy as np
np.testing.assert_almost_equal(dtree["radar_parameters"].radar_beam_width_h, 1.0)
np.testing.assert_almost_equal(dtree["radar_calibration"].antenna_gain_h, 43.0)
np.testing.assert_almost_equal(dtree["radar_calibration"].rx_loss_h, 3.0)
The groups hold one set of values: if the sweeps of a file disagree about a value, that value is left out of the group and a warning lists it. In this file only the last scan has another noise power, so for the whole volume radar_calibration has no noise_power_h and noise_power_v. Select the sweep whose values you need with sweep=.