Skip to content

Commit 544cd7f

Browse files
Merge pull request #1500 from OceanParcels/fixing_cgrid_eval_without_conversion
Bugfix for cgrid eval without applyConversion
2 parents 089241f + c268af3 commit 544cd7f

4 files changed

Lines changed: 42 additions & 20 deletions

File tree

docs/examples/tutorial_nemo_curvilinear.ipynb

Lines changed: 33 additions & 9 deletions
Large diffs are not rendered by default.

docs/examples/tutorial_sampling.ipynb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -247,13 +247,7 @@
247247
"name": "stdout",
248248
"output_type": "stream",
249249
"text": [
250-
"WARNING: Sampling of velocities should normally be done using fieldset.UV or fieldset.UVW object; thread carefully\n"
251-
]
252-
},
253-
{
254-
"name": "stdout",
255-
"output_type": "stream",
256-
"text": [
250+
"WARNING: Sampling of velocities should normally be done using fieldset.UV or fieldset.UVW object; tread carefully\n",
257251
"0it [00:00, ?it/s]\n"
258252
]
259253
}

parcels/field.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,7 +1194,7 @@ def time_index(self, time):
11941194

11951195
def _check_velocitysampling(self):
11961196
if self.name in ['U', 'V', 'W']:
1197-
logger.warning_once("Sampling of velocities should normally be done using fieldset.UV or fieldset.UVW object; thread carefully")
1197+
logger.warning_once("Sampling of velocities should normally be done using fieldset.UV or fieldset.UVW object; tread carefully")
11981198

11991199
def __getitem__(self, key):
12001200
self._check_velocitysampling()
@@ -1596,7 +1596,11 @@ def spatial_c_grid_interpolation2D(self, ti, z, y, x, time, particle=None, apply
15961596
V = (1-eta) * V0 + eta * V1
15971597
rad = np.pi/180.
15981598
deg2m = 1852 * 60.
1599-
meshJac = (deg2m * deg2m * math.cos(rad * y)) if grid.mesh == 'spherical' else 1
1599+
if applyConversion:
1600+
meshJac = (deg2m * deg2m * math.cos(rad * y)) if grid.mesh == 'spherical' else 1
1601+
else:
1602+
meshJac = deg2m if grid.mesh == 'spherical' else 1
1603+
16001604
jac = self.jacobian(xsi, eta, px, py) * meshJac
16011605

16021606
u = ((-(1-eta) * U - (1-xsi) * V) * px[0]

parcels/fieldset.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ def from_mom5(cls, filenames, variables, dimensions, indices=None, mesh='spheric
838838
This flag overrides the allow_time_extrapolation and sets it to False
839839
tracer_interp_method : str
840840
Method for interpolation of tracer fields. It is recommended to use 'bgrid_tracer' (default)
841-
Note that in the case of from_mom5() and from_bgrid(), the velocity fields are default to 'bgrid_velocity'
841+
Note that in the case of from_mom5() and from_b_grid_dataset(), the velocity fields are default to 'bgrid_velocity'
842842
chunksize :
843843
size of the chunks in dask loading (Default value = None)
844844
**kwargs :
@@ -918,7 +918,7 @@ def from_b_grid_dataset(cls, filenames, variables, dimensions, indices=None, mes
918918
This flag overrides the allow_time_extrapolation and sets it to False
919919
tracer_interp_method : str
920920
Method for interpolation of tracer fields. It is recommended to use 'bgrid_tracer' (default)
921-
Note that in the case of from_pop() and from_bgrid(), the velocity fields are default to 'bgrid_velocity'
921+
Note that in the case of from_pop() and from_b_grid_dataset(), the velocity fields are default to 'bgrid_velocity'
922922
chunksize :
923923
size of the chunks in dask loading (Default value = None)
924924
**kwargs :

0 commit comments

Comments
 (0)