W02-2.1: Count the number of occurrences of each warm ENSO category

Using the ONI data set from the previous worksheet, identify the number of months with

  • weak,
  • medium,
  • strong,
  • and very strong

warm ENSO conditions (i.e. El Niño only).

In order to fulfill the required tasks, you will need to

  • initialize counter variables for the different categories of warm ENSO stages,
  • write a for loop with embedded if-elif conditions (one for each stage),
  • and increment the stage-specific counter variables based on the anomaly thresholds given in W02-1: Loops.

In [1]:
import pandas as pd

url = "http://www.cpc.ncep.noaa.gov/data/indices/oni.ascii.txt"

# help(pd.read_fwf)
oni = pd.read_fwf(url, widths = [5, 5, 7, 7])
oni.head()


Out[1]:
SEAS YR TOTAL ANOM
0 DJF 1950 24.72 -1.53
1 JFM 1950 25.17 -1.34
2 FMA 1950 25.75 -1.16
3 MAM 1950 26.12 -1.18
4 AMJ 1950 26.32 -1.07

In [ ]:
## Your solution goes here:

In addition, please calculate the percentage of months characterized by at least weak El Niño conditions?


In [ ]:
## Your solution goes here:

W02-2.2: Do the same for cold ENSO events...

...and put the stage-specific counter variables for both warm and cold ENSO stages together in a single dictionary using meaningful and clearly distinguishable keys (e.g. 'Weak El Nino', 'Moderate El Nino', ..., 'Weak La Nina', ...). If you feel a little insecure with creating dict objects, feel free to browse back to E01-3 and let yourself inspire by the code included therein.

Oh, and remember that the stuff you created for answering the above task is still in the Jupyter Notebook's environment, so there is no need carry out the whole El Niño processing anew.


In [1]:
## Your solution goes here: