Skip to main content

13.8) Exercise 37 - Seasonal Rainfall


Consider the following array, which contains the monthly UK rainfall of 2012 (in mm), starting at January.

rainfall_2012=np.array([110.9, 60.0, 37.0, 128.0, 65.8, 149.0, 118.9, 111.3, 112.9, 126.2, 135.5, 179.4])
  • Rainfall[0] is the rainfall for January
  • Rainfall[1] is the rainfall for February
  • Rainfall[-1] is the rainfall for December

December 2011 rainfall was 168.1mm

  1. Create a new array by putting the December 2011 rainfall at the start of the rainfall_2012 array.
  2. Calculate the total rainfall by season with:
    • Winter : Dec 11 , Jan 12, Feb 12
    • Sprint : Mar-May 12
    • Summer : Jun-Aug 12
    • Autumn : Sep-Nov 12

Rather than specifying which elements of the array to sum, re-arranging the shape of the array and sum the values over an axis.
Solution: Np_seasonal_rainfall.py