Skip to content

Commit 0cb7f01

Browse files
Updating tutorials to use fieldset.constants dictionary
1 parent ce42035 commit 0cb7f01

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

docs/user_guide/examples/tutorial_Argofloats.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
"# Convert to SGRID-compliant dataset and create FieldSet\n",
132132
"ds_fset = parcels.convert.copernicusmarine_to_sgrid(fields=fields)\n",
133133
"fieldset = parcels.FieldSet.from_sgrid_conventions(ds_fset)\n",
134-
"fieldset.add_constant(\"mindepth\", 1.0)\n",
134+
"fieldset.constants[\"mindepth\"] = 1.0\n",
135135
"\n",
136136
"# Define a new Particle type including extra Variables\n",
137137
"ArgoParticle = parcels.Particle.add_variable(\n",

docs/user_guide/examples/tutorial_croco_3D.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
"fieldset = parcels.FieldSet.from_sgrid_conventions(ds_fset)\n",
9292
"\n",
9393
"# Add the critical depth (`hc`) as a constant to the fieldset\n",
94-
"fieldset.add_constant(\"hc\", ds_fields.hc.item())"
94+
"fieldset.constants[\"hc\"] = ds_fields.hc.item()"
9595
]
9696
},
9797
{
@@ -204,7 +204,7 @@
204204
"source": [
205205
"fieldset_noW = parcels.FieldSet.from_sgrid_conventions(ds_fset)\n",
206206
"fieldset_noW.W.data[:] = 0.0\n",
207-
"fieldset_noW.add_constant(\"hc\", ds_fields.hc.item())\n",
207+
"fieldset_noW.constants[\"hc\"] = ds_fields.hc.item()\n",
208208
"\n",
209209
"X, Z = np.meshgrid(\n",
210210
" [40e3, 80e3, 120e3],\n",

docs/user_guide/examples/tutorial_diffusion.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
"\n",
9191
"Just like velocities, diffusivities are passed to Parcels in the form of `Field` objects. When using `DiffusionUniformKh`, they should be added to the `FieldSet` object as constant fields, e.g. `fieldset.add_constant_field(\"Kh_zonal\", 1, mesh=\"flat\")`.\n",
9292
"\n",
93-
"To make a central difference approximation for computing the gradient in diffusivity, a resolution for this approximation `dres` is needed: _Parcels_ approximates the gradients in diffusivities by using their values at the particle's location ± `dres` (in both $x$ and $y$). A value of `dres` must be specified and added to the FieldSet by the user (e.g. `fieldset.add_constant(\"dres\", 0.01)`). Currently, it is unclear what the best value of `dres` is. From experience, the size of `dres` should be smaller than the spatial resolution of the data, but within reasonable limits of machine precision to avoid numerical errors. We are working on a method to compute gradients differently so that specifying `dres` is not necessary anymore.\n",
93+
"To make a central difference approximation for computing the gradient in diffusivity, a resolution for this approximation `dres` is needed: _Parcels_ approximates the gradients in diffusivities by using their values at the particle's location ± `dres` (in both $x$ and $y$). A value of `dres` must be specified and added to the FieldSet by the user (e.g. `fieldset.constants[\"dres\"] = 0.01`). Currently, it is unclear what the best value of `dres` is. From experience, the size of `dres` should be smaller than the spatial resolution of the data, but within reasonable limits of machine precision to avoid numerical errors. We are working on a method to compute gradients differently so that specifying `dres` is not necessary anymore.\n",
9494
"\n",
9595
"## Example: Impermeable Diffusivity Profile\n",
9696
"\n",
@@ -206,7 +206,7 @@
206206
"source": [
207207
"fieldset = parcels.FieldSet.from_sgrid_conventions(ds, mesh=\"flat\")\n",
208208
"fieldset.add_constant_field(\"Kh_zonal\", 1, mesh=\"flat\")\n",
209-
"fieldset.add_constant(\"dres\", 0.00005)"
209+
"fieldset.constants[\"dres\"] = 0.00005"
210210
]
211211
},
212212
{
@@ -537,7 +537,7 @@
537537
")\n",
538538
"fieldset.add_field(cell_areas_field)\n",
539539
"\n",
540-
"fieldset.add_constant(\"Cs\", 0.1)"
540+
"fieldset.constants[\"Cs\"] = 0.1"
541541
]
542542
},
543543
{

0 commit comments

Comments
 (0)