Skip to content

Commit

Permalink
bug correction in overplotting of grid data. Improvements in the read…
Browse files Browse the repository at this point in the history
…ing of user-defined parameters
  • Loading branch information
figuerasiventuraj committed Jun 2, 2023
1 parent f8e0c08 commit cadff8e
Show file tree
Hide file tree
Showing 6 changed files with 217 additions and 150 deletions.
13 changes: 13 additions & 0 deletions config/pyart/mf_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@

unfiltered_differential_reflectivity = 'unfiltered_differential_reflectivity'

corrected_unfiltered_differential_reflectivity = (
'corrected_unfiltered_differential_reflectivity')

differential_reflectivity_in_precipitation = (
'differential_reflectivity_in_precipitation')

Expand Down Expand Up @@ -570,6 +573,8 @@
'corrected_differential_reflectivity': corrected_differential_reflectivity,
'unfiltered_differential_reflectivity': (
unfiltered_differential_reflectivity),
'corrected_unfiltered_differential_reflectivity': (
corrected_unfiltered_differential_reflectivity),
'differential_reflectivity_in_precipitation': (
differential_reflectivity_in_precipitation),
'differential_reflectivity_in_snow': differential_reflectivity_in_snow,
Expand Down Expand Up @@ -1661,6 +1666,12 @@
'standard_name': 'differential_reflectivity',
'long_name': 'Unfiltered differential reflectivity',
'coordinates': 'elevation azimuth range'},

corrected_unfiltered_differential_reflectivity: {
'units': 'dB',
'standard_name': 'differential_reflectivity',
'long_name': 'Unfiltered differential reflectivity',
'coordinates': 'elevation azimuth range'},

differential_reflectivity_in_precipitation: {
'units': 'dB',
Expand Down Expand Up @@ -3926,6 +3937,7 @@ def spectrum_width_limit(container=None, selection=0):
differential_reflectivity: 'pyart_RefDiff',
corrected_differential_reflectivity: 'pyart_RefDiff',
unfiltered_differential_reflectivity: 'pyart_RefDiff',
corrected_unfiltered_differential_reflectivity: 'pyart_RefDiff',
differential_reflectivity_in_precipitation: 'pyart_RefDiff',
differential_reflectivity_in_snow: 'pyart_RefDiff',
differential_reflectivity_column_height: 'pyart_RefDiff',
Expand Down Expand Up @@ -4194,6 +4206,7 @@ def spectrum_width_limit(container=None, selection=0):
corrected_differential_reflectivity: (-1., 2.),
#unfiltered_differential_reflectivity: (-1., 8.),
unfiltered_differential_reflectivity: (-10., 10.),
corrected_unfiltered_differential_reflectivity: (-10., 10.),
differential_reflectivity_in_precipitation: (-10., 10.),
differential_reflectivity_in_snow: (-10., 10.),
differential_reflectivity_column_height: (0., 6.),
Expand Down
66 changes: 34 additions & 32 deletions src/pyrad_proc/pyrad/graph/plots_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,26 +117,43 @@ def plot_surface(grid, field_name, level, prdcfg, fname_list, titl=None,
lon_lines = np.arange(np.floor(min_lon), np.ceil(max_lon)+1, lonstep)
lat_lines = np.arange(np.floor(min_lat), np.ceil(max_lat)+1, latstep)

if use_basemap:
resolution = prdcfg['gridMapImageConfig'].get('mapres', 'l')
if resolution not in ('c', 'l', 'i', 'h', 'f'):
warn('Unknown map resolution: '+resolution)
resolution = 'l'

if resolution == 'c':
area_thresh = 10000
elif resolution == 'l':
area_thresh = 1000
elif resolution == 'i':
area_thresh = 100
elif resolution == 'h':
area_thresh = 10
elif resolution == 'f':
area_thresh = 1
else:
resolution = prdcfg['gridMapImageConfig'].get('mapres', '110m')
# Map from basemap to cartopy notation
if resolution == 'l':
resolution = '110m'
elif resolution == 'i':
resolution = '50m'
elif resolution == 'h':
resolution = '10m'

if resolution not in ('110m', '50m', '10m'):
warn('Unknown map resolution: '+resolution)
resolution = '110m'
background_zoom = prdcfg['gridMapImageConfig'].get(
'background_zoom', 8)
maps_list = prdcfg['gridMapImageConfig'].get('maps', [])

if fig is None:
fig = plt.figure(figsize=[xsize, ysize], dpi=dpi)

if use_basemap:
resolution = prdcfg['gridMapImageConfig'].get('mapres', 'l')
if resolution not in ('c', 'l', 'i', 'h', 'f'):
warn('Unknown map resolution: '+resolution)
resolution = 'l'

if resolution == 'c':
area_thresh = 10000
elif resolution == 'l':
area_thresh = 1000
elif resolution == 'i':
area_thresh = 100
elif resolution == 'h':
area_thresh = 10
elif resolution == 'f':
area_thresh = 1

display = pyart.graph.GridMapDisplayBasemap(grid)
display.plot_basemap(
lat_lines=lat_lines, lon_lines=lon_lines,
Expand All @@ -148,22 +165,7 @@ def plot_surface(grid, field_name, level, prdcfg, fname_list, titl=None,
ticklabs=ticklabs, mask_outside=mask_outside, vmin=vmin,
vmax=vmax, alpha=alpha, fig=fig)
else:
resolution = prdcfg['gridMapImageConfig'].get('mapres', '110m')
projection = cartopy.crs.PlateCarree()
# Map from basemap to cartopy notation
if resolution == 'l':
resolution = '110m'
elif resolution == 'i':
resolution = '50m'
elif resolution == 'h':
resolution = '10m'

if resolution not in ('110m', '50m', '10m'):
warn('Unknown map resolution: '+resolution)
resolution = '110m'
background_zoom = prdcfg['gridMapImageConfig'].get(
'background_zoom', 8)
maps_list = prdcfg['gridMapImageConfig'].get('maps', [])

display = pyart.graph.GridMapDisplay(grid)
display.plot_grid(
Expand All @@ -187,7 +189,7 @@ def plot_surface(grid, field_name, level, prdcfg, fname_list, titl=None,
else:
display.plot_grid(
field_name, level=level, norm=norm, ticks=ticks,
projection=projection, lat_lines=lat_lines,
projection=ax.projection, lat_lines=lat_lines,
lon_lines=lon_lines, ticklabs=ticklabs, colorbar_flag=False,
embellish=False, vmin=vmin, vmax=vmax,
mask_outside=mask_outside, alpha=alpha, title=titl, ax=ax,
Expand Down
46 changes: 34 additions & 12 deletions src/pyrad_proc/pyrad/proc/process_echoclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ def process_echo_id(procstatus, dscfg, radar_list=None):
datatype : list of string. Dataset keyword
The input data types
wind_size : int
Size of the moving window used to compute the ray texture
(number of gates). Default 7
max_textphi, max_textrhv, max_textzdr, max_textrefl : float
Maximum value for the texture of the differential phase, texture
of RhoHV, texture of Zdr and texture of reflectivity. Gates in
these. Default 20, 0.3, 2.85, 8
min_rhv : float
Minimum value for the RhoHV. Default 0.6
radar_list : list of Radar objects
Optional. list of radar objects
Expand Down Expand Up @@ -110,13 +119,21 @@ def process_echo_id(procstatus, dscfg, radar_list=None):

echo_id = np.ma.zeros((radar.nrays, radar.ngates), dtype=np.uint8)+3

# user defined parameters
wind_size = dscfg.get('wind_size', 7)
max_textphi = dscfg.get('max_textphi', 20.)
max_textrhv = dscfg.get('max_textrhv', 0.3)
max_textzdr = dscfg.get('max_textzdr', 2.85)
max_textrefl = dscfg.get('max_textrefl', 8.)
min_rhv = dscfg.get('min_rhv', 0.6)

# look for clutter
gatefilter = pyart.filters.moment_and_texture_based_gate_filter(
radar, zdr_field=zdr_field, rhv_field=rhv_field, phi_field=phi_field,
refl_field=refl_field, textzdr_field=None, textrhv_field=None,
textphi_field=None, textrefl_field=None, wind_size=7,
max_textphi=20., max_textrhv=0.3, max_textzdr=2.85,
max_textrefl=8., min_rhv=0.6)
textphi_field=None, textrefl_field=None, wind_size=wind_size,
max_textphi=max_textphi, max_textrhv=max_textrhv,
max_textzdr=max_textzdr, max_textrefl=max_textrefl, min_rhv=min_rhv)

is_clutter = gatefilter.gate_excluded == 1
echo_id[is_clutter] = 2
Expand Down Expand Up @@ -512,6 +529,9 @@ def process_echo_filter(procstatus, dscfg, radar_list=None):
elif field_name.startswith('uncorrected_'):
new_field_name = field_name.replace(
'uncorrected_', 'corrected_', 1)
elif field_name.startswith('unfiltered_'):
new_field_name = field_name.replace(
'unfiltered_', 'corrected_', 1)
else:
new_field_name = 'corrected_'+field_name
new_dataset['radar_out'].add_field(new_field_name, radar_field)
Expand Down Expand Up @@ -635,7 +655,7 @@ def process_filter_snr(procstatus, dscfg, radar_list=None):

for datatypedescr in dscfg['datatype']:
radarnr, _, datatype, _, _ = get_datatype_fields(datatypedescr)
if datatype in ('SNRh', 'SNRv', 'SNR','CNR'):
if datatype in ('SNRh', 'SNRv', 'SNR', 'CNR'):
snr_field = get_fieldname_pyart(datatype)
break

Expand Down Expand Up @@ -671,7 +691,6 @@ def process_filter_snr(procstatus, dscfg, radar_list=None):
if min_snr is not None:
gatefilter.exclude_below(snr_field, min_snr)


is_low_snr = gatefilter.gate_excluded == 1

for datatypedescr in dscfg['datatype']:
Expand Down Expand Up @@ -823,7 +842,7 @@ def process_filter_visibility(procstatus, dscfg, radar_list=None):
if datatype == 'VIS':
vis_field = get_fieldname_pyart(datatype)
break
elif 'visibility_polar' in datatype: # from GECSX
elif 'visibility_polar' in datatype: # from GECSX
vis_field = get_fieldname_pyart('visibility_polar')

ind_rad = int(radarnr[5:8])-1
Expand Down Expand Up @@ -1064,8 +1083,8 @@ def process_filter_vol2bird(procstatus, dscfg, radar_list=None):

field_name = get_fieldname_pyart(datatype)
if field_name not in radar.fields:
warn('Unable to filter {} according to VOL2BIRD_CLASS. No valid input fields'.format(
field_name))
warn(f'Unable to filter {field_name} according to VOL2BIRD_CLASS.'
f' No valid input fields')
continue
radar_field = deepcopy(radar.fields[field_name])
radar_field['data'] = np.ma.masked_where(
Expand Down Expand Up @@ -1363,8 +1382,9 @@ def process_hydroclass(procstatus, dscfg, radar_list=None):
try:
fields_dict = pyart.retrieve.hydroclass_semisupervised(
radar, hydro_names=hydro_names, var_names=var_names,
mass_centers=mass_centers, weights=weights, refl_field=refl_field,
zdr_field=zdr_field, rhv_field=rhv_field, kdp_field=kdp_field,
mass_centers=mass_centers, weights=weights,
refl_field=refl_field, zdr_field=zdr_field,
rhv_field=rhv_field, kdp_field=kdp_field,
temp_field=temp_field, iso0_field=iso0_field, hydro_field=None,
entropy_field=None, temp_ref=temp_ref,
compute_entropy=compute_entropy,
Expand Down Expand Up @@ -2181,9 +2201,11 @@ def process_melting_layer(procstatus, dscfg, radar_list=None):
continue

ml_top = (
radar_ml.fields['melting_layer_height']['data'][:, 1])
radar_ml.fields['melting_layer_height']['data'][
:, 1])
ml_bottom = (
radar_ml.fields['melting_layer_height']['data'][:, 0])
radar_ml.fields['melting_layer_height']['data'][
:, 0])
ml_thickness = ml_top-ml_bottom
ml_bottom_arr = np.ma.append(
ml_bottom_arr,
Expand Down
Loading

0 comments on commit cadff8e

Please sign in to comment.