Skip to content

Commit

Permalink
Merge pull request #1208 from OceanParcels/field_netcdf_decodewarning…
Browse files Browse the repository at this point in the history
…_option

Adding option to silence xarray decodewarnings
  • Loading branch information
erikvansebille committed Aug 4, 2022
2 parents 04485b2 + 43ec15b commit 3260033
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 49 deletions.
33 changes: 16 additions & 17 deletions parcels/examples/documentation_indexing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"metadata": {
"tags": [
"raises-exception"
]
},
"outputs": [
{
"ename": "ValueError",
Expand Down Expand Up @@ -123,19 +127,7 @@
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING: File NemoNorthSeaORCA025-N006_data/coordinates.nc could not be decoded properly by xarray (version 0.15.1).\n",
" It will be opened with no decoding. Filling values might be wrongly parsed.\n",
"WARNING: Casting lon data to np.float32\n",
"WARNING: Casting lat data to np.float32\n",
"WARNING: Trying to initialize a shared grid with different chunking sizes - action prohibited. Replacing requested field_chunksize with grid's master chunksize.\n"
]
}
],
"outputs": [],
"source": [
"mesh_mask = data_path + 'coordinates.nc'\n",
"\n",
Expand All @@ -147,7 +139,14 @@
" 'V': {'lon': 'glamf', 'lat': 'gphif', 'depth': 'depthw', 'time': 'time_counter'},\n",
" 'W': {'lon': 'glamf', 'lat': 'gphif', 'depth': 'depthw', 'time': 'time_counter'}}\n",
"\n",
"fieldsetC = FieldSet.from_nemo(filenames, variables, dimensions)"
"fieldsetC = FieldSet.from_nemo(filenames, variables, dimensions, netcdf_decodewarning=False)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Note by the way, that we used `netcdf_decodewarning=False` in the `FieldSet.from_nemo()` call above. This is to silence an expected warning because the time dimension in the `coordinates.nc` file can't be decoded by `xarray`."
]
},
{
Expand Down Expand Up @@ -221,7 +220,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -235,7 +234,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.8.13"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 3260033

Please sign in to comment.