Analysing meteorological data with NumPy

Question

Use NumPy's loadtxt method to read in the weather data from the Met Office station at Heathrow, heathrowdata.txt:

Heathrow (London Airport)
Location 5078E 1767N 25m amsl
Estimated data is marked with a * after the value.
Missing data (more than 2 days missing in month) is marked by  ---.
Sunshine data taken from an automatic Kipp & Zonen sensor marked with a #...
   yyyy  mm   tmax    tmin      af    rain     sun
              degC    degC    days      mm   hours
   1948   1    8.9     3.3    ---     85.0    ---
   1948   2    7.9     2.2    ---     26.0    ---
   1948   3   14.2     3.8    ---     14.0    ---
   1948   4   15.4     5.1    ---     35.0    ---
   1948   5   18.1     6.9    ---     57.0    ---
   1948   6   19.1    10.3    ---     67.0    ---
   1948   7   21.7    12.0    ---     21.0    ---
   1948   8   20.8    11.7    ---     67.0    ---
   1948   9   19.6    10.2    ---     35.0    ---
   1948  10   14.9     6.0    ---     50.0    ---
   1948  11   10.8     4.6    ---     44.0    ---
   1948  12    8.8     3.8    ---     63.0    ---
   1949   1    8.5     1.8       9    23.0    ---
   1949   2   10.4     0.6      11    27.0    ---
   1949   3    9.3     1.2      11    26.1    ---
   1949   4   16.2     6.0       1    34.2    ---
   1949   5   17.1     6.8       0    56.9    ---
   1949   6   22.0    10.5       0     9.0    ---
   1949   7   25.1    12.9       0    46.5    ---
   1949   8   23.9    12.5       0    26.3    ---
   ...
   2016   6   20.7    12.7       0    93.4   101.7#  Provisional
   2016   7   24.0    14.5       0    16.0   182.8#  Provisional
   2016   8   24.7    14.6       0    21.6   201.4#  Provisional
   2016   9   22.4    13.5       0    42.2   122.1#  Provisional

Use NumPy's array methods to find:

  1. the 10 hottest and coldest months in the data set;
  2. the total rainfall in each year, and hence the wettest year in the data set;
  3. the least sunny June.

Solution

To access solutions, please obtain an access code from Cambridge University Press at the Lecturer Resources page for my book (registration required) and then sign up to scipython.com providing this code.