{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# ZDR Bias Calculation\n\nThis example shows how to calculate the ZDR bias from VPT/Birdbath scans.\nThe technique here uses a vertically pointing scan in regions of light rain.\nIn these regions, raindrops should be approximately spherical and therefore their\nZDR near zero. Therefore, we want the average ZDR in these regions.\nThis code applies reflectivity and cross correlation ratio-based threshold to the ZDR\nbias calculation to ensure that we are taking the average ZDR in light rain.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\nimport xradar as xd\nfrom open_radar_data import DATASETS\n\nimport pyart\n\n# Read in example data\nfilename = DATASETS.fetch(\"sgpxsaprcfrvptI4.a1.20200205.100827.nc\")\n\n# Read in the data\ntree = xd.io.open_cfradial1_datatree(filename)\nradar = tree.pyart.to_radar()\n\n# Set up a typical filter for ZDR bias calculation in birdbath scan\n# Light rain and RhoHV near 1 ensures that raindrops are close to spherical\n# Therefore ZDR should be zero in these regions\ngatefilter = pyart.filters.GateFilter(radar)\ngatefilter.exclude_below(\"cross_correlation_ratio_hv\", 0.995)\ngatefilter.exclude_above(\"cross_correlation_ratio_hv\", 1)\ngatefilter.exclude_below(\"reflectivity\", 10)\ngatefilter.exclude_above(\"reflectivity\", 30)\n\nresults = pyart.correct.calc_zdr_offset(\n radar,\n zdr_var=\"differential_reflectivity\",\n gatefilter=gatefilter,\n height_range=(1000, 3000),\n)\n\nprint(\"Zdr Bias: \" + \"{:.2f}\".format(results[\"bias\"]))\n\nfig, ax = plt.subplots(1, 3, figsize=(8, 5))\nax[0].plot(results[\"profile_zdr\"], results[\"range\"])\nax[0].set_ylabel(\"Range (m)\")\nax[0].set_xlabel(\"Zdr (dB)\")\nax[1].plot(results[\"profile_reflectivity\"], results[\"range\"])\nax[1].set_xlabel(\"Zh (dBZ)\")\nax[2].plot(results[\"profile_cross_correlation_ratio_hv\"], results[\"range\"])\nax[2].set_xlabel(\"RhoHV ()\")\nfig.tight_layout()\nplt.show()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "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.14.3" } }, "nbformat": 4, "nbformat_minor": 0 }