Skip to content

Commit

Permalink
TST: Fix median filter depreciation warnings as well as more tests fo…
Browse files Browse the repository at this point in the history
…r simple moments. (#1214)

* TST: Fix median filter depreciation warnings as well as more tests for
simple moments.

* TST: Update values.

* MNT: Adding variables for simple moment calculation functions.

* FIX: Removal of depreciation warning for interp namespace.
  • Loading branch information
zssherman authored Jul 22, 2022
1 parent 0a4a9af commit 5ea116f
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 7 deletions.
38 changes: 36 additions & 2 deletions pyart/default_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@

# Normalized coherent power, signal quality index, SQI, NCP
normalized_coherent_power = 'normalized_coherent_power'
logarithmic_cross_correlation_ratio = 'logarithmic_cross_correlation_ratio'

# Differential phase shift, PhiDP
differential_phase = 'differential_phase'
Expand All @@ -75,13 +76,18 @@
specific_differential_phase = 'specific_differential_phase'
corrected_specific_differential_phase = 'corrected_specific_differential_phase'

# Linear depolarization ration (h - horizontal, v - vertical), LDR
# Linear depolarization ratio (h - horizontal, v - vertical), LDR
linear_depolarization_ratio = 'linear_polarization_ratio'
linear_depolarization_ratio_h = 'linear_depolarization_ratio_h'
linear_depolarization_ratio_v = 'linear_depolarization_ratio_v'

# Circular depolarization ratio
circular_depolarization_ratio = 'circular_depolarization_ratio'

# Misc fields
signal_to_noise_ratio = 'signal_to_noise_ratio'
noisedBZ_hh = 'noisedBZ_hh'
noisedBZ_vv = 'noisedBZ_vv'
rain_rate = 'rain_rate'
radar_estimated_rain_rate = 'radar_estimated_rain_rate'
radar_echo_classification = 'radar_echo_classification'
Expand Down Expand Up @@ -163,6 +169,7 @@
'corrected_differential_reflectivity':
corrected_differential_reflectivity,
'cross_correlation_ratio': cross_correlation_ratio,
'logarithmic_cross_correlation_ratio': logarithmic_cross_correlation_ratio,
'normalized_coherent_power': normalized_coherent_power,
'differential_phase': differential_phase,
'unfolded_differential_phase': unfolded_differential_phase,
Expand All @@ -173,7 +180,10 @@
'linear_depolarization_ratio': linear_depolarization_ratio,
'linear_depolarization_ratio_h': linear_depolarization_ratio_h,
'linear_depolarization_ratio_v': linear_depolarization_ratio_v,
'circular_depolarization_ratio': circular_depolarization_ratio,
'signal_to_noise_ratio': signal_to_noise_ratio,
'noisedBZ_hh': noisedBZ_hh,
'noisedBZ_vv': noisedBZ_vv,
'rain_rate': rain_rate,
'radar_estimated_rain_rate': radar_estimated_rain_rate,
'radar_echo_classification': radar_echo_classification,
Expand Down Expand Up @@ -534,6 +544,11 @@
'valid_min': 0.0,
'coordinates': 'elevation azimuth range'},

logarithmic_cross_correlation_ratio: {
'units': 'ratio',
'long_name': 'Logarithmic cross correlation ratio',
'coordinates': 'elevation azimuth range'},

normalized_coherent_power: {
'units': 'ratio',
'standard_name': 'normalized_coherent_power',
Expand Down Expand Up @@ -575,7 +590,6 @@
'long_name': 'Corrected specific differential phase (KDP)',
'coordinates': 'elevation azimuth range'},


# Depolarization ratio fields
linear_depolarization_ratio: {
'units': 'dB',
Expand All @@ -595,13 +609,28 @@
'long_name': 'Linear depolarization ratio vertical',
'coordinates': 'elevation azimuth range'},

circular_depolarization_ratio: {
'units': 'dB',
'long_name': 'Circular depolarization ratio',
'coordinates': 'elevation azimuth range'},

# Misc fields
signal_to_noise_ratio: {
'units': 'dB',
'standard_name': 'signal_to_noise_ratio',
'long_name': 'Signal to noise ratio',
'coordinates': 'elevation azimuth range'},

noisedBZ_hh: {
'units': 'dBZ',
'long_name': 'noise in dBZ horizontal',
'coordinates': 'elevation azimuth range'},

noisedBZ_vv: {
'units': 'dBZ',
'long_name': 'noise in dBZ vertical',
'coordinates': 'elevation azimuth range'},

rain_rate: {
'units': 'kg/m2/s',
'standard_name': 'rain_rate',
Expand Down Expand Up @@ -1435,6 +1464,7 @@ def spectrum_width_limit(container=None, selection=0):
clutter_filter_power_removed: 'pyart_RefDiff',

cross_correlation_ratio: 'pyart_RefDiff',
logarithmic_cross_correlation_ratio: 'pyart_RefDiff',

differential_phase: 'pyart_Wild25',
unfolded_differential_phase: 'pyart_Wild25',
Expand All @@ -1446,6 +1476,7 @@ def spectrum_width_limit(container=None, selection=0):
linear_depolarization_ratio: 'pyart_SCook18',
linear_depolarization_ratio_h: 'pyart_SCook18',
linear_depolarization_ratio_v: 'pyart_SCook18',
circular_depolarization_ratio: 'pyart_SCook18',

rain_rate: 'pyart_RRate11',
radar_estimated_rain_rate: 'pyart_RRate11',
Expand All @@ -1458,6 +1489,9 @@ def spectrum_width_limit(container=None, selection=0):
height: 'pyart_SCook18',
interpolated_profile: 'pyart_SCook18',

noisedBZ_hh: 'pyart_HomeyerRainbow',
noisedBZ_vv: 'pyart_HomeyerRainbow',

# Additional reflectivity like fields
'CZ': 'pyart_HomeyerRainbow',
'DZ': 'pyart_HomeyerRainbow',
Expand Down
4 changes: 2 additions & 2 deletions pyart/retrieve/advection.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import copy

import numpy as np
from scipy.ndimage import interpolation
from scipy.ndimage import shift
from netCDF4 import num2date

from ..config import get_fillvalue
Expand Down Expand Up @@ -147,7 +147,7 @@ def grid_shift(grid, advection, trim_edges=0, field_list=None):
data = np.ma.filled(data, np.nan)

# shift the data
shifted_data = interpolation.shift(
shifted_data = shift(
data, [0, advection[0], advection[1]], prefilter=False)

# mask invalid, trim and place into grid
Expand Down
6 changes: 3 additions & 3 deletions pyart/retrieve/simple_moment_calculations.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def calculate_velocity_texture(radar, vel_field=None, wind_size=4, nyq=None,
vel_texture_field['long_name'] = 'Doppler velocity texture'
vel_texture_field['standard_name'] = (
'texture_of_radial_velocity' + '_of_scatters_away_from_instrument')
vel_texture_field['data'] = ndimage.filters.median_filter(vel_texture,
size=(wind_size,
wind_size))
vel_texture_field['data'] = ndimage.median_filter(vel_texture,
size=(wind_size,
wind_size))
return vel_texture_field
9 changes: 9 additions & 0 deletions tests/retrieve/test_simple_moment_calculations.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
""" Unit Tests for Py-ART's retrieve/simple_moment_calculation.py module. """

import numpy as np
from numpy.testing import assert_allclose
import pyart

# Setup a test radar object for various retrievals
Expand Down Expand Up @@ -66,3 +67,11 @@ def test_calculate_velocity_texture():
texture_field = pyart.retrieve.calculate_velocity_texture(
radar, vel_field, wind_size=4, nyq=10)
assert np.all(texture_field['data'] == 0)

# Test none parameters
radar2 = pyart.io.read(pyart.testing.NEXRAD_ARCHIVE_MSG31_FILE)
texture_field = pyart.retrieve.calculate_velocity_texture(
radar2, vel_field=None, wind_size=4, nyq=None)
assert_allclose(
texture_field['data'][-1][-5:],
[0.000363, 0.000363, 0.000363, 0.000363, 0.000363], atol=1e-03)

0 comments on commit 5ea116f

Please sign in to comment.