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

Add tests for simple moments #1066

Merged
merged 3 commits into from
Mar 10, 2022
Merged
Changes from all commits
Commits
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
47 changes: 39 additions & 8 deletions pyart/retrieve/tests/test_simple_moment_calculations.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,51 @@
import numpy as np
import pyart

# Setup a test radar object for various retrievals
test_radar = pyart.testing.make_empty_ppi_radar(100, 360, 5)
test_radar.range['data'] = test_radar.range['data'] * 100.0
range_grid = np.meshgrid(
test_radar.range['data'],
np.ma.ones(test_radar.time['data'].shape))[0] + 1.0
foo_field = {'data': np.zeros(
[360 * 5, 100]) + 20.0 * np.log10(range_grid / 1000.)}
test_radar.add_field('reflectivity', foo_field)


def test_calculate_snr_from_reflectivity():
test_radar = pyart.testing.make_empty_ppi_radar(100, 360, 5)
test_radar.range['data'] = test_radar.range['data'] * 100.0
range_grid = np.meshgrid(
test_radar.range['data'],
np.ma.ones(test_radar.time['data'].shape))[0] + 1.0
foo_field = {'data': np.zeros(
[360 * 5, 100]) + 20.0 * np.log10(range_grid / 1000.)}
test_radar.add_field('reflectivity', foo_field)
"""Test the calculate_snr_from_reflectivity function from pyart.retrieve"""
snr = pyart.retrieve.calculate_snr_from_reflectivity(test_radar, toa=500)
assert snr['data'].mean() < 1e-6


def test_compute_noisedBZ():
"""Test the compute_noisedBZ function from pyart.retrieve"""
noise = pyart.retrieve.compute_noisedBZ(nrays=test_radar.nrays,
noisedBZ_val=1.,
_range=test_radar.range['data'],
ref_dist=1.,
noise_field='noisedBZ_hh')
test_radar.add_field_like
assert noise['data'].min() > 1.
assert noise['data'].max() < 45.


def test_compute_snr():
noise = pyart.retrieve.compute_noisedBZ(nrays=test_radar.nrays,
noisedBZ_val=1.,
_range=test_radar.range['data'],
ref_dist=1.,
noise_field='noisedBZ_hh')
# Add the noise field to the radar
test_radar.add_field('noisedBZ_hh', noise)

# Calculate snr from reflectivity and noise
snr = pyart.retrieve.compute_snr(test_radar,
refl_field='reflectivity',
noise_field='noisedBZ_hh')
assert snr['data'].min() > -1.


def test_calculate_velocity_texture():
radar = pyart.testing.make_empty_ppi_radar(10, 36, 1)

Expand Down