Skip to content

Commit 8e750c7

Browse files
Setting defaults for fieldset.computeTimeChunk()
1 parent 544cd7f commit 8e750c7

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

docs/examples/parcels_tutorial.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
"cell_type": "markdown",
9292
"metadata": {},
9393
"source": [
94-
"The `fieldset` can then be visualized with e.g. `matplotlib.pyplot.pcolormesh()`. To show the zonal velocity (`U`), give the commands below. Note that we first have to load the fieldset with `fieldset.computeTimeChunk(time=0, dt=1)` to load the first time frame of the fieldset."
94+
"The `fieldset` can then be visualized with e.g. `matplotlib.pyplot.pcolormesh()`. To show the zonal velocity (`U`), give the commands below. Note that we first have to load the fieldset with `fieldset.computeTimeChunk()` to load the first time frame of the fieldset."
9595
]
9696
},
9797
{
@@ -111,7 +111,7 @@
111111
}
112112
],
113113
"source": [
114-
"fieldset.computeTimeChunk(time=0, dt=1)\n",
114+
"fieldset.computeTimeChunk()\n",
115115
"\n",
116116
"plt.pcolormesh(fieldset.U.grid.lon, fieldset.U.grid.lat, fieldset.U.data[0, :, :])\n",
117117
"plt.xlabel(\"Zonal distance [m]\")\n",

parcels/fieldset.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,7 @@ def write(self, filename):
11411141
if isinstance(v, Field) and (v.name != 'U') and (v.name != 'V'):
11421142
v.write(filename)
11431143

1144-
def computeTimeChunk(self, time, dt):
1144+
def computeTimeChunk(self, time=0., dt=1):
11451145
"""Load a chunk of three data time steps into the FieldSet.
11461146
This is used when FieldSet uses data imported from netcdf,
11471147
with default option deferred_load. The loaded time steps are at or immediatly before time
@@ -1150,9 +1150,12 @@ def computeTimeChunk(self, time, dt):
11501150
Parameters
11511151
----------
11521152
time :
1153-
Time around which the FieldSet chunks are to be loaded. Time is provided as a double, relatively to Fieldset.time_origin
1153+
Time around which the FieldSet chunks are to be loaded.
1154+
Time is provided as a double, relatively to Fieldset.time_origin.
1155+
Default is 0.
11541156
dt :
1155-
time step of the integration scheme
1157+
time step of the integration scheme, needed to set the direction of time chunk loading.
1158+
Default is 1.
11561159
"""
11571160
signdt = np.sign(dt)
11581161
nextTime = np.infty if dt > 0 else -np.infty

0 commit comments

Comments
 (0)