Skip to content

Commit

Permalink
better error with az_za_grid set but no az_array or za_array
Browse files Browse the repository at this point in the history
  • Loading branch information
bhazelton authored and steven-murray committed Jun 8, 2023
1 parent bf3c13e commit 986976c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pyuvdata/uvbeam/tests/test_uvbeam.py
Original file line number Diff line number Diff line change
Expand Up @@ -1233,6 +1233,12 @@ def test_spatial_interpolation_errors(cst_power_2freq_cut):
az_array=az_interp_vals, za_array=za_interp_vals, freq_array=np.array([100])
)

# test errors if frequency interp values outside range
with pytest.raises(
ValueError,
match="If az_za_grid is set to True, az_array and za_array must be provided.",
):
uvbeam.interp(az_za_grid=True, freq_array=freq_interp_vals)
# test errors if positions outside range
with pytest.raises(
ValueError,
Expand Down
5 changes: 5 additions & 0 deletions pyuvdata/uvbeam/uvbeam.py
Original file line number Diff line number Diff line change
Expand Up @@ -2311,6 +2311,11 @@ def interp(
kind_use = "nearest"

if az_za_grid:
if az_array is None or za_array is None:
raise ValueError(
"If az_za_grid is set to True, az_array and za_array must be "
"provided."
)
az_array_use, za_array_use = np.meshgrid(az_array, za_array)
az_array_use = az_array_use.flatten()
za_array_use = za_array_use.flatten()
Expand Down

0 comments on commit 986976c

Please sign in to comment.