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: Addition of above_toa_filter. #1586

Merged
merged 6 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
8 changes: 8 additions & 0 deletions pyart/filters/gatefilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,14 @@ def exclude_above(
marked = self._get_fdata(field) > value
return self._merge(marked, op, exclude_masked)

def exclude_above_toa(self, value, exclude_masked=True, op="or", inclusive=False):
"""Exclude gates above a given toa value."""
if inclusive:
marked = self._radar.gate_altitude["data"] >= value
else:
marked = self._radar.gate_altitude["data"] > value
return self._merge(marked, op, exclude_masked)

def exclude_inside(
self, field, v1, v2, exclude_masked=True, op="or", inclusive=True
):
Expand Down
1 change: 0 additions & 1 deletion pyart/map/gates_to_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def map_gates_to_grid(
gatefilters=False,
map_roi=True,
weighting_function="Barnes2",
toa=17000.0,
roi_func="dist_beam",
constant_roi=None,
z_factor=0.05,
Expand Down
11 changes: 11 additions & 0 deletions tests/filters/test_gatefilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,17 @@ def test_gatefilter_exclude_above():
assert gfilter.gate_excluded[0, -1] is np.True_


def test_gatefilter_exclude_above_toa():
gfilter = pyart.correct.GateFilter(radar)
gfilter.exclude_above_toa(211.0)
assert gfilter.gate_excluded[0, 0] is np.False_
assert gfilter.gate_excluded[0, -1] is np.True_

assert gfilter.gate_excluded[0, -2] is np.False_
gfilter.exclude_above_toa(211.0, inclusive=True)
assert gfilter.gate_excluded[0, -2] is np.True_


def test_gatefilter_exclude_inside():
gfilter = pyart.correct.GateFilter(radar)
gfilter.exclude_inside("test_field", 2, 5, inclusive=False)
Expand Down
Loading