-
Notifications
You must be signed in to change notification settings - Fork 269
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ADD: ZDR bias code from RadTraQ (#1630)
* ADD: ZDR bias calculations from Radtraq * ADD: Example for gallery * ADD: ZDR bias calculations * FIX: Revert back for spectra_calculations.py * FIX: Restore phase proc from main branch * STY: Black and ruff changes. * FIX: Duplicate entries in __init__ and obj to radar * FIX: Reinsert calc_bias * FIX: Never mind, there were two calc_biases --------- Co-authored-by: Zach Sherman <[email protected]>
- Loading branch information
Showing
4 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
""" | ||
ZDR Bias Calculation | ||
--------------------- | ||
This example shows how to calculate the ZDR bias from VPT/Birdbath scans. | ||
The technique here uses a vertically pointing scan in regions of light rain. | ||
In these regions, raindrops should be approximately spherical and therefore their | ||
ZDR near zero. Therefore, we want the average ZDR in these regions. | ||
This code applies reflectivity and cross correlation ratio-based thresholds to the ZDR | ||
bias calculation to ensure that we are taking the average ZDR in light rain. | ||
""" | ||
|
||
import matplotlib.pyplot as plt | ||
from open_radar_data import DATASETS | ||
|
||
import pyart | ||
|
||
# Read in example data | ||
filename = DATASETS.fetch("sgpxsaprcfrvptI4.a1.20200205.100827.nc") | ||
ds = pyart.io.read(filename) | ||
|
||
# Set up a typical filter for ZDR bias calculation in birdbath scan | ||
# Light rain and RhoHV near 1 ensures that raindrops are close to spherical | ||
# Therefore ZDR should be zero in these regions | ||
gatefilter = pyart.filters.GateFilter(ds) | ||
gatefilter.exclude_below("cross_correlation_ratio_hv", 0.995) | ||
gatefilter.exclude_above("cross_correlation_ratio_hv", 1) | ||
gatefilter.exclude_below("reflectivity", 10) | ||
gatefilter.exclude_above("reflectivity", 30) | ||
|
||
results = pyart.correct.calc_zdr_offset( | ||
ds, | ||
zdr_var="differential_reflectivity", | ||
gatefilter=gatefilter, | ||
height_range=(1000, 3000), | ||
) | ||
|
||
print("Zdr Bias: " + "{:.2f}".format(results["bias"])) | ||
|
||
fig, ax = plt.subplots(1, 3, figsize=(8, 5)) | ||
ax[0].plot(results["profile_zdr"], results["range"]) | ||
ax[0].set_ylabel("Range (m)") | ||
ax[0].set_xlabel("Zdr (dB)") | ||
ax[1].plot(results["profile_reflectivity"], results["range"]) | ||
ax[1].set_xlabel("Zh (dBZ)") | ||
ax[2].plot(results["profile_cross_correlation_ratio_hv"], results["range"]) | ||
ax[2].set_xlabel("RhoHV ()") | ||
fig.tight_layout() | ||
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters