Skip to content

Commit dbbe01b

Browse files
committed
Updated lesson notebook to be consistent with lesson changes
1 parent 02e296e commit dbbe01b

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

notebooks/L6/numpy/Advanced-data-processing-with-NumPy.ipynb

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,13 @@
280280
"cell_type": "markdown",
281281
"metadata": {},
282282
"source": [
283-
"### Calculations within a date range\n",
283+
"## Calculations within a date range\n",
284284
"\n",
285285
"One common thing we'd like to do is calculate something about our data over a fixed time range, for example, one year.\n",
286286
"We've seen this idea previously, but just to remind you we can do this by masking our data.\n",
287+
"\n",
288+
"### Removing missing data\n",
289+
"\n",
287290
"First, let's check for any missing data in the `tmax` array."
288291
]
289292
},
@@ -423,9 +426,12 @@
423426
"cell_type": "markdown",
424427
"metadata": {},
425428
"source": [
426-
"### Splitting dates into separate year, month, day\n",
429+
"## Splitting dates into separate year, month, and day\n",
427430
"\n",
428431
"Now we can go about splitting our dates into separate arrays for the year, month, and day.\n",
432+
"\n",
433+
"### Splitting a single date string\n",
434+
"\n",
429435
"As a reminder, it is first useful to recall that character strings can be sliced using index values just like arrays."
430436
]
431437
},
@@ -462,6 +468,8 @@
462468
"cell_type": "markdown",
463469
"metadata": {},
464470
"source": [
471+
"### Splitting dates in a NumPy array\n",
472+
"\n",
465473
"With this in mind, we can now attempt the same in our NumPy array `date_clean_str`."
466474
]
467475
},
@@ -534,9 +542,12 @@
534542
"cell_type": "markdown",
535543
"metadata": {},
536544
"source": [
537-
"### Finding the average monthly max temperature\n",
545+
"## Finding averages in a date range\n",
538546
"\n",
539547
"Now that we have separate arrays for the year, month, and day we can do some fun stuff like calculate the monthly average temperature for a given year.\n",
548+
"\n",
549+
"### Finding the average monthly max temperature\n",
550+
"\n",
540551
"Let's take 2010 again as our example and find the average temperatures for each month in 2010.\n",
541552
"For this, we can use a `for` loop."
542553
]
@@ -571,7 +582,7 @@
571582
"1. We created an array of zeros with 12 locations to store the monthly average temperatures.\n",
572583
"2. We used an index variable called `index` to define where to store those monthly average temperatures. We could have done this differently, but there is a good reason to use `index` here because it is more flexible if we wanted to consider more than one year of data as you'll see in this week's exercise.\n",
573584
"3. We then used a `for` loop to go through each unique month (found using `np.unique()`).\n",
574-
"4. For each month we found the max temperature using the condition `month == month_now`, and taking the `tmax_clean.mean()` for that month.\n",
585+
"4. For each month we found the max temperature using the condition `month == month_now`, and taking the `tmax_clean.mean()` for that month. We also limit the months to those in 2010 by using the `year == '2010'` condition.\n",
575586
"5. We added `1` to the `index` value to ensure the next mean value goes into the correct location in the `means_2010` array.\n",
576587
"\n",
577588
"This might seem a bit complicated, but it is rather powerful as well.\n",
@@ -709,7 +720,7 @@
709720
"cell_type": "markdown",
710721
"metadata": {},
711722
"source": [
712-
"### Comparing monthly temperatures\n",
723+
"### Calculating temperature anomalies\n",
713724
"\n",
714725
"One thing we can do now that we have a mean temperature for February in 2010-2015 is to compare one of those years to the average max temperature in the time period.\n",
715726
"This would give us a temperature anomaly, the difference between the mean value and a given year.\n",
@@ -734,7 +745,8 @@
734745
"cell_type": "markdown",
735746
"metadata": {},
736747
"source": [
737-
"As we can see, February of 2010 was 1.7° Fahrenheit warmer than the average February between 2010 and 2015.\n",
748+
"As we can see, February of 2010 was only 0.08° Fahrenheit warmer than the average February between 2010 and 2015.\n",
749+
"Pretty typical February, it would seem.\n",
738750
"We'll explore exactly this kind of thing in more detail in this week's exercise."
739751
]
740752
}

0 commit comments

Comments
 (0)