Skip to content

Commit c2f2b38

Browse files
Fixing review comments
1 parent 4e30feb commit c2f2b38

File tree

7 files changed

+13
-13
lines changed

7 files changed

+13
-13
lines changed

parcels/_typing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class ParcelsAST(ast.AST):
3737
Mesh = Literal["spherical", "flat"] # corresponds with `mesh`
3838
VectorType = Literal["3D", "3DSigma", "2D"] | None # corresponds with `vector_type`
3939
ChunkMode = Literal["auto", "specific", "failsafe"] # corresponds with `chunk_mode`
40-
GridIndexingType = Literal["pop", "mom5", "mitgcm", "nemo"] # corresponds with `gridindexingtype`
40+
GridIndexingType = Literal["pop", "mom5", "mitgcm", "nemo", "croco"] # corresponds with `gridindexingtype`
4141
UpdateStatus = Literal["not_updated", "first_updated", "updated"] # corresponds with `_update_status`
4242
TimePeriodic = float | datetime.timedelta | Literal[False] # corresponds with `time_periodic`
4343
NetcdfEngine = Literal["netcdf4", "xarray", "scipy"]

parcels/compilation/codegenerator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ def __init__(self, fieldset=None, ptype=JITParticle):
426426
self.fieldset = fieldset
427427
self.ptype = ptype
428428
self.field_args = collections.OrderedDict()
429-
if isinstance(fieldset.U, Field) and fieldset.U.gridindexingtype == "croco" and hasattr(fieldset, "H"):
429+
if fieldset.U.gridindexingtype == "croco" and hasattr(fieldset, "H"):
430430
self.field_args["H"] = fieldset.H # CROCO requires H field
431431
self.vector_field_args = collections.OrderedDict()
432432
self.const_args = collections.OrderedDict()
@@ -827,7 +827,7 @@ def visit_FieldEvalNode(self, node):
827827
self.visit(node.args)
828828
args = self._check_FieldSamplingArguments(node.args.ccode)
829829
statements_croco = []
830-
if "croco" in node.field.obj.gridindexingtype and node.field.obj.name != "H": # TODO needs to be sigma
830+
if "croco" in node.field.obj.gridindexingtype and node.field.obj.name != "H":
831831
statements_croco.append(
832832
c.Assign(
833833
"parcels_interp_state",

tests/test_advection.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import math
2-
import os
32
from datetime import timedelta
43

54
import numpy as np
@@ -22,6 +21,7 @@
2221
StatusCode,
2322
Variable,
2423
)
24+
from tests.utils import TEST_DATA
2525

2626
ptype = {"scipy": ScipyParticle, "jit": JITParticle}
2727
kernel = {
@@ -197,9 +197,7 @@ def test_advection_RK45(lon, lat, mode, rk45_tol):
197197

198198
@pytest.mark.parametrize("mode", ["scipy", "jit"])
199199
def test_advection_3DCROCO(mode):
200-
data_path = os.path.join(os.path.dirname(__file__), "test_data/")
201-
fieldset = FieldSet.from_modulefile(data_path + "fieldset_CROCO3D.py")
202-
assert fieldset.U.creation_log == "from_croco"
200+
fieldset = FieldSet.from_modulefile(TEST_DATA / "fieldset_CROCO3D.py")
203201

204202
runtime = 1e4
205203
X, Z = np.meshgrid([40e3, 80e3, 120e3], [-10, -130])
@@ -218,9 +216,7 @@ def SampleW(particle, fieldset, time):
218216

219217
@pytest.mark.parametrize("mode", ["scipy", "jit"])
220218
def test_advection_2DCROCO(mode):
221-
data_path = os.path.join(os.path.dirname(__file__), "test_data/")
222-
fieldset = FieldSet.from_modulefile(data_path + "fieldset_CROCO2D.py")
223-
assert fieldset.U.creation_log == "from_croco"
219+
fieldset = FieldSet.from_modulefile(TEST_DATA / "fieldset_CROCO2D.py")
224220

225221
runtime = 1e4
226222
X = np.array([40e3, 80e3, 120e3])

tests/test_data/CROCO_idealized.nc

-1.11 MB
Binary file not shown.

tests/test_data/fieldset_CROCO2D.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55

66
def create_fieldset(indices=None):
7-
file = os.path.join(os.path.dirname(__file__), "CROCO_idealized.nc")
7+
example_dataset_folder = parcels.download_example_dataset("CROCOidealized_data")
8+
file = os.path.join(example_dataset_folder, "CROCO_idealized.nc")
89

910
variables = {"U": "u", "V": "v"}
1011
dimensions = {
@@ -17,6 +18,7 @@ def create_fieldset(indices=None):
1718
dimensions,
1819
allow_time_extrapolation=True,
1920
mesh="flat",
21+
indices=indices,
2022
)
2123

2224
return fieldset

tests/test_data/fieldset_CROCO3D.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55

66
def create_fieldset(indices=None):
7-
file = os.path.join(os.path.dirname(__file__), "CROCO_idealized.nc")
7+
example_dataset_folder = parcels.download_example_dataset("CROCOidealized_data")
8+
file = os.path.join(example_dataset_folder, "CROCO_idealized.nc")
89

910
variables = {"U": "u", "V": "v", "W": "w", "H": "h"}
1011
dimensions = {
@@ -19,6 +20,7 @@ def create_fieldset(indices=None):
1920
dimensions,
2021
allow_time_extrapolation=True,
2122
mesh="flat",
23+
indices=indices,
2224
)
2325

2426
return fieldset

tests/test_fieldset_sampling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ def test_sampling_out_of_bounds_time(mode, allow_time_extrapolation):
618618

619619

620620
@pytest.mark.parametrize("mode", ["scipy", "jit"])
621-
def test_sampling_3DCROCO(mode, npart=10):
621+
def test_sampling_3DCROCO(mode):
622622
data_path = os.path.join(os.path.dirname(__file__), "test_data/")
623623
fieldset = FieldSet.from_modulefile(data_path + "fieldset_CROCO3D.py")
624624

0 commit comments

Comments
 (0)