@@ -57,25 +57,25 @@ def peninsula_fieldset(xdim, ydim, mesh="flat", grid_type="A"):
57
57
58
58
# Create the fields
59
59
x , y = np .meshgrid (La , Wa , sparse = True , indexing = "xy" )
60
- P = (u0 * R ** 2 * y / ((x - x0 ) ** 2 + y ** 2 ) - u0 * y ) / 1e3
60
+ P = u0 * R ** 2 * y / ((x - x0 ) ** 2 + y ** 2 ) - u0 * y
61
+
62
+ # Set land points to zero
63
+ landpoints = P >= 0.0
64
+ P [landpoints ] = 0.0
61
65
62
66
if grid_type == "A" :
63
67
U = u0 - u0 * R ** 2 * ((x - x0 ) ** 2 - y ** 2 ) / (((x - x0 ) ** 2 + y ** 2 ) ** 2 )
64
68
V = - 2 * u0 * R ** 2 * ((x - x0 ) * y ) / (((x - x0 ) ** 2 + y ** 2 ) ** 2 )
69
+ U [landpoints ] = 0.0
70
+ V [landpoints ] = 0.0
65
71
elif grid_type == "C" :
66
72
U = np .zeros (P .shape )
67
73
V = np .zeros (P .shape )
68
- V [:, 1 :] = P [:, 1 :] - P [:, :- 1 ]
69
- U [1 :, :] = - (P [1 :, :] - P [:- 1 , :])
74
+ V [:, 1 :] = ( P [:, 1 :] - P [:, :- 1 ]) / ( La [ 1 ] - La [ 0 ])
75
+ U [1 :, :] = - (P [1 :, :] - P [:- 1 , :]) / ( Wa [ 1 ] - Wa [ 0 ])
70
76
else :
71
77
raise RuntimeError (f"Grid_type { grid_type } is not a valid option" )
72
78
73
- # Set land points to NaN
74
- landpoints = P >= 0.0
75
- P [landpoints ] = np .nan
76
- U [landpoints ] = np .nan
77
- V [landpoints ] = np .nan
78
-
79
79
# Convert from m to lat/lon for spherical meshes
80
80
lon = La / 1852.0 / 60.0 if mesh == "spherical" else La
81
81
lat = Wa / 1852.0 / 60.0 if mesh == "spherical" else Wa
@@ -185,7 +185,7 @@ def test_peninsula_fieldset(mode, mesh, tmpdir):
185
185
pset = peninsula_example (fieldset , outfile , 5 , mode = mode , degree = 1 )
186
186
# Test advection accuracy by comparing streamline values
187
187
err_adv = np .abs (pset .p_start - pset .p )
188
- assert (err_adv <= 1.0e-3 ).all ()
188
+ assert (err_adv <= 1.0 ).all ()
189
189
# Test Field sampling accuracy by comparing kernel against Field sampling
190
190
err_smpl = np .array (
191
191
[
@@ -196,7 +196,7 @@ def test_peninsula_fieldset(mode, mesh, tmpdir):
196
196
for i in range (pset .size )
197
197
]
198
198
)
199
- assert (err_smpl <= 1.0e-3 ).all ()
199
+ assert (err_smpl <= 1.0 ).all ()
200
200
201
201
202
202
@pytest .mark .parametrize (
@@ -213,7 +213,7 @@ def test_peninsula_fieldset_AnalyticalAdvection(mode, mesh, tmpdir):
213
213
# Test advection accuracy by comparing streamline values
214
214
err_adv = np .array ([abs (p .p_start - p .p ) for p in pset ])
215
215
216
- tol = {"scipy" : 3.0e-1 , "jit" : 1.0e-1 }.get (mode )
216
+ tol = {"scipy" : 3.0e2 , "jit" : 1.0e2 }.get (mode )
217
217
assert (err_adv <= tol ).all ()
218
218
219
219
@@ -239,7 +239,7 @@ def test_peninsula_file(mode, mesh, tmpdir):
239
239
pset = peninsula_example (fieldset , outfile , 5 , mode = mode , degree = 1 )
240
240
# Test advection accuracy by comparing streamline values
241
241
err_adv = np .abs (pset .p_start - pset .p )
242
- assert (err_adv <= 1.0e-3 ).all ()
242
+ assert (err_adv <= 1.0 ).all ()
243
243
# Test Field sampling accuracy by comparing kernel against Field sampling
244
244
err_smpl = np .array (
245
245
[
@@ -250,7 +250,7 @@ def test_peninsula_file(mode, mesh, tmpdir):
250
250
for i in range (pset .size )
251
251
]
252
252
)
253
- assert (err_smpl <= 1.0e-3 ).all ()
253
+ assert (err_smpl <= 1.0 ).all ()
254
254
255
255
256
256
def main (args = None ):
0 commit comments