Analyzing intra-year daily average temperatures

We are going to have a look at the temperature variation within a year by converting dates to the corresponding day of the year in numbers. This number is between 1 and 366, where 1 corresponds to January 1st and 365 (or 366) corresponds to December 31st. Perform the following steps to analyze the intra-year daily average temperature:

  1. Initialize arrays for the range 1-366 with averages initialized to zeros:
    rng = np.arange(1, 366)
    avgs = np.zeros(365)
    avgs2 = np.zeros(365)
  2. Calculate averages by the day of the year before and after a cutoff point:
    for i in rng: indices = np.where(days[:cutoff] == i) avgs[i-1] = temp[indices].mean() indices = np.where(days[cutoff+1:] == i) avgs2[i-1] = temp[indices].mean() ...

Get Learning NumPy Array now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.