Skip to content

Commit df53323

Browse files
lkailynncarjukentpre-commit-ci[bot]
authoredApr 24, 2023
Lily edits (#386)
* Implemented edits for pages 31 and 32 * Implemented grammar fixes for pages 33-34 * Implemented grammatical fixes for pages 31-40 * Updated Matplotlib file to fix pre-commit * Implemented grammatical fixes for pages 41-50 * Update netcdf-cf.ipynb * Update netcdf-cf.ipynb * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update pandas.ipynb * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update computation-masking.ipynb * Update enso-xarray.ipynb * Update xarray-intro.ipynb --------- Co-authored-by: Julia Kent <46687291+jukent@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 7ac805d commit df53323

10 files changed

+469
-468
lines changed
 

‎appendix/how-to-contribute.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ This content is under construction!
77
General information on how to contribute to any Project Pythia repository
88
may be found [here][pythia contributor's guide].
99

10-
A full contributor's guide will appear here, cross-referencing our tutorials on open Pull Requests on GitHub.
10+
This page will eventually contain a full guide to contributing to Project Pythia. As GitHub Pull Requests are an important part of contributing to Pythia, this guide will cross-reference tutorials on GitHub and Pull Requests.
1111

12-
A simple way to comment on anything you find in this book is to use the "open issue" and "suggest edit" buttons under the GitHub Octocat logo at the top of each page. These links will take you to GitHub where the source material for the book is hosted. You'll need a free (and broadly useful) GitHub account. See
13-
the main [Project Pythia Contributor's Guide][pythia contributor's guide].
12+
If you need to comment on anything in Pythia Foundations you feel needs work, you can use the "open issue" or "suggest edit" buttons at the top of any Pythia Foundations page. These buttons appear when you hover over the GitHub Octocat logo. Clicking on these buttons will take you to the relevant page on GitHub, where the entirety of the Pythia Foundations material is hosted. In order to actually suggest changes, you must have a free GitHub account, as listed in the GitHub section of Pythia Foundations. This contributor's guide is strictly for Pythia Foundations; for general Project Pythia contribution guidelines, see the main [Project Pythia Contributor's Guide][pythia contributor's guide].
1413

15-
You may also quickly provide feedback via this [Google form](https://docs.google.com/forms/d/e/1FAIpQLSeVa1TC9xM-dk7qIE2e8bsgSrIP82yYDNw3wew3J46eREJa4w/viewform?usp=sf_link).
14+
To quickly provide feedback about minor issues without the use of GitHub, you can also use this [Google Form](https://docs.google.com/forms/d/e/1FAIpQLSeVa1TC9xM-dk7qIE2e8bsgSrIP82yYDNw3wew3J46eREJa4w/viewform?usp=sf_link).
1615

1716
## Contributing a new Jupyter Notebook
1817

‎appendix/template.ipynb

+45-38
Large diffs are not rendered by default.

‎core/data-formats.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
This content is under construction!
55
```
66

7-
This section will contain tutorials on how to interact in Python with data file formats in widespread use in the geosciences, such as NetCDF.
7+
There are many data file formats used commonly in the geosciences, such as NetCDF and GRIB. This section contains tutorials on how to interact with these files in Python.

‎core/data-formats/netcdf-cf.ipynb

+59-54
Large diffs are not rendered by default.

‎core/pandas/pandas.ipynb

+66-87
Large diffs are not rendered by default.

‎core/xarray/computation-masking.ipynb

+68-65
Large diffs are not rendered by default.

‎core/xarray/dask-arrays-xarray.ipynb

+77-76
Large diffs are not rendered by default.

‎core/xarray/enso-xarray.ipynb

+19-20
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"source": [
2424
"## Overview\n",
2525
"\n",
26-
"In this notebook, we will:\n",
26+
"In this tutorial, we perform and demonstrate the following tasks:\n",
2727
"\n",
2828
"1. Load SST data from the CESM2 model\n",
2929
"2. Mask data using `.where()`\n",
@@ -62,7 +62,9 @@
6262
"tags": []
6363
},
6464
"source": [
65-
"## Imports \n"
65+
"## Imports \n",
66+
"\n",
67+
"For this tutorial, we import several Python packages. As plotting ENSO data requires a geographically accurate map, Cartopy is imported to handle geographic features and map projections. Xarray is used to manage raw data, and Matplotlib allows for feature-rich data plotting. Finally, a custom Pythia package is imported, in this case allowing access to the Pythia example data library."
6668
]
6769
},
6870
{
@@ -91,15 +93,15 @@
9193
"metadata": {},
9294
"source": [
9395
"\n",
94-
"In this notebook, we are going to combine several topics we've covered so far to compute the [Niño 3.4 Index](https://climatedataguide.ucar.edu/climate-data/nino-sst-indices-nino-12-3-34-4-oni-and-tni) for the CESM2 submission for the [CMIP6 project](https://esgf-node.llnl.gov/projects/cmip6/). \n",
96+
"In this tutorial, we combine topics covered in previous Xarray tutorials to demonstrate a real-world example. The real-world scenario demonstrated in this tutorial is the computation of the [Niño 3.4 Index](https://climatedataguide.ucar.edu/climate-data/nino-sst-indices-nino-12-3-34-4-oni-and-tni), as shown in the CESM2 submission for the [CMIP6 project](https://esgf-node.llnl.gov/projects/cmip6/). A rough definition of Niño 3.4, in addition to a definition of Niño data computation, is listed below:\n",
9597
"\n",
9698
"> Niño 3.4 (5N-5S, 170W-120W): The Niño 3.4 anomalies may be thought of as representing the average equatorial SSTs across the Pacific from about the dateline to the South American coast. The Niño 3.4 index typically uses a 5-month running mean, and El Niño or La Niña events are defined when the Niño 3.4 SSTs exceed +/- 0.4C for a period of six months or more.\n",
9799
"\n",
98-
"> Nino X Index computation: (a) Compute area averaged total SST from Niño X region; (b) Compute monthly climatology (e.g., 1950-1979) for area averaged total SST from Niño X region, and subtract climatology from area averaged total SST time series to obtain anomalies; (c) Smooth the anomalies with a 5-month running mean; (d) Normalize the smoothed values by its standard deviation over the climatological period.\n",
100+
"> Niño X Index computation: a) Compute area averaged total SST from Niño X region; b) Compute monthly climatology (e.g., 1950-1979) for area averaged total SST from Niño X region, and subtract climatology from area averaged total SST time series to obtain anomalies; c) Smooth the anomalies with a 5-month running mean; d) Normalize the smoothed values by its standard deviation over the climatological period.\n",
99101
"\n",
100102
"![](https://www.ncdc.noaa.gov/monitoring-content/teleconnections/nino-regions.gif)\n",
101103
"\n",
102-
"At the end of this notebook, you should be able to produce a plot that looks similar to this [Oceanic Niño Index plot](https://climatedataguide.ucar.edu/sites/default/files/styles/extra_large/public/2022-03/indices_oni_2_2_lg.png):\n",
104+
"The overall goal of this tutorial is to produce a plot of ENSO data using Xarray; this plot will resemble the Oceanic Niño Index plot shown below.\n",
103105
"\n",
104106
"![ONI index plot from NCAR Climate Data Guide](https://climatedataguide.ucar.edu/sites/default/files/styles/extra_large/public/2022-03/indices_oni_2_2_lg.png)"
105107
]
@@ -110,7 +112,7 @@
110112
"tags": []
111113
},
112114
"source": [
113-
"Open the SST and areacello datasets, and use Xarray's `merge` method to combine them into a single dataset:"
115+
"In this first example, we begin by opening datasets containing the sea-surface temperature (SST) and grid-cell size data. (These datasets are taken from the Pythia example data library, using the Pythia package imported above.) The two datasets are then combined into a single dataset using Xarray's `merge` method."
114116
]
115117
},
116118
{
@@ -132,7 +134,7 @@
132134
"cell_type": "markdown",
133135
"metadata": {},
134136
"source": [
135-
"Visualize the first time slice to make sure the data looks as expected:"
137+
"This example uses Matplotlib and Cartopy to plot the first time slice of the dataset on an actual geographic map. By doing so, we verify that the data values fit the pattern of SST data:"
136138
]
137139
},
138140
{
@@ -156,10 +158,7 @@
156158
"source": [
157159
"## Select the Niño 3.4 region \n",
158160
"\n",
159-
"There are a couple ways to select the Niño 3.4 region:\n",
160-
"\n",
161-
"1. Use `sel()` or `isel()`\n",
162-
"2. Use `where()` and select all values within the bounds of interest"
161+
"In this set of examples, we demonstrate the selection of data values from a dataset which are located in the Niño 3.4 geographic region. The following example illustrates a selection technique that uses the `sel()` or `isel()` method:"
163162
]
164163
},
165164
{
@@ -176,7 +175,7 @@
176175
"cell_type": "markdown",
177176
"metadata": {},
178177
"source": [
179-
"The other option for selecting our region of interest is to use "
178+
"This example illustrates the alternate technique for selecting Niño 3.4 data, which makes use of the `where()` method:"
180179
]
181180
},
182181
{
@@ -195,7 +194,7 @@
195194
"cell_type": "markdown",
196195
"metadata": {},
197196
"source": [
198-
"Let's plot the selected region to make sure we are doing the right thing."
197+
"Finally, we plot the selected region to ensure it fits the definition of the Niño 3.4 region:"
199198
]
200199
},
201200
{
@@ -220,7 +219,7 @@
220219
"source": [
221220
"## Compute the anomalies\n",
222221
"\n",
223-
"We first group by month and subtract the mean SST at each point in the Niño 3.4 region. We then compute the weighted average over the region to obtain the anomalies:"
222+
"There are three main steps to obtain the anomalies from the Niño 3.4 dataset created in the previous set of examples. First, we use the `groupby()` method to convert to monthly data. Second, we subtract the mean sea-surface temperature (SST) from the monthly data. Finally, we obtain the anomalies by computing a weighted average. These steps are illustrated in the next example:"
224223
]
225224
},
226225
{
@@ -238,7 +237,7 @@
238237
"cell_type": "markdown",
239238
"metadata": {},
240239
"source": [
241-
"Now, smooth the anomalies with a 5-month running mean:"
240+
"In this example, we smooth the data curve by applying a `mean` function with a 5-month moving window to the anomaly dataset. We then plot the smoothed data against the original data to demonstrate:"
242241
]
243242
},
244243
{
@@ -266,7 +265,7 @@
266265
"cell_type": "markdown",
267266
"metadata": {},
268267
"source": [
269-
"Compute the standard deviation of the SST in the Nino 3.4 region, over the entire time period of the data array:"
268+
"Since the ENSO index conveys deviations from a norm, the calculation of Niño data requires a standard deviation. In this example, we calculate the standard deviation of the SST in the Niño 3.4 region data, across the entire time period of the data array:"
270269
]
271270
},
272271
{
@@ -283,7 +282,7 @@
283282
"cell_type": "markdown",
284283
"metadata": {},
285284
"source": [
286-
"Then we'll normalize the values by dividing the rolling mean by the standard deviation of the SST in the Niño 3.4 region:"
285+
"The final step of the Niño 3.4 index calculation involves normalizing the data. In this example, we perform this normalization by dividing the smoothed anomaly data by the standard deviation calculated above:"
287286
]
288287
},
289288
{
@@ -306,7 +305,7 @@
306305
"cell_type": "markdown",
307306
"metadata": {},
308307
"source": [
309-
"We will highlight values in excess of $\\pm$0.5, roughly corresponding to El Niño (warm) and La Niña (cold) events."
308+
"In this example, we use Matplotlib to generate a plot of our final Niño 3.4 data. This plot is set up to highlight values above 0.5, corresponding to El Niño (warm) events, and values below -0.5, corresponding to La Niña (cold) events."
310309
]
311310
},
312311
{
@@ -356,7 +355,7 @@
356355
"source": [
357356
"## Summary\n",
358357
"\n",
359-
"We have applied a variety of Xarray's selection, grouping, and statistical functions to compute and visualize an important climate index. "
358+
"This tutorial covered the use of Xarray features, including selection, grouping, and statistical functions, to compute and visualize a data index important to climate science."
360359
]
361360
},
362361
{
@@ -394,7 +393,7 @@
394393
"name": "python",
395394
"nbconvert_exporter": "python",
396395
"pygments_lexer": "ipython3",
397-
"version": "3.10.4"
396+
"version": "3.10.9"
398397
},
399398
"toc-autonumbering": false,
400399
"toc-showcode": false,

0 commit comments

Comments
 (0)