@@ -61,22 +61,22 @@ def test_advection_zonal(lon, lat, depth):
6161 """Particles at high latitude move geographically faster due to the pole correction in `GeographicPolar`."""
6262 npart = 10
6363 data2D = {
64- "U" : np .ones ((lon .size , lat .size ), dtype = np .float32 ),
65- "V" : np .zeros ((lon .size , lat .size ), dtype = np .float32 ),
64+ "U" : np .ones ((lat .size , lon .size ), dtype = np .float32 ),
65+ "V" : np .zeros ((lat .size , lon .size ), dtype = np .float32 ),
6666 }
6767 data3D = {
68- "U" : np .ones ((lon .size , lat .size , depth .size ), dtype = np .float32 ),
69- "V" : np .zeros ((lon .size , lat .size , depth .size ), dtype = np .float32 ),
68+ "U" : np .ones ((depth .size , lat .size , lon .size ), dtype = np .float32 ),
69+ "V" : np .zeros ((depth .size , lat .size , lon .size ), dtype = np .float32 ),
7070 }
7171 dimensions = {"lon" : lon , "lat" : lat }
72- fieldset2D = FieldSet .from_data (data2D , dimensions , mesh = "spherical" , transpose = True )
72+ fieldset2D = FieldSet .from_data (data2D , dimensions , mesh = "spherical" )
7373
7474 pset2D = ParticleSet (fieldset2D , pclass = Particle , lon = np .zeros (npart ) + 20.0 , lat = np .linspace (0 , 80 , npart ))
7575 pset2D .execute (AdvectionRK4 , runtime = timedelta (hours = 2 ), dt = timedelta (seconds = 30 ))
7676 assert (np .diff (pset2D .lon ) > 1.0e-4 ).all ()
7777
7878 dimensions ["depth" ] = depth
79- fieldset3D = FieldSet .from_data (data3D , dimensions , mesh = "spherical" , transpose = True )
79+ fieldset3D = FieldSet .from_data (data3D , dimensions , mesh = "spherical" )
8080 pset3D = ParticleSet (
8181 fieldset3D ,
8282 pclass = Particle ,
@@ -91,9 +91,9 @@ def test_advection_zonal(lon, lat, depth):
9191def test_advection_meridional (lon , lat ):
9292 """Particles at high latitude move geographically faster due to the pole correction in `GeographicPolar`."""
9393 npart = 10
94- data = {"U" : np .zeros ((lon .size , lat .size ), dtype = np .float32 ), "V" : np .ones ((lon .size , lat .size ), dtype = np .float32 )}
94+ data = {"U" : np .zeros ((lat .size , lon .size ), dtype = np .float32 ), "V" : np .ones ((lat .size , lon .size ), dtype = np .float32 )}
9595 dimensions = {"lon" : lon , "lat" : lat }
96- fieldset = FieldSet .from_data (data , dimensions , mesh = "spherical" , transpose = True )
96+ fieldset = FieldSet .from_data (data , dimensions , mesh = "spherical" )
9797
9898 pset = ParticleSet (fieldset , pclass = Particle , lon = np .linspace (- 60 , 60 , npart ), lat = np .linspace (0 , 30 , npart ))
9999 delta_lat = np .diff (pset .lat )
@@ -110,9 +110,9 @@ def test_advection_3D():
110110 "lat" : np .linspace (0.0 , 1e4 , ydim , dtype = np .float32 ),
111111 "depth" : np .linspace (0.0 , 1.0 , zdim , dtype = np .float32 ),
112112 }
113- data = {"U" : np .ones ((xdim , ydim , zdim ), dtype = np .float32 ), "V" : np .zeros ((xdim , ydim , zdim ), dtype = np .float32 )}
114- data ["U" ][: , :, 0 ] = 0.0
115- fieldset = FieldSet .from_data (data , dimensions , mesh = "flat" , transpose = True )
113+ data = {"U" : np .ones ((zdim , ydim , xdim ), dtype = np .float32 ), "V" : np .zeros ((zdim , ydim , xdim ), dtype = np .float32 )}
114+ data ["U" ][0 , :, : ] = 0.0
115+ fieldset = FieldSet .from_data (data , dimensions , mesh = "flat" )
116116
117117 pset = ParticleSet (
118118 fieldset , pclass = Particle , lon = np .zeros (npart ), lat = np .zeros (npart ) + 1e2 , depth = np .linspace (0 , 1 , npart )
@@ -171,11 +171,11 @@ def SubmergeParticle(particle, fieldset, time): # pragma: no cover
171171def test_advection_RK45 (lon , lat , rk45_tol ):
172172 npart = 10
173173 data2D = {
174- "U" : np .ones ((lon .size , lat .size ), dtype = np .float32 ),
175- "V" : np .zeros ((lon .size , lat .size ), dtype = np .float32 ),
174+ "U" : np .ones ((lat .size , lon .size ), dtype = np .float32 ),
175+ "V" : np .zeros ((lat .size , lon .size ), dtype = np .float32 ),
176176 }
177177 dimensions = {"lon" : lon , "lat" : lat }
178- fieldset = FieldSet .from_data (data2D , dimensions , mesh = "spherical" , transpose = True )
178+ fieldset = FieldSet .from_data (data2D , dimensions , mesh = "spherical" )
179179 fieldset .add_constant ("RK45_tol" , rk45_tol )
180180
181181 dt = timedelta (seconds = 30 ).total_seconds ()
@@ -266,8 +266,8 @@ def create_periodic_fieldset(xdim, ydim, uvel, vvel):
266266 "lat" : np .linspace (0.0 , 1.0 , ydim + 1 , dtype = np .float32 )[1 :],
267267 }
268268
269- data = {"U" : uvel * np .ones ((xdim , ydim ), dtype = np .float32 ), "V" : vvel * np .ones ((xdim , ydim ), dtype = np .float32 )}
270- return FieldSet .from_data (data , dimensions , mesh = "spherical" , transpose = True )
269+ data = {"U" : uvel * np .ones ((ydim , xdim ), dtype = np .float32 ), "V" : vvel * np .ones ((ydim , xdim ), dtype = np .float32 )}
270+ return FieldSet .from_data (data , dimensions , mesh = "spherical" )
271271
272272
273273def periodicBC (particle , fieldset , time ): # pragma: no cover
@@ -373,10 +373,10 @@ def create_fieldset_stationary(xdim=100, ydim=100, maxtime=timedelta(hours=6)):
373373 "time" : time ,
374374 }
375375 data = {
376- "U" : np .ones ((xdim , ydim , 1 ), dtype = np .float32 ) * u_0 * np .cos (f * time ),
377- "V" : np .ones ((xdim , ydim , 1 ), dtype = np .float32 ) * - u_0 * np .sin (f * time ),
376+ "U" : np .transpose ( np . ones ((xdim , ydim , 1 ), dtype = np .float32 ) * u_0 * np .cos (f * time ) ),
377+ "V" : np .transpose ( np . ones ((xdim , ydim , 1 ), dtype = np .float32 ) * - u_0 * np .sin (f * time ) ),
378378 }
379- fieldset = FieldSet .from_data (data , dimensions , mesh = "flat" , transpose = True )
379+ fieldset = FieldSet .from_data (data , dimensions , mesh = "flat" )
380380 # setting some constants for AdvectionRK45 kernel
381381 fieldset .RK45_min_dt = 1e-3
382382 fieldset .RK45_max_dt = 1e2
@@ -435,13 +435,13 @@ def test_stationary_eddy_vertical():
435435 lon_data = np .linspace (0 , 25000 , xdim , dtype = np .float32 )
436436 lat_data = np .linspace (0 , 25000 , ydim , dtype = np .float32 )
437437 time_data = np .arange (0.0 , 6 * 3600 + 1e-5 , 60.0 , dtype = np .float64 )
438- fld1 = np .ones ((xdim , ydim , 1 ), dtype = np .float32 ) * u_0 * np .cos (f * time_data )
439- fld2 = np .ones ((xdim , ydim , 1 ), dtype = np .float32 ) * - u_0 * np .sin (f * time_data )
440- fldzero = np .zeros ((xdim , ydim , 1 ), dtype = np .float32 ) * time_data
438+ fld1 = np .transpose ( np . ones ((xdim , ydim , 1 ), dtype = np .float32 ) * u_0 * np .cos (f * time_data ) )
439+ fld2 = np .transpose ( np . ones ((xdim , ydim , 1 ), dtype = np .float32 ) * - u_0 * np .sin (f * time_data ) )
440+ fldzero = np .transpose ( np . zeros ((xdim , ydim , 1 ), dtype = np .float32 ) * time_data )
441441
442442 dimensions = {"lon" : lon_data , "lat" : lat_data , "time" : time_data }
443443 data = {"U" : fld1 , "V" : fldzero , "W" : fld2 }
444- fieldset = FieldSet .from_data (data , dimensions , mesh = "flat" , transpose = True )
444+ fieldset = FieldSet .from_data (data , dimensions , mesh = "flat" )
445445
446446 pset = ParticleSet (fieldset , pclass = Particle , lon = lon , lat = lat , depth = depth )
447447 pset .execute (AdvectionRK4_3D , dt = dt , endtime = endtime )
@@ -453,7 +453,7 @@ def test_stationary_eddy_vertical():
453453 assert np .allclose (pset .depth , exp_depth , rtol = 1e-5 )
454454
455455 data = {"U" : fldzero , "V" : fld2 , "W" : fld1 }
456- fieldset = FieldSet .from_data (data , dimensions , mesh = "flat" , transpose = True )
456+ fieldset = FieldSet .from_data (data , dimensions , mesh = "flat" )
457457
458458 pset = ParticleSet (fieldset , pclass = Particle , lon = lon , lat = lat , depth = depth )
459459 pset .execute (AdvectionRK4_3D , dt = dt , endtime = endtime )
@@ -483,10 +483,10 @@ def create_fieldset_moving(xdim=100, ydim=100, maxtime=timedelta(hours=6)):
483483 "time" : time ,
484484 }
485485 data = {
486- "U" : np .ones ((xdim , ydim , 1 ), dtype = np .float32 ) * u_g + (u_0 - u_g ) * np .cos (f * time ),
487- "V" : np .ones ((xdim , ydim , 1 ), dtype = np .float32 ) * - (u_0 - u_g ) * np .sin (f * time ),
486+ "U" : np .transpose ( np . ones ((xdim , ydim , 1 ), dtype = np .float32 ) * u_g + (u_0 - u_g ) * np .cos (f * time ) ),
487+ "V" : np .transpose ( np . ones ((xdim , ydim , 1 ), dtype = np .float32 ) * - (u_0 - u_g ) * np .sin (f * time ) ),
488488 }
489- return FieldSet .from_data (data , dimensions , mesh = "flat" , transpose = True )
489+ return FieldSet .from_data (data , dimensions , mesh = "flat" )
490490
491491
492492@pytest .fixture
@@ -555,11 +555,15 @@ def create_fieldset_decaying(xdim=100, ydim=100, maxtime=timedelta(hours=6)):
555555 "time" : time ,
556556 }
557557 data = {
558- "U" : np .ones ((xdim , ydim , 1 ), dtype = np .float32 ) * u_g * np .exp (- gamma_g * time )
559- + (u_0 - u_g ) * np .exp (- gamma * time ) * np .cos (f * time ),
560- "V" : np .ones ((xdim , ydim , 1 ), dtype = np .float32 ) * - (u_0 - u_g ) * np .exp (- gamma * time ) * np .sin (f * time ),
558+ "U" : np .transpose (
559+ np .ones ((xdim , ydim , 1 ), dtype = np .float32 ) * u_g * np .exp (- gamma_g * time )
560+ + (u_0 - u_g ) * np .exp (- gamma * time ) * np .cos (f * time )
561+ ),
562+ "V" : np .transpose (
563+ np .ones ((xdim , ydim , 1 ), dtype = np .float32 ) * - (u_0 - u_g ) * np .exp (- gamma * time ) * np .sin (f * time )
564+ ),
561565 }
562- return FieldSet .from_data (data , dimensions , mesh = "flat" , transpose = True )
566+ return FieldSet .from_data (data , dimensions , mesh = "flat" )
563567
564568
565569@pytest .fixture
0 commit comments