@@ -22,8 +22,8 @@ def fieldset() -> FieldSet: # TODO v4: Move into a `conftest.py` file and remov
2222 """Fixture to create a FieldSet object for testing."""
2323 ds = datasets ["ds_2d_left" ]
2424 grid = XGrid .from_dataset (ds )
25- U = Field ("U" , ds ["U (A grid)" ], grid , mesh_type = "flat" )
26- V = Field ("V" , ds ["V (A grid)" ], grid , mesh_type = "flat" )
25+ U = Field ("U" , ds ["U (A grid)" ], grid )
26+ V = Field ("V" , ds ["V (A grid)" ], grid )
2727 UV = VectorField ("UV" , U , V )
2828
2929 return FieldSet (
@@ -191,11 +191,18 @@ def IncrLon(particle, fieldset, time): # pragma: no cover
191191
192192def test_write_timebackward (fieldset , tmp_zarrfile ):
193193 def Update_lon (particle , fieldset , time ): # pragma: no cover
194- particle .dlon -= 0.1 * particle .dt
194+ dt = particle .dt / np .timedelta64 (1 , "s" )
195+ particle .dlon -= 0.1 * dt
195196
196- pset = ParticleSet (fieldset , pclass = Particle , lat = np .linspace (0 , 1 , 3 ), lon = [0 , 0 , 0 ], time = [1 , 2 , 3 ])
197- pfile = pset .ParticleFile (tmp_zarrfile , outputdt = 1.0 )
198- pset .execute (pset .Kernel (Update_lon ), runtime = 4 , dt = - 1.0 , output_file = pfile )
197+ pset = ParticleSet (
198+ fieldset ,
199+ pclass = Particle ,
200+ lat = np .linspace (0 , 1 , 3 ),
201+ lon = [0 , 0 , 0 ],
202+ time = np .array ([np .datetime64 ("2000-01-01" ) for _ in range (3 )]),
203+ )
204+ pfile = pset .ParticleFile (tmp_zarrfile , outputdt = np .timedelta64 (1 , "s" ))
205+ pset .execute (pset .Kernel (Update_lon ), runtime = np .timedelta64 (1 , "s" ), dt = - np .timedelta64 (1 , "s" ), output_file = pfile )
199206 ds = xr .open_zarr (tmp_zarrfile )
200207 trajs = ds ["trajectory" ][:]
201208 assert trajs .values .dtype == "int64"
0 commit comments