Skip to content

Commit 6b6b44d

Browse files
reint-fischerreint-fischer
authored andcommitted
revert AvsC grid accuracy guide
1 parent 8486301 commit 6b6b44d

File tree

1 file changed

+17
-22
lines changed

1 file changed

+17
-22
lines changed

docs/user_guide/examples/tutorial_peninsula_AvsCgrid.ipynb renamed to docs/user_guide/examples_v3/tutorial_peninsula_AvsCgrid.ipynb

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
"import numpy as np\n",
2828
"import scipy\n",
2929
"import xarray as xr\n",
30-
"import xgcm\n",
3130
"from matplotlib.lines import Line2D\n",
3231
"\n",
3332
"import parcels"
@@ -56,29 +55,25 @@
5655
" R = 0.32 * domainsizeX / 2\n",
5756
"\n",
5857
" x, y = np.meshgrid(lon, lat, sparse=True, indexing=\"xy\")\n",
59-
" P_data = u0 * R**2 * y / ((x - x0) ** 2 + y**2) - u0 * y\n",
60-
" landpoints = P_data >= 0.0\n",
61-
" P_data[landpoints] = 0.0\n",
58+
" P = u0 * R**2 * y / ((x - x0) ** 2 + y**2) - u0 * y\n",
59+
" landpoints = P >= 0.0\n",
60+
" P[landpoints] = 0.0\n",
6261
"\n",
6362
" if grid_type == \"A\":\n",
64-
" U_data = u0 - u0 * R**2 * ((x - x0) ** 2 - y**2) / (((x - x0) ** 2 + y**2) ** 2)\n",
65-
" V_data = -2 * u0 * R**2 * ((x - x0) * y) / (((x - x0) ** 2 + y**2) ** 2)\n",
66-
" U_data[landpoints] = 0.0\n",
67-
" V_data[landpoints] = 0.0\n",
63+
" U = u0 - u0 * R**2 * ((x - x0) ** 2 - y**2) / (((x - x0) ** 2 + y**2) ** 2)\n",
64+
" V = -2 * u0 * R**2 * ((x - x0) * y) / (((x - x0) ** 2 + y**2) ** 2)\n",
65+
" U[landpoints] = 0.0\n",
66+
" V[landpoints] = 0.0\n",
6867
" elif grid_type == \"C\":\n",
69-
" U_data = np.zeros(P.shape)\n",
70-
" V_data = np.zeros(P.shape)\n",
71-
" V_data[:, 1:] = (P_data[:, 1:] - P_data[:, :-1]) / (lon[1] - lon[0])\n",
72-
" U_data[1:, :] = -(P_data[1:, :] - P_data[:-1, :]) / (lat[1] - lat[0])\n",
68+
" U = np.zeros(P.shape)\n",
69+
" V = np.zeros(P.shape)\n",
70+
" V[:, 1:] = (P[:, 1:] - P[:, :-1]) / (lon[1] - lon[0])\n",
71+
" U[1:, :] = -(P[1:, :] - P[:-1, :]) / (lat[1] - lat[0])\n",
7372
"\n",
73+
" data = {\"U\": U, \"V\": V, \"P\": P}\n",
7474
" dimensions = {\"lon\": lon, \"lat\": lat}\n",
75-
" grid = parcels.XGrid(xgcm.grid())\n",
76-
" U = parcels.Field(\"U\", U_data, grid=, interp_method=)\n",
77-
" V = parcels.Field(\"V\", V_data, grid=, interp_method=)\n",
78-
" UV = parcels.VectorField(\"UV\", U, V, vector_interp_method=)\n",
79-
" P = parcels.Field(\"P\", P_data, grid=, interp_method=)\n",
8075
"\n",
81-
" fieldset = parcels.FieldSet([U, V, P])\n",
76+
" fieldset = parcels.FieldSet.from_data(data, dimensions, mesh=\"flat\")\n",
8277
" fieldset.U.interp_method = interp_method\n",
8378
" fieldset.V.interp_method = interp_method\n",
8479
" return fieldset"
@@ -97,8 +92,8 @@
9792
"metadata": {},
9893
"outputs": [],
9994
"source": [
100-
"def SampleP(particles, fieldset):\n",
101-
" particles.p = fieldset.P[particles]\n",
95+
"def SampleP(particle, fieldset, time):\n",
96+
" particle.p = fieldset.P[time, particle.lon, particle.lat, particle.depth]\n",
10297
"\n",
10398
"\n",
10499
"def DeleteParticle(particle, fieldset, time):\n",
@@ -363,7 +358,7 @@
363358
],
364359
"metadata": {
365360
"kernelspec": {
366-
"display_name": "test-notebooks",
361+
"display_name": "parcels",
367362
"language": "python",
368363
"name": "python3"
369364
},
@@ -377,7 +372,7 @@
377372
"name": "python",
378373
"nbconvert_exporter": "python",
379374
"pygments_lexer": "ipython3",
380-
"version": "3.11.0"
375+
"version": "3.12.3"
381376
}
382377
},
383378
"nbformat": 4,

0 commit comments

Comments
 (0)