@@ -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
@@ -379,10 +379,10 @@ def create_fieldset_stationary(xdim=100, ydim=100, maxtime=timedelta(hours=6)):
379379 "time" : time ,
380380 }
381381 data = {
382- "U" : np .ones ((xdim , ydim , 1 ), dtype = np .float32 ) * u_0 * np .cos (f * time ),
383- "V" : np .ones ((xdim , ydim , 1 ), dtype = np .float32 ) * - u_0 * np .sin (f * time ),
382+ "U" : np .transpose ( np . ones ((xdim , ydim , 1 ), dtype = np .float32 ) * u_0 * np .cos (f * time ) ),
383+ "V" : np .transpose ( np . ones ((xdim , ydim , 1 ), dtype = np .float32 ) * - u_0 * np .sin (f * time ) ),
384384 }
385- fieldset = FieldSet .from_data (data , dimensions , mesh = "flat" , transpose = True )
385+ fieldset = FieldSet .from_data (data , dimensions , mesh = "flat" )
386386 # setting some constants for AdvectionRK45 kernel
387387 fieldset .RK45_min_dt = 1e-3
388388 fieldset .RK45_max_dt = 1e2
@@ -441,13 +441,13 @@ def test_stationary_eddy_vertical():
441441 lon_data = np .linspace (0 , 25000 , xdim , dtype = np .float32 )
442442 lat_data = np .linspace (0 , 25000 , ydim , dtype = np .float32 )
443443 time_data = np .arange (0.0 , 6 * 3600 + 1e-5 , 60.0 , dtype = np .float64 )
444- fld1 = np .ones ((xdim , ydim , 1 ), dtype = np .float32 ) * u_0 * np .cos (f * time_data )
445- fld2 = np .ones ((xdim , ydim , 1 ), dtype = np .float32 ) * - u_0 * np .sin (f * time_data )
446- fldzero = np .zeros ((xdim , ydim , 1 ), dtype = np .float32 ) * time_data
444+ fld1 = np .transpose ( np . ones ((xdim , ydim , 1 ), dtype = np .float32 ) * u_0 * np .cos (f * time_data ) )
445+ fld2 = np .transpose ( np . ones ((xdim , ydim , 1 ), dtype = np .float32 ) * - u_0 * np .sin (f * time_data ) )
446+ fldzero = np .transpose ( np . zeros ((xdim , ydim , 1 ), dtype = np .float32 ) * time_data )
447447
448448 dimensions = {"lon" : lon_data , "lat" : lat_data , "time" : time_data }
449449 data = {"U" : fld1 , "V" : fldzero , "W" : fld2 }
450- fieldset = FieldSet .from_data (data , dimensions , mesh = "flat" , transpose = True )
450+ fieldset = FieldSet .from_data (data , dimensions , mesh = "flat" )
451451
452452 pset = ParticleSet (fieldset , pclass = Particle , lon = lon , lat = lat , depth = depth )
453453 pset .execute (AdvectionRK4_3D , dt = dt , endtime = endtime )
@@ -459,7 +459,7 @@ def test_stationary_eddy_vertical():
459459 assert np .allclose (pset .depth , exp_depth , rtol = 1e-5 )
460460
461461 data = {"U" : fldzero , "V" : fld2 , "W" : fld1 }
462- fieldset = FieldSet .from_data (data , dimensions , mesh = "flat" , transpose = True )
462+ fieldset = FieldSet .from_data (data , dimensions , mesh = "flat" )
463463
464464 pset = ParticleSet (fieldset , pclass = Particle , lon = lon , lat = lat , depth = depth )
465465 pset .execute (AdvectionRK4_3D , dt = dt , endtime = endtime )
@@ -489,10 +489,10 @@ def create_fieldset_moving(xdim=100, ydim=100, maxtime=timedelta(hours=6)):
489489 "time" : time ,
490490 }
491491 data = {
492- "U" : np .ones ((xdim , ydim , 1 ), dtype = np .float32 ) * u_g + (u_0 - u_g ) * np .cos (f * time ),
493- "V" : np .ones ((xdim , ydim , 1 ), dtype = np .float32 ) * - (u_0 - u_g ) * np .sin (f * time ),
492+ "U" : np .transpose ( np . ones ((xdim , ydim , 1 ), dtype = np .float32 ) * u_g + (u_0 - u_g ) * np .cos (f * time ) ),
493+ "V" : np .transpose ( np . ones ((xdim , ydim , 1 ), dtype = np .float32 ) * - (u_0 - u_g ) * np .sin (f * time ) ),
494494 }
495- return FieldSet .from_data (data , dimensions , mesh = "flat" , transpose = True )
495+ return FieldSet .from_data (data , dimensions , mesh = "flat" )
496496
497497
498498@pytest .fixture
@@ -561,11 +561,15 @@ def create_fieldset_decaying(xdim=100, ydim=100, maxtime=timedelta(hours=6)):
561561 "time" : time ,
562562 }
563563 data = {
564- "U" : np .ones ((xdim , ydim , 1 ), dtype = np .float32 ) * u_g * np .exp (- gamma_g * time )
565- + (u_0 - u_g ) * np .exp (- gamma * time ) * np .cos (f * time ),
566- "V" : np .ones ((xdim , ydim , 1 ), dtype = np .float32 ) * - (u_0 - u_g ) * np .exp (- gamma * time ) * np .sin (f * time ),
564+ "U" : np .transpose (
565+ np .ones ((xdim , ydim , 1 ), dtype = np .float32 ) * u_g * np .exp (- gamma_g * time )
566+ + (u_0 - u_g ) * np .exp (- gamma * time ) * np .cos (f * time )
567+ ),
568+ "V" : np .transpose (
569+ np .ones ((xdim , ydim , 1 ), dtype = np .float32 ) * - (u_0 - u_g ) * np .exp (- gamma * time ) * np .sin (f * time )
570+ ),
567571 }
568- return FieldSet .from_data (data , dimensions , mesh = "flat" , transpose = True )
572+ return FieldSet .from_data (data , dimensions , mesh = "flat" )
569573
570574
571575@pytest .fixture
0 commit comments