Skip to content

Commit

Permalink
Clarify difference between compute and load in xarray example (#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsignell authored Jun 27, 2023
1 parent 702f19d commit b2c8520
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions xarray.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,13 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Call `.compute()` or `.load()` when you want your result as a `xarray.DataArray` with data stored as NumPy arrays.\n",
"Call `.compute()` or `.load()` when you want your result as a `xarray.DataArray` with data stored as NumPy arrays. \n",
"\n",
"<div class=\"alert alert-info\">\n",
" \n",
"NOTE: `load()` alters the DataArray inplace whereas `compute()` returns a new DataArray object.\n",
"\n",
"</div>\n",
"\n",
"If you started `Client()` above then you may want to watch the status page during computation."
]
Expand All @@ -143,7 +149,7 @@
"metadata": {},
"outputs": [],
"source": [
"computed_da = da3.load()\n",
"computed_da = da3.compute()\n",
"type(computed_da.data)"
]
},
Expand Down Expand Up @@ -191,7 +197,8 @@
"metadata": {},
"outputs": [],
"source": [
"da.resample(time='1w').mean('time').std('time')"
"resampled_da = da.resample(time='1w').mean('time')\n",
"resampled_da.std('time')"
]
},
{
Expand All @@ -200,7 +207,7 @@
"metadata": {},
"outputs": [],
"source": [
"da.resample(time='1w').mean('time').std('time').load().plot(figsize=(12, 8))"
"resampled_da.std('time').plot(figsize=(12, 8))"
]
},
{
Expand All @@ -216,7 +223,7 @@
"metadata": {},
"outputs": [],
"source": [
"da_smooth = da.rolling(time=30).mean().persist()\n",
"da_smooth = da.rolling(time=30).mean()\n",
"da_smooth"
]
},
Expand Down Expand Up @@ -338,7 +345,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.12"
"version": "3.10.5"
}
},
"nbformat": 4,
Expand Down

0 comments on commit b2c8520

Please sign in to comment.