Skip to content

Commit 13cb229

Browse files
authored
Edits to climatology doc (#361)
1 parent 497e7bc commit 13cb229

File tree

1 file changed

+41
-11
lines changed

1 file changed

+41
-11
lines changed

docs/source/user-stories/climatology.ipynb

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@
6161
"source": [
6262
"To account for Feb-29 being present in some years, we'll construct a time vector to group by as \"mmm-dd\" string.\n",
6363
"\n",
64-
"For more options, see https://strftime.org/"
64+
"```{seealso}\n",
65+
"For more options, see [this great website](https://strftime.org/).\n",
66+
"```"
6567
]
6668
},
6769
{
@@ -80,7 +82,7 @@
8082
"id": "6",
8183
"metadata": {},
8284
"source": [
83-
"## map-reduce\n",
85+
"## First, `method=\"map-reduce\"`\n",
8486
"\n",
8587
"The default\n",
8688
"[method=\"map-reduce\"](https://flox.readthedocs.io/en/latest/implementation.html#method-map-reduce)\n",
@@ -110,7 +112,7 @@
110112
"id": "8",
111113
"metadata": {},
112114
"source": [
113-
"## Rechunking for map-reduce\n",
115+
"### Rechunking for map-reduce\n",
114116
"\n",
115117
"We can split each chunk along the `lat`, `lon` dimensions to make sure the\n",
116118
"output chunk sizes are more reasonable\n"
@@ -139,7 +141,7 @@
139141
"But what if we didn't want to rechunk the dataset so drastically (note the 10x\n",
140142
"increase in tasks). For that let's try `method=\"cohorts\"`\n",
141143
"\n",
142-
"## method=cohorts\n",
144+
"## `method=\"cohorts\"`\n",
143145
"\n",
144146
"We can take advantage of patterns in the groups here \"day of year\".\n",
145147
"Specifically:\n",
@@ -271,7 +273,7 @@
271273
"id": "21",
272274
"metadata": {},
273275
"source": [
274-
"And now our cohorts contain more than one group\n"
276+
"And now our cohorts contain more than one group, *and* there is a substantial reduction in number of cohorts **162 -> 12**\n"
275277
]
276278
},
277279
{
@@ -281,7 +283,7 @@
281283
"metadata": {},
282284
"outputs": [],
283285
"source": [
284-
"preferrd_method, new_cohorts = flox.core.find_group_cohorts(\n",
286+
"preferred_method, new_cohorts = flox.core.find_group_cohorts(\n",
285287
" labels=codes,\n",
286288
" chunks=(rechunked.chunksizes[\"time\"],),\n",
287289
")\n",
@@ -295,13 +297,23 @@
295297
"id": "23",
296298
"metadata": {},
297299
"outputs": [],
300+
"source": [
301+
"preferred_method"
302+
]
303+
},
304+
{
305+
"cell_type": "code",
306+
"execution_count": null,
307+
"id": "24",
308+
"metadata": {},
309+
"outputs": [],
298310
"source": [
299311
"new_cohorts.values()"
300312
]
301313
},
302314
{
303315
"cell_type": "markdown",
304-
"id": "24",
316+
"id": "25",
305317
"metadata": {},
306318
"source": [
307319
"Now the groupby reduction **looks OK** in terms of number of tasks but remember\n",
@@ -311,7 +323,7 @@
311323
{
312324
"cell_type": "code",
313325
"execution_count": null,
314-
"id": "25",
326+
"id": "26",
315327
"metadata": {},
316328
"outputs": [],
317329
"source": [
@@ -320,7 +332,25 @@
320332
},
321333
{
322334
"cell_type": "markdown",
323-
"id": "26",
335+
"id": "27",
336+
"metadata": {},
337+
"source": [
338+
"flox's heuristics will choose `\"cohorts\"` automatically!"
339+
]
340+
},
341+
{
342+
"cell_type": "code",
343+
"execution_count": null,
344+
"id": "28",
345+
"metadata": {},
346+
"outputs": [],
347+
"source": [
348+
"flox.xarray.xarray_reduce(rechunked, day, func=\"mean\")"
349+
]
350+
},
351+
{
352+
"cell_type": "markdown",
353+
"id": "29",
324354
"metadata": {},
325355
"source": [
326356
"## How about other climatologies?\n",
@@ -331,7 +361,7 @@
331361
{
332362
"cell_type": "code",
333363
"execution_count": null,
334-
"id": "27",
364+
"id": "30",
335365
"metadata": {},
336366
"outputs": [],
337367
"source": [
@@ -340,7 +370,7 @@
340370
},
341371
{
342372
"cell_type": "markdown",
343-
"id": "28",
373+
"id": "31",
344374
"metadata": {},
345375
"source": [
346376
"This looks great. Why?\n",

0 commit comments

Comments
 (0)