@@ -57,25 +57,25 @@ def peninsula_fieldset(xdim, ydim, mesh="flat", grid_type="A"):
5757
5858 # Create the fields
5959 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
6165
6266 if grid_type == "A" :
6367 U = u0 - u0 * R ** 2 * ((x - x0 ) ** 2 - y ** 2 ) / (((x - x0 ) ** 2 + y ** 2 ) ** 2 )
6468 V = - 2 * u0 * R ** 2 * ((x - x0 ) * y ) / (((x - x0 ) ** 2 + y ** 2 ) ** 2 )
69+ U [landpoints ] = 0.0
70+ V [landpoints ] = 0.0
6571 elif grid_type == "C" :
6672 U = np .zeros (P .shape )
6773 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 ])
7076 else :
7177 raise RuntimeError (f"Grid_type { grid_type } is not a valid option" )
7278
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-
7979 # Convert from m to lat/lon for spherical meshes
8080 lon = La / 1852.0 / 60.0 if mesh == "spherical" else La
8181 lat = Wa / 1852.0 / 60.0 if mesh == "spherical" else Wa
@@ -185,7 +185,7 @@ def test_peninsula_fieldset(mode, mesh, tmpdir):
185185 pset = peninsula_example (fieldset , outfile , 5 , mode = mode , degree = 1 )
186186 # Test advection accuracy by comparing streamline values
187187 err_adv = np .abs (pset .p_start - pset .p )
188- assert (err_adv <= 1.0e-3 ).all ()
188+ assert (err_adv <= 1.0 ).all ()
189189 # Test Field sampling accuracy by comparing kernel against Field sampling
190190 err_smpl = np .array (
191191 [
@@ -196,7 +196,7 @@ def test_peninsula_fieldset(mode, mesh, tmpdir):
196196 for i in range (pset .size )
197197 ]
198198 )
199- assert (err_smpl <= 1.0e-3 ).all ()
199+ assert (err_smpl <= 1.0 ).all ()
200200
201201
202202@pytest .mark .parametrize (
@@ -213,7 +213,7 @@ def test_peninsula_fieldset_AnalyticalAdvection(mode, mesh, tmpdir):
213213 # Test advection accuracy by comparing streamline values
214214 err_adv = np .array ([abs (p .p_start - p .p ) for p in pset ])
215215
216- tol = {"scipy" : 3.0e-1 , "jit" : 1.0e-1 }.get (mode )
216+ tol = {"scipy" : 3.0e2 , "jit" : 1.0e2 }.get (mode )
217217 assert (err_adv <= tol ).all ()
218218
219219
@@ -239,7 +239,7 @@ def test_peninsula_file(mode, mesh, tmpdir):
239239 pset = peninsula_example (fieldset , outfile , 5 , mode = mode , degree = 1 )
240240 # Test advection accuracy by comparing streamline values
241241 err_adv = np .abs (pset .p_start - pset .p )
242- assert (err_adv <= 1.0e-3 ).all ()
242+ assert (err_adv <= 1.0 ).all ()
243243 # Test Field sampling accuracy by comparing kernel against Field sampling
244244 err_smpl = np .array (
245245 [
@@ -250,7 +250,7 @@ def test_peninsula_file(mode, mesh, tmpdir):
250250 for i in range (pset .size )
251251 ]
252252 )
253- assert (err_smpl <= 1.0e-3 ).all ()
253+ assert (err_smpl <= 1.0 ).all ()
254254
255255
256256def main (args = None ):
0 commit comments