Skip to content

Commit

Permalink
FIX: Add get_azimuth xradar (#1547)
Browse files Browse the repository at this point in the history
* FIX: Fix handling of instrument params

* ADD: Add get_azimuth method to xradar
  • Loading branch information
mgrover1 authored Apr 5, 2024
1 parent 999aaf9 commit 8384897
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
26 changes: 26 additions & 0 deletions pyart/xradar/accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,32 @@ def _find_fields(self, ds):
}
return fields

def get_azimuth(self, sweep, copy=False):
"""
Return an array of azimuth angles for a given sweep.
Parameters
----------
sweep : int
Sweep number to retrieve data for, 0 based.
copy : bool, optional
True to return a copy of the azimuths. False, the default, returns
a view of the azimuths (when possible), changing this data will
change the data in the underlying Radar object.
Returns
-------
azimuths : array
Array containing the azimuth angles for a given sweep.
"""
s = self.get_slice(sweep)
azimuths = self.azimuth["data"][s]
if copy:
return azimuths.copy()
else:
return azimuths


def _point_data_factory(grid, coordinate):
"""Return a function which returns the locations of all points."""
Expand Down
10 changes: 10 additions & 0 deletions tests/xradar/test_accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ def test_get_field(filename=filename):
assert reflectivity.shape == (480, 996)


def test_get_azimuth(filename=filename):
dtree = xd.io.open_cfradial1_datatree(
filename,
optional=False,
)
radar = pyart.xradar.Xradar(dtree)
azimuths = radar.get_azimuth(0)
assert azimuths.shape == (480,)


def test_instrument_parameters(filename=filename):
dtree = xd.io.open_cfradial1_datatree(
filename,
Expand Down

0 comments on commit 8384897

Please sign in to comment.