Skip to content

Commit

Permalink
ADD: Addition of above_toa_filter. (#1586)
Browse files Browse the repository at this point in the history
* ADD: Addition of above_toa_filter.
This filter replaces toa parameter in gridding code and allows for the
user to specify their own remove above toa filter by using the
gatefilter for consistency between both gridding functions.

* STY: PEP8 line fix.

* DOC: Update docstring for toa.

* MNT: Include toa for backwards compatability.

* MNT: Add back old comments.

* MNT: Add back in toa.
  • Loading branch information
zssherman committed Jun 20, 2024
1 parent 99e13b1 commit ce371a0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
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
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

0 comments on commit ce371a0

Please sign in to comment.