{ "cells": [ { "cell_type": "markdown", "id": "0", "metadata": {}, "source": [ "# Radarx" ] }, { "cell_type": "code", "execution_count": null, "id": "1", "metadata": {}, "outputs": [], "source": [ "import radarx as rx\n", "import xradar as xd\n", "import cmweather # noqa\n", "import cartopy.crs as ccrs\n", "from datetime import datetime" ] }, { "cell_type": "code", "execution_count": null, "id": "2", "metadata": {}, "outputs": [], "source": [ "def filter_radar(ds):\n", " ds = ds.where((ds.reflectivity >= 0) & (ds.reflectivity <= 70))\n", " return ds" ] }, { "cell_type": "markdown", "id": "3", "metadata": {}, "source": [ "## Grid Setup" ] }, { "cell_type": "code", "execution_count": null, "id": "4", "metadata": {}, "outputs": [], "source": [ "x_lims = (-300e3, 250e3)\n", "y_lims = (-250e3, 300e3)\n", "z_lims = (0, 15e3)\n", "h_res = 2000\n", "v_res = 500" ] }, { "cell_type": "markdown", "id": "5", "metadata": {}, "source": [ "## Load data" ] }, { "cell_type": "code", "execution_count": null, "id": "6", "metadata": {}, "outputs": [], "source": [ "filename = \"KSGF20180612_083109_V06.nc\"" ] }, { "cell_type": "code", "execution_count": null, "id": "7", "metadata": {}, "outputs": [], "source": [ "dtree = xd.io.open_cfradial1_datatree(filename)" ] }, { "cell_type": "code", "execution_count": null, "id": "8", "metadata": {}, "outputs": [], "source": [ "dtree = rx.utils.combine_nexrad_sweeps(dtree)" ] }, { "cell_type": "code", "execution_count": null, "id": "9", "metadata": {}, "outputs": [], "source": [ "dtree = dtree.xradar.map_over_sweeps(filter_radar)" ] }, { "cell_type": "code", "execution_count": null, "id": "10", "metadata": {}, "outputs": [], "source": [ "dtree = dtree.xradar.georeference()\n", "dtree.groups" ] }, { "cell_type": "code", "execution_count": null, "id": "11", "metadata": {}, "outputs": [], "source": [ "dtree[\"sweep_0\"][\"reflectivity\"].plot(\n", " x=\"x\",\n", " y=\"y\",\n", " xlim=(-300e3, 200e3),\n", " ylim=(-200e3, 300e3),\n", " cmap=\"ChaseSpectral\",\n", " levels=range(-10, 70),\n", ")" ] }, { "cell_type": "markdown", "id": "12", "metadata": {}, "source": [ "## Radarx" ] }, { "cell_type": "code", "execution_count": null, "id": "13", "metadata": {}, "outputs": [], "source": [ "tstart = datetime.now()\n", "ds_rx = dtree.radarx.to_grid(\n", " data_vars=[\"reflectivity\"],\n", " pseudo_cappi=False,\n", " x_lim=x_lims,\n", " y_lim=y_lims,\n", " z_lim=z_lims,\n", " x_step=h_res,\n", " y_step=h_res,\n", " z_step=v_res,\n", " x_smth=0.2,\n", " y_smth=0.2,\n", " z_smth=0.6,\n", ")\n", "print(\"Radarx gridding took:\", datetime.now() - tstart)\n", "display(ds_rx)" ] }, { "cell_type": "markdown", "id": "14", "metadata": {}, "source": [ "## Plot" ] }, { "cell_type": "code", "execution_count": null, "id": "15", "metadata": {}, "outputs": [], "source": [ "ds_rx.radarx.plot_max_cappi(\n", " data_var=\"reflectivity\",\n", " vmin=-10,\n", " vmax=70,\n", " range_rings=True,\n", " add_map=True,\n", " projection=ccrs.PlateCarree(),\n", " title=\"Radarx\",\n", ")" ] }, { "cell_type": "code", "execution_count": null, "id": "16", "metadata": {}, "outputs": [], "source": [] } ], "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.7" } }, "nbformat": 4, "nbformat_minor": 5 }