Skip to content

Commit

Permalink
Updates regrid2
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonb5 committed Nov 7, 2023
1 parent 2e58cd7 commit df2d23a
Show file tree
Hide file tree
Showing 2 changed files with 156 additions and 255 deletions.
33 changes: 8 additions & 25 deletions tests/test_regrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,23 +387,6 @@ def test_vertical_placeholder(self):
with pytest.raises(NotImplementedError, match=""):
regridder.vertical("so", ds)

def test_missing_dimension(self):
ds = fixtures.generate_dataset(
decode_times=True, cf_compliant=False, has_bounds=True
)

del ds.lat.attrs["axis"]

output_grid = grid.create_gaussian_grid(32)

regridder = regrid2.Regrid2Regridder(ds, output_grid)

with pytest.raises(
RuntimeError,
match="Could not find axis 'lat', ensure 'lat' exists and the attributes are correct.",
):
regridder.horizontal("ts", ds)

@pytest.mark.filterwarnings("ignore:.*invalid value.*divide.*:RuntimeWarning")
def test_output_bounds(self):
ds = fixtures.generate_dataset(
Expand Down Expand Up @@ -567,10 +550,10 @@ def test_map_longitude_coarse_to_fine(self):
]

expected_weigths = [
[[90]],
[[90]],
[[90]],
[[90]],
[90],
[90],
[90],
[90],
]

np.testing.assert_allclose(mapping, expected_mapping)
Expand All @@ -586,7 +569,7 @@ def test_map_longitude_fine_to_coarse(self):
[2, 3],
]

expected_weigths = [[[90, 90]], [[90, 90]]]
expected_weigths = [[90, 90], [90, 90]]

np.testing.assert_allclose(mapping, expected_mapping)
np.testing.assert_allclose(weights, expected_weigths)
Expand Down Expand Up @@ -632,9 +615,9 @@ def test_map_latitude_fine_to_coarse(self):
]

expected_weigths = [
[[0.29289322], [0.20710678]],
[[0.5], [0.5]],
[[0.20710678], [0.29289322]],
[0.29289322, 0.20710678],
[0.5, 0.5],
[0.20710678, 0.29289322],
]

np.testing.assert_allclose(mapping, expected_mapping)
Expand Down
Loading

0 comments on commit df2d23a

Please sign in to comment.