El Niño intensities

Discussion thread for El Niño intensities.

In the El Nino intensities problem trying the following code:

with open('mei.ext_index.txt') as csvfile:
        reader = csv.reader(csvfile, delimiter='	')
        next(reader, None)  # skip the header line
        year_mei = {rows[0]:rows[1:12] for rows in reader}

to get a dictionary as {‘year’:'list of mei values} results in the last column of values for NovDec bi-month being missed; the list has length 11 not 12.

Solved my own issue. I must remember that the range operator ‘n:m’ means ‘n’ up to but excluding ‘m’.

1 Like

Haha yeah that always messes me up in Python.

Confused over both the input to the function and what is expected as output:

Input : A two-year range corresponding to a specific winter season (in the Northern Hemisphere).

Output : Two strings: 1. “El Nino”, “La Nina”, or “neither” depending whether the season had an El Niño or La Niña event (or neither), and if there was an event, and 2. “weak”, “moderate”, "strong, or “very strong” depending on the event’s intensity. If there was no event, return “none” for the intensity.

I interpreted the input description as asking for the specific winter season bi-months in the Northern Hemisphere across the year boundary, i.e NovDec, DecJan, JanFeb, FebMar, MarApr. This assumes you define winter as starting at the winter solstice and ending at the vernal equinox, AND including both bi-months that contain the months in which these occur. Note this gives you the five consecutive months you need to check for an “event”. However, the tests output appears to have checked the entirety of both years in the input string; inspection of the floating point value in the expected output shows it is the maximal absolute value of the first event found in the two year period (though see below). Note that this value is not asked for in the output description, which only asks for the ‘classification’ and the ‘intensity’ strings.

The test code for this problem is likely wrong. Specifically, try the inputs ‘1898-99’ and ‘2001-02’. The expected output from ‘2001-02’ is ‘El Nino, moderate, 1.223’. From looking at the data text file the value 1.223 comes from the very end of 2002; the test code must have checked both years fully. Now try ‘1898-99’. The expected output received was ‘Neither, none, 0’. However, from the text file we see five consecutive months at the end of 1899 with an MEI over +0.5; the criteria for El Nino.