Metek MRR2#
import cmweather # noqa
import matplotlib.pyplot as plt
from open_radar_data import DATASETS
import xradar as xd
xd.io.open_metek_datatree supports the Metek MRR2 processed (.pro, .ave) and raw (.raw) files. The initialized datatree will contain all vertically pointing radar data in one sweep.
In this example, we are loading the 60 s average files from the MRR2 sampling a rain event over the Argonne Testbed for Multiscale Observational Science at Argonne National Laboratory in the Chicago suburbs.
mrr_test_file = DATASETS.fetch("0308.pro.gz")
import gzip
import shutil
decompressed_file = mrr_test_file[:-3]
with gzip.open(mrr_test_file, "rb") as f_in:
with open(decompressed_file, "wb") as f_out:
shutil.copyfileobj(f_in, f_out)
with xd.io.open_metek_datatree(decompressed_file) as ds:
display(ds)
Downloading file '0308.pro.gz' from 'https://github.com/openradar/open-radar-data/raw/main/data/0308.pro.gz' to '/home/docs/.cache/open-radar-data'.
<xarray.DataTree>
Group: /
│ Dimensions: ()
│ Coordinates:
│ latitude float64 8B ...
│ longitude float64 8B ...
│ altitude float64 8B ...
│ Data variables:
│ volume_number int64 8B 0
│ platform_type <U5 20B 'fixed'
│ instrument_type <U5 20B 'radar'
│ time_coverage_start <U20 80B '2024-03-08T23:00:00Z'
│ time_coverage_end <U20 80B '2024-03-08T23:59:57Z'
│ Attributes:
│ Conventions: None
│ instrument_name: None
│ version: None
│ title: None
│ institution: None
│ references: None
│ source: None
│ history: None
│ comment: im/exported using xradar
└── Group: /sweep_0
Dimensions: (sample: 64, time: 362, range: 31, index: 11222)
Coordinates:
velocity_bins (sample) float64 512B ...
* time (time) datetime64[ns] 3kB 2024-03-08T23:00:0...
* range (range) float64 248B 150.0 300.0 ... 4.65e+03
Dimensions without coordinates: sample, index
Data variables: (12/14)
transfer_function (time, range) float64 90kB ...
spectral_reflectivity (index, sample) float64 6MB ...
drop_size (index, sample) float64 6MB ...
drop_number_density (index, sample) float64 6MB ...
percentage_valid_spectra (time) float64 3kB ...
path_integrated_attenuation (time, range) float64 90kB ...
... ...
rainfall_rate (time, range) float64 90kB ...
liquid_water_content (time, range) float64 90kB ...
velocity (time, range) float64 90kB ...
spectrum_index (time, range) float64 90kB ...
azimuth (time) float64 3kB ...
elevation (time) float64 3kB ...View the structure of the loaded datatree.
ds["sweep_0"]
<xarray.DataTree 'sweep_0'>
Group: /sweep_0
Dimensions: (sample: 64, time: 362, range: 31, index: 11222)
Coordinates:
velocity_bins (sample) float64 512B ...
* time (time) datetime64[ns] 3kB 2024-03-08T23:00:0...
* range (range) float64 248B 150.0 300.0 ... 4.65e+03
Dimensions without coordinates: sample, index
Data variables: (12/14)
transfer_function (time, range) float64 90kB ...
spectral_reflectivity (index, sample) float64 6MB ...
drop_size (index, sample) float64 6MB ...
drop_number_density (index, sample) float64 6MB ...
percentage_valid_spectra (time) float64 3kB ...
path_integrated_attenuation (time, range) float64 90kB ...
... ...
rainfall_rate (time, range) float64 90kB ...
liquid_water_content (time, range) float64 90kB ...
velocity (time, range) float64 90kB ...
spectrum_index (time, range) float64 90kB ...
azimuth (time) float64 3kB ...
elevation (time) float64 3kB ...Plot MRR timeseries#
One can use the typical xarray plotting functions for plotting the velocity or other MRR2 variables.
plt.figure(figsize=(10, 3))
ds["sweep_0"]["velocity"].T.plot(cmap="balance", vmin=0, vmax=12)
<matplotlib.collections.QuadMesh at 0x771d3056e120>
Plot MRR spectra#
In order to plot the spectra, you first need to locate the index that corresponds to the given time period. This is done using xarray .sel() functionality to get the indicies.
indicies = ds["sweep_0"]["spectrum_index"].sel(
time="2024-03-08T23:01:00", method="nearest"
)
indicies
ds["sweep_0"]["spectral_reflectivity"].isel(index=indicies).T.plot(
cmap="ChaseSpectral", x="velocity_bins"
)
<matplotlib.collections.QuadMesh at 0x771d3049f390>
Calculate rainfall accumulation estimated from Doppler velocity spectra#
rainfall = ds["sweep_0"]["rainfall_rate"].isel(range=0).cumsum() / 60.0
rainfall.plot()
plt.ylabel("Cumulative rainfall [mm]")
Text(0, 0.5, 'Cumulative rainfall [mm]')