{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Metek MRR2" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import cmweather # noqa\n", "import matplotlib.pyplot as plt\n", "from open_radar_data import DATASETS\n", "\n", "import xradar as xd" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "`xd.io.open_metek_datatree` supports the Metek MRR2 processed (.pro, .ave) and raw (.raw) files. The initalized datatree will contain all of the vertically pointing radar data in one sweep. \n", "\n", "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." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "mrr_test_file = DATASETS.fetch(\"0308.pro.gz\")\n", "!gunzip -f $mrr_test_file\n", "with xd.io.open_metek_datatree(mrr_test_file[:-3]) as ds:\n", " display(ds)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "View the structure of the loaded datatree. " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ds[\"sweep_0\"]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Plot MRR timeseries\n", "\n", "One can use the typical xarray plotting functions for plotting the velocity or other MRR2 variables." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plt.figure(figsize=(10, 3))\n", "ds[\"sweep_0\"][\"velocity\"].T.plot(cmap=\"balance\", vmin=0, vmax=12)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Plot MRR spectra\n", "\n", "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." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "indicies = ds[\"sweep_0\"][\"spectrum_index\"].sel(\n", " time=\"2024-03-08T23:01:00\", method=\"nearest\"\n", ")\n", "indicies\n", "ds[\"sweep_0\"][\"spectral_reflectivity\"].isel(index=indicies).T.plot(\n", " cmap=\"ChaseSpectral\", x=\"velocity_bins\"\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Calculate rainfall accumulation estimated from Doppler velocity spectra" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "rainfall = ds[\"sweep_0\"][\"rainfall_rate\"].isel(range=0).cumsum() / 60.0\n", "rainfall.plot()\n", "plt.ylabel(\"Cumulative rainfall [mm]\")" ] } ], "metadata": { "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.6" } }, "nbformat": 4, "nbformat_minor": 4 }