@@ -27,35 +27,11 @@ def fixture_grid():
27
27
return load_static_earth_relief ()
28
28
29
29
30
- @pytest .fixture (scope = "module" , name = "expected_clipped_grid" )
31
- def fixture_expected_clipped_grid ():
32
- """
33
- The expected grdclip grid result.
34
- """
35
- return xr .DataArray (
36
- data = [
37
- [1000.0 , 570.5 , - 1000.0 , - 1000.0 ],
38
- [1000.0 , 1000.0 , 571.5 , 638.5 ],
39
- [555.5 , 556.0 , 580.0 , 1000.0 ],
40
- ],
41
- coords = {"lon" : [- 52.5 , - 51.5 , - 50.5 , - 49.5 ], "lat" : [- 18.5 , - 17.5 , - 16.5 ]},
42
- dims = ["lat" , "lon" ],
43
- )
44
-
45
-
46
30
@pytest .fixture (scope = "module" , name = "expected_equalized_grid" )
47
31
def fixture_expected_equalized_grid ():
48
32
"""
49
33
The expected grdhisteq grid result.
50
34
"""
51
- return xr .DataArray (
52
- data = [[0 , 0 , 0 , 1 ], [0 , 0 , 0 , 1 ], [0 , 0 , 1 , 1 ], [1 , 1 , 1 , 1 ]],
53
- coords = {
54
- "lon" : [- 51.5 , - 50.5 , - 49.5 , - 48.5 ],
55
- "lat" : [- 21.5 , - 20.5 , - 19.5 , - 18.5 ],
56
- },
57
- dims = ["lat" , "lon" ],
58
- )
59
35
60
36
61
37
def test_xarray_accessor_gridline_cartesian ():
@@ -211,7 +187,7 @@ def test_xarray_accessor_tiled_grid_slice_and_add():
211
187
assert added_grid .gmt .gtype is GridType .GEOGRAPHIC
212
188
213
189
214
- def test_xarray_accessor_clip (grid , expected_clipped_grid ):
190
+ def test_xarray_accessor_clip (grid ):
215
191
"""
216
192
Check that the accessor has the clip method and that it works correctly.
217
193
@@ -220,6 +196,16 @@ def test_xarray_accessor_clip(grid, expected_clipped_grid):
220
196
clipped_grid = grid .gmt .clip (
221
197
below = [550 , - 1000 ], above = [700 , 1000 ], region = [- 53 , - 49 , - 19 , - 16 ]
222
198
)
199
+
200
+ expected_clipped_grid = xr .DataArray (
201
+ data = [
202
+ [1000.0 , 570.5 , - 1000.0 , - 1000.0 ],
203
+ [1000.0 , 1000.0 , 571.5 , 638.5 ],
204
+ [555.5 , 556.0 , 580.0 , 1000.0 ],
205
+ ],
206
+ coords = {"lon" : [- 52.5 , - 51.5 , - 50.5 , - 49.5 ], "lat" : [- 18.5 , - 17.5 , - 16.5 ]},
207
+ dims = ["lat" , "lon" ],
208
+ )
223
209
xr .testing .assert_allclose (a = clipped_grid , b = expected_clipped_grid )
224
210
225
211
@@ -230,4 +216,13 @@ def test_xarray_accessor_equalize(grid, expected_equalized_grid):
230
216
This test is adapted from the `test_equalize_grid_no_outgrid` test.
231
217
"""
232
218
equalized_grid = grid .gmt .equalize_hist (divisions = 2 , region = [- 52 , - 48 , - 22 , - 18 ])
219
+
220
+ expected_equalized_grid = xr .DataArray (
221
+ data = [[0 , 0 , 0 , 1 ], [0 , 0 , 0 , 1 ], [0 , 0 , 1 , 1 ], [1 , 1 , 1 , 1 ]],
222
+ coords = {
223
+ "lon" : [- 51.5 , - 50.5 , - 49.5 , - 48.5 ],
224
+ "lat" : [- 21.5 , - 20.5 , - 19.5 , - 18.5 ],
225
+ },
226
+ dims = ["lat" , "lon" ],
227
+ )
233
228
xr .testing .assert_allclose (a = equalized_grid , b = expected_equalized_grid )
0 commit comments