Skip to content

Commit 1109081

Browse files
JessicaS11pre-commit-ci[bot]dcherian
authored
start adding [new] scipy2022 tutorial content (#65)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: dcherian <deepak@cherian.net> Co-authored-by: Deepak Cherian <dcherian@users.noreply.github.com>
1 parent 34c0bb2 commit 1109081

19 files changed

+930
-535
lines changed

_toc.yml

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,67 @@
22
root: intro
33
format: jb-book
44
parts:
5+
- caption: Overview
6+
chapters:
7+
- file: overview/xarray-in-45-min
58
- caption: Fundamentals
69
chapters:
7-
- file: scipy-tutorial/00_overview
8-
- file: scipy-tutorial/01_datastructures_and_io
9-
- file: scipy-tutorial/02_working_with_labeled_data
10-
- file: scipy-tutorial/03_computation_with_xarray
11-
- file: scipy-tutorial/04_plotting_and_visualization
12-
- file: scipy-tutorial/05_intro_to_dask
13-
- file: scipy-tutorial/06_xarray_and_dask
10+
- file: fundamentals/00_overview
11+
- file: fundamentals/01_datastructures_and_io
12+
- file: fundamentals/02.1_working_with_labeled_data
13+
sections:
14+
- file: fundamentals/02.2_manipulating_dimensions
15+
- file: fundamentals/02.3_aligning_data_objects
16+
- file: fundamentals/03.1_computation_with_xarray
17+
sections:
18+
- file: fundamentals/03.2_groupby_with_xarray
19+
- file: fundamentals/04_plotting_and_visualization
20+
21+
- caption: Intermediate
22+
chapters:
23+
- file: intermediate/01-high-level-computation-patterns
24+
25+
- caption: Advanced
26+
chapters:
27+
- file: advanced/xarray_and_dask
1428

1529
- caption: Workshops
1630
chapters:
17-
- file: workshops/oceanhackweek-2020/README
31+
- file: workshops/oceanhackweek2020/README
1832
sections:
19-
- file: workshops/oceanhackweek-2020/xarray-oceanhackweek20
33+
- url: https://tutorial.xarray.dev/overview/xarray-in-45-min
34+
title: Xarray in 45 minutes
2035
- file: workshops/thinking-like-xarray/README
2136
sections:
22-
- file: workshops/thinking-like-xarray/01-high-level-computation-patterns
37+
- url: https://tutorial.xarray.dev/intermediate/01-high-level-computation-patterns
38+
title: High-level computation patterns
2339
- file: workshops/online-tutorial-series/README
2440
sections:
2541
- file: workshops/online-tutorial-series/01_xarray_fundamentals
2642
- file: workshops/online-tutorial-series/02_indexing
2743
- file: workshops/online-tutorial-series/03_computation
2844
- file: workshops/scipy2022/README
45+
sections:
46+
- url: https://tutorial.xarray.dev/fundamentals/00_overview
47+
title: Introduction
48+
- url: https://tutorial.xarray.dev/fundamentals/01_datastructures_and_io
49+
title: Data Structures
50+
- file: workshops/scipy2022/cleaning_real_data
51+
- url: https://tutorial.xarray.dev/fundamentals/02.1_working_with_labeled_data
52+
title: Labeled Data
53+
- url: https://tutorial.xarray.dev/fundamentals/02.2_manipulating_dimensions
54+
title: Manipulating Dimensions
55+
- url: https://tutorial.xarray.dev/fundamentals/02.3_aligning_data_objects
56+
title: Data Alignment
57+
- url: https://tutorial.xarray.dev/fundamentals/03.1_computation_with_xarray
58+
title: Computation
59+
- url: https://tutorial.xarray.dev/fundamentals/03.2_groupby_with_xarray
60+
title: Groupby
61+
- url: https://tutorial.xarray.dev/fundamentals/04_plotting_and_visualization.html
62+
title: Plotting and Visualization
63+
- file: workshops/scipy2022/xarray_ecosystem
64+
- url: https://tutorial.xarray.dev/fundamentals/06_xarray_and_dask
65+
title: Xarray and Dask
2966

3067
- caption: Reference
3168
chapters:

scipy-tutorial/00_overview.ipynb renamed to fundamentals/00_overview.ipynb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,13 @@
8787
"\n",
8888
"The layout of the tutorial will be as follows:\n",
8989
"\n",
90-
"1. [Introduction + Data structures for multi-dimensional data](./01_datastructures_and_io.ipynb)\n",
91-
"1. [Working with labeled data](02_working_with_labeled_data.ipynb)\n",
92-
"1. [Computation with Xarray](03_computation_with_xarray.ipynb)\n",
93-
"1. [Plotting and Visualization](04_plotting_and_visualization.ipynb)\n",
90+
"1. [Introduction + data structures for multi-dimensional data](./01_datastructures_and_io.ipynb)\n",
91+
"1. [Working with labeled data](02.1_working_with_labeled_data.ipynb)\n",
92+
"1. [Manipulating dimensions](02.2_manipulating_dimensions.ipynb)\n",
93+
"1. [Aligning data objects](02.3_aligning_data_objects.ipynb)\n",
94+
"1. [Computation with Xarray](03.1_computation_with_xarray.ipynb)\n",
95+
"1. [Groupby with Xarray](03.2_groupby_with_xarray.ipynb)\n",
96+
"1. [Plotting and visualization](04_plotting_and_visualization.ipynb)\n",
9497
"1. [Introduction to Dask](05_intro_to_dask.ipynb)\n",
9598
"1. [Dask and Xarray](06_xarray_and_dask.ipynb)\n",
9699
"\n",

scipy-tutorial/02_working_with_labeled_data.ipynb renamed to fundamentals/02.1_working_with_labeled_data.ipynb

Lines changed: 0 additions & 184 deletions
Original file line numberDiff line numberDiff line change
@@ -301,190 +301,6 @@
301301
"source": [
302302
"# your code here"
303303
]
304-
},
305-
{
306-
"cell_type": "markdown",
307-
"metadata": {},
308-
"source": [
309-
"## Interpolation\n",
310-
"\n",
311-
"If we want to look at values between the current grid cells (interpolation), we\n",
312-
"can do that with `interp` (requires `scipy`):\n"
313-
]
314-
},
315-
{
316-
"cell_type": "code",
317-
"execution_count": null,
318-
"metadata": {},
319-
"outputs": [],
320-
"source": [
321-
"arr.interp(\n",
322-
" x=np.linspace(2, 6, 10),\n",
323-
" y=pd.date_range(\"2009-04-01\", \"2009-04-30\", freq=\"D\"),\n",
324-
")"
325-
]
326-
},
327-
{
328-
"cell_type": "markdown",
329-
"metadata": {},
330-
"source": [
331-
"when trying to extrapolate, the resulting values will be `nan`.\n",
332-
"\n",
333-
"If we already have a object with the desired coordinates, we can use\n",
334-
"`interp_like`:\n"
335-
]
336-
},
337-
{
338-
"cell_type": "code",
339-
"execution_count": null,
340-
"metadata": {},
341-
"outputs": [],
342-
"source": [
343-
"other = xr.DataArray(\n",
344-
" dims=(\"x\", \"y\"),\n",
345-
" coords={\n",
346-
" \"x\": np.linspace(2, 4, 10),\n",
347-
" \"y\": pd.date_range(\"2009-04-01\", \"2009-04-30\", freq=\"D\"),\n",
348-
" },\n",
349-
")\n",
350-
"arr.interp_like(other)"
351-
]
352-
},
353-
{
354-
"cell_type": "markdown",
355-
"metadata": {},
356-
"source": [
357-
"### Exercises\n",
358-
"\n",
359-
"Increase the step size along latitude and longitude from 2.5 degrees to 1\n",
360-
"degree.\n"
361-
]
362-
},
363-
{
364-
"cell_type": "code",
365-
"execution_count": null,
366-
"metadata": {},
367-
"outputs": [],
368-
"source": [
369-
"# your code here"
370-
]
371-
},
372-
{
373-
"cell_type": "markdown",
374-
"metadata": {},
375-
"source": [
376-
"## Broadcasting and automatic alignment\n",
377-
"\n",
378-
"Labels help with combining arrays with different coordinates:\n"
379-
]
380-
},
381-
{
382-
"cell_type": "code",
383-
"execution_count": null,
384-
"metadata": {},
385-
"outputs": [],
386-
"source": [
387-
"a = xr.DataArray(\n",
388-
" np.random.randn(3, 4),\n",
389-
" dims=(\"x\", \"y\"),\n",
390-
" coords={\"x\": [\"a\", \"b\", \"c\"], \"y\": np.arange(4)},\n",
391-
")\n",
392-
"b = xr.DataArray(\n",
393-
" np.random.randn(2, 7),\n",
394-
" dims=(\"x\", \"y\"),\n",
395-
" coords={\"x\": [\"b\", \"d\"], \"y\": [-2, -1, 0, 1, 2, 3, 4]},\n",
396-
")\n",
397-
"\n",
398-
"a + b"
399-
]
400-
},
401-
{
402-
"cell_type": "markdown",
403-
"metadata": {},
404-
"source": [
405-
"This will automatically select only common labels from both arrays (a inner\n",
406-
"join) and then perform the operation.\n"
407-
]
408-
},
409-
{
410-
"cell_type": "markdown",
411-
"metadata": {},
412-
"source": [
413-
"Broadcasting works similar:\n"
414-
]
415-
},
416-
{
417-
"cell_type": "code",
418-
"execution_count": null,
419-
"metadata": {},
420-
"outputs": [],
421-
"source": [
422-
"arr1 = xr.DataArray(\n",
423-
" np.random.randn(3),\n",
424-
" dims=\"x\",\n",
425-
" coords={\"x\": [\"a\", \"b\", \"c\"]},\n",
426-
")\n",
427-
"arr2 = xr.DataArray(\n",
428-
" np.random.randn(4),\n",
429-
" dims=\"y\",\n",
430-
" coords={\"y\": np.arange(4)},\n",
431-
")\n",
432-
"\n",
433-
"arr1 + arr2"
434-
]
435-
},
436-
{
437-
"cell_type": "markdown",
438-
"metadata": {},
439-
"source": [
440-
"where both arrays were automatically broadcasted against each other:\n"
441-
]
442-
},
443-
{
444-
"cell_type": "code",
445-
"execution_count": null,
446-
"metadata": {},
447-
"outputs": [],
448-
"source": [
449-
"arr1_, arr2_ = xr.broadcast(arr1, arr2)"
450-
]
451-
},
452-
{
453-
"cell_type": "code",
454-
"execution_count": null,
455-
"metadata": {},
456-
"outputs": [],
457-
"source": [
458-
"arr1_"
459-
]
460-
},
461-
{
462-
"cell_type": "code",
463-
"execution_count": null,
464-
"metadata": {},
465-
"outputs": [],
466-
"source": [
467-
"arr2_"
468-
]
469-
},
470-
{
471-
"cell_type": "markdown",
472-
"metadata": {},
473-
"source": [
474-
"and then the operation (a sum) was executed.\n",
475-
"\n",
476-
"We can also call `align` speciically with different options.\n"
477-
]
478-
},
479-
{
480-
"cell_type": "code",
481-
"execution_count": null,
482-
"metadata": {},
483-
"outputs": [],
484-
"source": [
485-
"a_al, b_al = xr.align(a, b, join=\"inner\")\n",
486-
"b_al"
487-
]
488304
}
489305
],
490306
"metadata": {

0 commit comments

Comments
 (0)