Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Improved convective stratiform functions #1314

Merged
merged 74 commits into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from 68 commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
57af278
test adding function
lauratomkins May 25, 2022
5534da8
Create _echo_class_updated.py
lauratomkins May 25, 2022
3dd35fb
Renaming refl to ref
lauratomkins Sep 14, 2022
6fff794
Create yuter_convsf.py
lauratomkins Sep 14, 2022
c573129
Update _echo_class_updated.py
lauratomkins Sep 14, 2022
a131b80
Merge branch 'ARM-DOE:main' into convsf
lauratomkins Sep 14, 2022
bd0c5c1
Merge branch 'convsf' of https://github.com/lauratomkins/pyart into c…
lauratomkins Sep 14, 2022
be7f586
Implement dilation technique for core radius assignment
lauratomkins Sep 14, 2022
899aa56
Add functionality for scalar addition difference
lauratomkins Sep 14, 2022
73ef2d3
Rename variables
lauratomkins Sep 28, 2022
78a105f
Add new function
lauratomkins Sep 28, 2022
e39e5d9
Add functions
lauratomkins Sep 28, 2022
cfb4d67
Remove array creation
lauratomkins Sep 28, 2022
316ce6b
Create conv strat array before assigning
lauratomkins Sep 28, 2022
f3ebded
add background intensity
lauratomkins Sep 28, 2022
e0dc6f8
Adding documentation
lauratomkins Sep 28, 2022
e9242d2
documentation
lauratomkins Sep 28, 2022
3b14a23
Update echo_class.py
lauratomkins Sep 28, 2022
b418d67
Update _echo_class_updated.py
lauratomkins Sep 28, 2022
3306749
Update echo_class.py
lauratomkins Sep 28, 2022
36fa6af
Merge branch 'ARM-DOE:main' into convsf
lauratomkins Sep 28, 2022
630a712
update naming convention
lauratomkins Sep 29, 2022
c68d312
More variable renaming
lauratomkins Sep 29, 2022
63d1fd8
Add function returns
lauratomkins Sep 29, 2022
3ab5dc0
Add function outputs
lauratomkins Sep 29, 2022
38e5b0a
Added threshold for calculating background radius
lauratomkins Sep 29, 2022
ca99b03
Update __init__.py
lauratomkins Oct 4, 2022
8c82a0d
Rename to always_core_threshold
lauratomkins Oct 4, 2022
8486d64
Delete yuter_convsf.py
lauratomkins Oct 4, 2022
d09d3a1
Merge branch 'ARM-DOE:main' into convsf
lauratomkins Oct 11, 2022
4ca1e3e
Placeholders for other function outputs
lauratomkins Oct 11, 2022
8e4077b
Updated documentation
lauratomkins Oct 12, 2022
070eb9f
Remove large radial mask
lauratomkins Oct 14, 2022
549c45d
Add other reference
lauratomkins Oct 14, 2022
e8203cf
Add despeckling abilities
lauratomkins Oct 18, 2022
83ee027
Add check for if reflectivity field is masked
lauratomkins Oct 18, 2022
816ded0
Add functionality for desired level
lauratomkins Oct 18, 2022
d3e3653
Change under to over
lauratomkins Oct 18, 2022
d2749da
Update default max_diff
lauratomkins Oct 18, 2022
1196ca5
Fix masking bugs
lauratomkins Oct 18, 2022
c8cb69a
Set db_averaging default to True
lauratomkins Oct 25, 2022
6e88f99
Add in background radius recommendations and catch
lauratomkins Oct 25, 2022
fcb638d
Merge branch 'ARM-DOE:main' into convsf
lauratomkins Oct 26, 2022
4edd2bd
Merge branch 'convsf' of https://github.com/lauratomkins/pyart into c…
lauratomkins Oct 26, 2022
980f764
Fix m/km correction
lauratomkins Oct 26, 2022
5f4fadb
Update reference
lauratomkins Oct 26, 2022
736cbdf
Update comment
lauratomkins Oct 26, 2022
5a9a226
Add test for new function
lauratomkins Oct 26, 2022
c921a05
Move functions to correct file
lauratomkins Oct 26, 2022
defe56e
Remove unnecessary variables
lauratomkins Oct 26, 2022
2e5a27c
Wrap text in comment
lauratomkins Oct 26, 2022
3dcc93f
Wrap text
lauratomkins Oct 26, 2022
fa8cbdb
Create plot_convective_stratiform.py
lauratomkins Nov 2, 2022
9c92ed7
Add description
lauratomkins Nov 4, 2022
6f0eae4
Add plotting function
lauratomkins Nov 4, 2022
af5b7d2
Add DOI
lauratomkins Nov 4, 2022
c59d1f6
Add variable description for plot function
lauratomkins Nov 4, 2022
2bd8f3d
Merge branch 'ARM-DOE:main' into convsf
lauratomkins Nov 4, 2022
e726f1f
Delete test.py
lauratomkins Nov 4, 2022
cd96cc3
Merge remote-tracking branch 'upstream/main' into convsf
lauratomkins Nov 8, 2022
b64da94
Move plotting function to graph
lauratomkins Nov 8, 2022
21923fc
Delete plot_rhi_sigmet.py
lauratomkins Nov 8, 2022
95117b2
Remove hard coding of constants
lauratomkins Nov 8, 2022
c1400d2
Rename function to conv_strat_yuter
lauratomkins Nov 8, 2022
e815f47
Update level_m description
lauratomkins Nov 8, 2022
bc1de5a
Make constants lowercase
lauratomkins Nov 8, 2022
53292fa
Remove plt.show()
lauratomkins Nov 8, 2022
dc3a780
Update function name in example
lauratomkins Nov 9, 2022
6d1aec1
Update test_echo_class.py
lauratomkins Nov 9, 2022
227e245
Update tests/io/test_mdv_grid.py
lauratomkins Nov 9, 2022
13284ee
Update test_mdv_grid.py
lauratomkins Nov 9, 2022
3848cb1
Update custom_config.py
lauratomkins Nov 9, 2022
a34a7ca
Update default_config.py
lauratomkins Nov 9, 2022
f7f6829
Update attenuation.py
lauratomkins Nov 9, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
334 changes: 334 additions & 0 deletions examples/retrieve/plot_convective_stratiform.py

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions pyart/correct/attenuation.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def calculate_attenuation_zphi(radar, doc=None, fzl=None, smooth_window_len=5,
----------
radar : Radar
Radar object to use for attenuation calculations. Must have
phidp and refl fields.
phidp and ref fields.
doc : float, optional
Number of gates at the end of each ray to to remove from the
calculation.
Expand Down Expand Up @@ -243,7 +243,7 @@ def calculate_attenuation_zphi(radar, doc=None, fzl=None, smooth_window_len=5,

if end_gate_arr[ray] > smooth_window_len:
# extract the ray's phase shift,
# init. refl. correction and mask
# init. ref. correction and mask
ray_phase_shift = corr_phidp[ray, 0:end_gate_arr[ray]]
ray_mask = mask[ray, 0:end_gate_arr[ray]]
ray_refl_linear = refl_linear[ray, 0:end_gate_arr[ray]]
Expand Down Expand Up @@ -335,7 +335,7 @@ def calculate_attenuation_philinear(
----------
radar : Radar
Radar object to use for attenuation calculations. Must have
phidp and refl fields.
phidp and ref fields.
doc : float, optional
Number of gates at the end of each ray to to remove from the
calculation.
Expand Down Expand Up @@ -922,7 +922,7 @@ def calculate_attenuation(radar, z_offset, debug=False, doc=15, fzl=4000.0,
for i in range(start_ray, end_ray):
# perform attenuation calculation on a single ray

# extract the ray's phase shift and init. refl. correction
# extract the ray's phase shift and init. ref. correction
ray_phase_shift = proc_dp_phase_shift[i, 0:end_gate]
ray_init_refl = init_refl_correct[i, 0:end_gate]

Expand Down
14 changes: 7 additions & 7 deletions pyart/default_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1024,9 +1024,9 @@
'HCLASS': radar_echo_classification, # (55) Hydrometeor class
'HCLASS2': radar_echo_classification, # (56) Hydrometeor class
'ZDRC': corrected_differential_reflectivity,
# (57) Corrected diff. refl.
# (57) Corrected diff. ref.
'ZDRC2': corrected_differential_reflectivity,
# (58) Corrected diff. refl.
# (58) Corrected diff. ref.
'UNKNOWN_59': None, # Unknown field
'UNKNOWN_60': None, # Unknown field
'UNKNOWN_61': None, # Unknown field
Expand Down Expand Up @@ -1319,11 +1319,11 @@
'ZDR': corrected_differential_reflectivity,
# Differential reflectivity from corrected timeseries
'UZDR': differential_reflectivity,
# Diff. refl. from uncorrected timeseries
'AZDR': None, # Diff. refl., rainfall atten. corr., corr t.s.
'ZDR1': None, # Diff. refl., corr. t.s., 1st LAG algo.
'UZDR1': None, # Diff. refl., uncorr. t.s., 1st LAG algo.
'AZDR1': None, # Diff. refl., rain. atten. corr., corr. t.s., 1st LAG
# Diff. ref. from uncorrected timeseries
'AZDR': None, # Diff. ref., rainfall atten. corr., corr t.s.
'ZDR1': None, # Diff. ref., corr. t.s., 1st LAG algo.
'UZDR1': None, # Diff. ref., uncorr. t.s., 1st LAG algo.
'AZDR1': None, # Diff. ref., rain. atten. corr., corr. t.s., 1st LAG

'PHI': corrected_differential_phase,
# Differential phase from corrected timeseries
Expand Down
1 change: 1 addition & 0 deletions pyart/graph/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,6 @@
from .gridmapdisplay_basemap import GridMapDisplayBasemap
from .radarmapdisplay import RadarMapDisplay
from .radarmapdisplay_basemap import RadarMapDisplayBasemap
from .convstrat_scheme_plot import plot_convstrat_scheme

__all__ = [s for s in dir() if not s.startswith('_')]
76 changes: 76 additions & 0 deletions pyart/graph/convstrat_scheme_plot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import numpy as np
import matplotlib.pyplot as plt

def plot_convstrat_scheme(always_core_thres, use_cosine, max_diff=None, zero_diff_cos_val=None,
use_addition=False, scalar_diff=None):
"""
Plots the scheme used in the convective stratiform classification

Parameters
----------
always_core_thres : float
All values above this threshold considered to be convective
use_cosine : bool
Boolean used to determine if cosine scheme should be used for identifying convective cores (True) or a scalar
scheme (False)
max_diff : float, optional
Maximum difference between background average and reflectivity in order to be classified as convective.
"a" value in Eqn. B1 in Yuter and Houze (1997)
zero_diff_cos_val : float, optional
Value where difference between background average and reflectivity is zero in the cosine function
"b" value in Eqn. B1 in Yuter and Houze (1997)
use_addition : bool, optional
Determines if a multiplier (False) or addition (True) in the scalar difference scheme should be used
scalar_diff : float, optional
If using a scalar difference scheme, this value is the multiplier or addition to the background average

"""

# create array of background values
bkg_vals = np.linspace(0, 60, 100)

# create difference array
if use_cosine:
# cosine scheme
diff = max_diff * np.cos(np.pi * bkg_vals / (2 * zero_diff_cos_val))
else:
if use_addition:
# scalar addition scheme
diff = (bkg_vals + scalar_diff) - bkg_vals
else:
# scalar multiplier scheme
diff = (bkg_vals * scalar_diff) - bkg_vals

# if values are less than zero, set to zero
diff[diff < 0] = 0
# background values greater than always core thres, set to zero
diff[bkg_vals > always_core_thres] = 0

# Now plot
fig = plt.figure()
ax = plt.gca()
# plot difference line
ax.plot(bkg_vals, diff, lw=2, color='black')
# plot always core thres
ax.axvline(x=always_core_thres, lw=1, ls='--', color='red')
ax.text(always_core_thres+2, 1, 'Always Core Thres.', color='red')
if use_cosine:
# plot zero difference cosine value
ax.axvline(x=zero_diff_cos_val, lw=1, ls='--', color='green')
ax.text(zero_diff_cos_val+2, 0.75, 'Zero Diff. Cosine Val.', color='green')
# plot max difference
ax.axhline(y=max_diff, lw=1, ls='--', color='blue')
ax.text(10, max_diff+0.05, 'Max. Diff.', color='blue')
elif use_addition:
# plot scalar
ax.axhline(y=scalar_diff, lw=1, ls='--', color='orange')
ax.text(10, scalar_diff+0.05, 'Scalar Diff.', color='orange')
# add grid
ax.grid()
# set axis limits
ax.set_ylim([0, np.max(diff) + 0.2])
ax.set_xlim([np.min(bkg_vals), np.max(bkg_vals)])
# set axis labels and title
ax.set_ylabel('Difference (dBZ - dBZ$_{background}$)')
ax.set_xlabel('Background Value (dBZ$_{background}$)')
ax.set_title('Convective Stratiform Equation')
2 changes: 1 addition & 1 deletion pyart/retrieve/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""

from .kdp_proc import kdp_maesaka, kdp_schneebeli, kdp_vulpiani
from .echo_class import steiner_conv_strat, hydroclass_semisupervised
from .echo_class import steiner_conv_strat, conv_strat_yuter, hydroclass_semisupervised
from .echo_class import get_freq_band
from .gate_id import map_profile_to_gates, fetch_radar_time_profile
from .simple_moment_calculations import calculate_snr_from_reflectivity
Expand Down
Loading