@@ -30,28 +30,6 @@ def set_globcurrent_fieldset(
3030 )
3131
3232
33- @pytest .mark .v4remove (
34- reason = "indices keryword is not supported in v4. Subsetting should be done on xarray level."
35- )
36- @pytest .mark .parametrize (
37- "use_xarray" , [True , pytest .param (False , marks = pytest .mark .xfail )]
38- )
39- def test_globcurrent_fieldset (use_xarray ):
40- fieldset = set_globcurrent_fieldset ()
41- assert fieldset .U .lon .size == 81
42- assert fieldset .U .lat .size == 41
43- assert fieldset .V .lon .size == 81
44- assert fieldset .V .lat .size == 41
45-
46- if not use_xarray :
47- indices = {"lon" : [5 ], "lat" : range (20 , 30 )}
48- fieldsetsub = set_globcurrent_fieldset (indices = indices )
49- assert np .allclose (fieldsetsub .U .lon , fieldset .U .lon [indices ["lon" ]])
50- assert np .allclose (fieldsetsub .U .lat , fieldset .U .lat [indices ["lat" ]])
51- assert np .allclose (fieldsetsub .V .lon , fieldset .V .lon [indices ["lon" ]])
52- assert np .allclose (fieldsetsub .V .lat , fieldset .V .lat [indices ["lat" ]])
53-
54-
5533@pytest .mark .parametrize (
5634 "dt, lonstart, latstart" , [(3600.0 , 25 , - 35 ), (- 3600.0 , 20 , - 39 )]
5735)
@@ -103,55 +81,6 @@ def test_globcurrent_particles():
10381 assert abs (pset [0 ].lat - - 35.3 ) < 1
10482
10583
106- @pytest .mark .v4remove
107- @pytest .mark .xfail (
108- reason = "Can't patch metadata without using xarray. v4 will natively use xarray anyway. GH1919."
109- )
110- @pytest .mark .parametrize ("dt" , [- 300 , 300 ])
111- def test_globcurrent_xarray_vs_netcdf (dt ):
112- fieldsetNetcdf = set_globcurrent_fieldset (use_xarray = False )
113- fieldsetxarray = set_globcurrent_fieldset (use_xarray = True )
114- lonstart , latstart , runtime = (25 , - 35 , timedelta (days = 7 ))
115-
116- psetN = parcels .ParticleSet (
117- fieldsetNetcdf , pclass = parcels .Particle , lon = lonstart , lat = latstart
118- )
119- psetN .execute (parcels .AdvectionRK4 , runtime = runtime , dt = dt )
120-
121- psetX = parcels .ParticleSet (
122- fieldsetxarray , pclass = parcels .Particle , lon = lonstart , lat = latstart
123- )
124- psetX .execute (parcels .AdvectionRK4 , runtime = runtime , dt = dt )
125-
126- assert np .allclose (psetN [0 ].lon , psetX [0 ].lon )
127- assert np .allclose (psetN [0 ].lat , psetX [0 ].lat )
128-
129-
130- @pytest .mark .v4remove
131- @pytest .mark .xfail (
132- reason = "Timeslices will be removed in v4, as users will be able to use xarray directly."
133- )
134- @pytest .mark .parametrize ("dt" , [- 300 , 300 ])
135- def test_globcurrent_netcdf_timestamps (dt ):
136- fieldsetNetcdf = set_globcurrent_fieldset ()
137- timestamps = fieldsetNetcdf .U .grid .timeslices
138- fieldsetTimestamps = set_globcurrent_fieldset (timestamps = timestamps )
139- lonstart , latstart , runtime = (25 , - 35 , timedelta (days = 7 ))
140-
141- psetN = parcels .ParticleSet (
142- fieldsetNetcdf , pclass = parcels .Particle , lon = lonstart , lat = latstart
143- )
144- psetN .execute (parcels .AdvectionRK4 , runtime = runtime , dt = dt )
145-
146- psetT = parcels .ParticleSet (
147- fieldsetTimestamps , pclass = parcels .Particle , lon = lonstart , lat = latstart
148- )
149- psetT .execute (parcels .AdvectionRK4 , runtime = runtime , dt = dt )
150-
151- assert np .allclose (psetN .lon [0 ], psetT .lon [0 ])
152- assert np .allclose (psetN .lat [0 ], psetT .lat [0 ])
153-
154-
15584def test__particles_init_time ():
15685 fieldset = set_globcurrent_fieldset ()
15786
0 commit comments