Skip to content

Commit 51f60ec

Browse files
Merge branch 'v4-dev' into swap_space_and_time_interpolation_order
2 parents 17d4be2 + 29798dc commit 51f60ec

21 files changed

+191
-543
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ jobs:
7676
with:
7777
environment-file: environment.yml
7878
- name: Integration test
79-
# TODO v4: Re-enable `tutorial_periodic_boundaries` and `tutorial_timevaryingdepthdimensions` notebooks
79+
# TODO v4: Re-enable `tutorial_periodic_boundaries`, `tutorial_timevaryingdepthdimensions` and `tutorial_croco_3D` notebooks
8080
run: |
81-
coverage run -m pytest -v -s --nbval-lax -k "not documentation and not tutorial_periodic_boundaries and not tutorial_timevaryingdepthdimensions" --html="${{ matrix.os }}_${{ matrix.python-version }}_integration_test_report.html" --self-contained-html docs/examples
81+
coverage run -m pytest -v -s --nbval-lax -k "not documentation and not tutorial_periodic_boundaries and not tutorial_timevaryingdepthdimensions and not tutorial_croco_3D" --html="${{ matrix.os }}_${{ matrix.python-version }}_integration_test_report.html" --self-contained-html docs/examples
8282
coverage xml
8383
- name: Codecov
8484
uses: codecov/[email protected]

docs/documentation/index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ Parcels has several documentation and tutorial Jupyter notebooks and scripts whi
2525
../examples/tutorial_periodic_boundaries.ipynb
2626
../examples/tutorial_interpolation.ipynb
2727
../examples/tutorial_unitconverters.ipynb
28-
../examples/tutorial_timestamps.ipynb
2928

3029

3130
.. nbgallery::

docs/examples/documentation_unstuck_Agrid.ipynb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@
809809
"dimensions = {\"U\": dims, \"V\": dims}\n",
810810
"\n",
811811
"indices = {\n",
812-
" \"lon\": range(lonmin, lonmax),\n",
812+
" \"lon\": range(lonmin, lonmax), # TODO v4: Remove `indices` argument from this cell\n",
813813
" \"lat\": range(latmin, latmax),\n",
814814
"} # to load only a small part of the domain\n",
815815
"\n",
@@ -874,7 +874,10 @@
874874
"outputs": [],
875875
"source": [
876876
"fieldset = parcels.FieldSet.from_netcdf(\n",
877-
" filenames, variables, dimensions, indices=indices\n",
877+
" filenames,\n",
878+
" variables,\n",
879+
" dimensions,\n",
880+
" indices=indices, # TODO v4: Remove `indices` argument from this cell\n",
878881
")\n",
879882
"u_displacement = v_x\n",
880883
"v_displacement = v_y\n",
@@ -1401,7 +1404,7 @@
14011404
" filenames,\n",
14021405
" variables,\n",
14031406
" dimensions,\n",
1404-
" indices=indices,\n",
1407+
" indices=indices, # TODO v4: Remove `indices` argument from this cell\n",
14051408
" interp_method={\n",
14061409
" \"U\": \"partialslip\",\n",
14071410
" \"V\": \"partialslip\",\n",
@@ -1439,7 +1442,7 @@
14391442
" filenames,\n",
14401443
" variables,\n",
14411444
" dimensions,\n",
1442-
" indices=indices,\n",
1445+
" indices=indices, # TODO v4: Remove `indices` argument from this cell\n",
14431446
" interp_method={\n",
14441447
" \"U\": \"freeslip\",\n",
14451448
" \"V\": \"freeslip\",\n",

docs/examples/example_globcurrent.py

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010

1111
def set_globcurrent_fieldset(
1212
filename=None,
13-
indices=None,
14-
use_xarray=False,
15-
timestamps=None,
1613
):
1714
if filename is None:
1815
data_folder = parcels.download_example_dataset("GlobCurrent_example_data")
@@ -23,38 +20,32 @@ def set_globcurrent_fieldset(
2320
"U": "eastward_eulerian_current_velocity",
2421
"V": "northward_eulerian_current_velocity",
2522
}
26-
if timestamps is None:
27-
dimensions = {"lat": "lat", "lon": "lon", "time": "time"}
28-
else:
29-
dimensions = {"lat": "lat", "lon": "lon"}
30-
if use_xarray:
31-
ds = xr.open_mfdataset(filename, combine="by_coords")
32-
return parcels.FieldSet.from_xarray_dataset(
33-
ds,
34-
variables,
35-
dimensions,
36-
)
37-
else:
38-
return parcels.FieldSet.from_netcdf(
39-
filename,
40-
variables,
41-
dimensions,
42-
indices,
43-
timestamps=timestamps,
44-
)
23+
dimensions = {"lat": "lat", "lon": "lon", "time": "time"}
24+
ds = xr.open_mfdataset(filename, combine="by_coords")
25+
26+
return parcels.FieldSet.from_xarray_dataset(
27+
ds,
28+
variables,
29+
dimensions,
30+
)
4531

4632

47-
@pytest.mark.parametrize("use_xarray", [True, False])
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+
)
4839
def test_globcurrent_fieldset(use_xarray):
49-
fieldset = set_globcurrent_fieldset(use_xarray=use_xarray)
40+
fieldset = set_globcurrent_fieldset()
5041
assert fieldset.U.lon.size == 81
5142
assert fieldset.U.lat.size == 41
5243
assert fieldset.V.lon.size == 81
5344
assert fieldset.V.lat.size == 41
5445

5546
if not use_xarray:
5647
indices = {"lon": [5], "lat": range(20, 30)}
57-
fieldsetsub = set_globcurrent_fieldset(indices=indices, use_xarray=use_xarray)
48+
fieldsetsub = set_globcurrent_fieldset(indices=indices)
5849
assert np.allclose(fieldsetsub.U.lon, fieldset.U.lon[indices["lon"]])
5950
assert np.allclose(fieldsetsub.U.lat, fieldset.U.lat[indices["lat"]])
6051
assert np.allclose(fieldsetsub.V.lon, fieldset.V.lon[indices["lon"]])
@@ -64,21 +55,20 @@ def test_globcurrent_fieldset(use_xarray):
6455
@pytest.mark.parametrize(
6556
"dt, lonstart, latstart", [(3600.0, 25, -35), (-3600.0, 20, -39)]
6657
)
67-
@pytest.mark.parametrize("use_xarray", [True, False])
68-
def test_globcurrent_fieldset_advancetime(dt, lonstart, latstart, use_xarray):
58+
def test_globcurrent_fieldset_advancetime(dt, lonstart, latstart):
6959
data_folder = parcels.download_example_dataset("GlobCurrent_example_data")
7060
basepath = str(data_folder / "20*-GLOBCURRENT-L4-CUReul_hs-ALT_SUM-v02.0-fv01.0.nc")
7161
files = sorted(glob(str(basepath)))
7262

73-
fieldsetsub = set_globcurrent_fieldset(files[0:10], use_xarray=use_xarray)
63+
fieldsetsub = set_globcurrent_fieldset(files[0:10])
7464
psetsub = parcels.ParticleSet.from_list(
7565
fieldset=fieldsetsub,
7666
pclass=parcels.Particle,
7767
lon=[lonstart],
7868
lat=[latstart],
7969
)
8070

81-
fieldsetall = set_globcurrent_fieldset(files[0:10], use_xarray=use_xarray)
71+
fieldsetall = set_globcurrent_fieldset(files[0:10])
8272
psetall = parcels.ParticleSet.from_list(
8373
fieldset=fieldsetall,
8474
pclass=parcels.Particle,
@@ -95,9 +85,8 @@ def test_globcurrent_fieldset_advancetime(dt, lonstart, latstart, use_xarray):
9585
assert abs(psetsub[0].lon - psetall[0].lon) < 1e-4
9686

9787

98-
@pytest.mark.parametrize("use_xarray", [True, False])
99-
def test_globcurrent_particles(use_xarray):
100-
fieldset = set_globcurrent_fieldset(use_xarray=use_xarray)
88+
def test_globcurrent_particles():
89+
fieldset = set_globcurrent_fieldset()
10190

10291
lonstart = [25]
10392
latstart = [-35]
@@ -114,6 +103,10 @@ def test_globcurrent_particles(use_xarray):
114103
assert abs(pset[0].lat - -35.3) < 1
115104

116105

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+
)
117110
@pytest.mark.parametrize("dt", [-300, 300])
118111
def test_globcurrent_xarray_vs_netcdf(dt):
119112
fieldsetNetcdf = set_globcurrent_fieldset(use_xarray=False)
@@ -134,6 +127,10 @@ def test_globcurrent_xarray_vs_netcdf(dt):
134127
assert np.allclose(psetN[0].lat, psetX[0].lat)
135128

136129

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+
)
137134
@pytest.mark.parametrize("dt", [-300, 300])
138135
def test_globcurrent_netcdf_timestamps(dt):
139136
fieldsetNetcdf = set_globcurrent_fieldset()
@@ -195,9 +192,8 @@ def test__particles_init_time():
195192
assert pset[0].time - pset4[0].time == 0
196193

197194

198-
@pytest.mark.parametrize("use_xarray", [True, False])
199-
def test_globcurrent_time_extrapolation_error(use_xarray):
200-
fieldset = set_globcurrent_fieldset(use_xarray=use_xarray)
195+
def test_globcurrent_time_extrapolation_error():
196+
fieldset = set_globcurrent_fieldset()
201197
pset = parcels.ParticleSet(
202198
fieldset,
203199
pclass=parcels.Particle,

docs/examples/tutorial_timestamps.ipynb

Lines changed: 0 additions & 134 deletions
This file was deleted.

docs/v4/TODO.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@ List of tasks that are important to do before the release of version 4 (but can'
55
- [ ] Make migration guide for v3 to v4
66
- [ ] Just prior to release: Update conda feedstock recipe dependencies (remove cgen and compiler dependencies). Make sure that recipe is up-to-date.
77
- [ ] Revamp the oceanparcels.org landing page, and perhaps also consider new logo/branding?
8-
- [ ] Look into xarray and whether users can create periodic datasets without increasing the size of the original dataset (i.e., no compromise alternative to `time_periodic` param in v3). Update docs accordingly.
98
- [ ] Rerun all the tutorials so that their output is in line with new v4 print statements etc
9+
- Documentation
10+
- [ ] Look into xarray and whether users can create periodic datasets without increasing the size of the original dataset (i.e., no compromise alternative to `time_periodic` param in v3). Update docs accordingly.
11+
- [ ] Look into xarray and whether users can create datasets from snapshots assigning different time dimensions without increasing the size of the original dataset (i.e., no compromise alternative to `timestamps` param in v3). Update docs accordingly.

0 commit comments

Comments
 (0)