MetOffice / PyPRECIS

PyPRECIS is the python based training environment for Met Office PRECIS training courses.
BSD 3-Clause "New" or "Revised" License
20 stars 2 forks source link

Calculation of future timeseries anomaly not what intended in worksheet 4 #144

Closed nhsavage closed 1 year ago

nhsavage commented 2 years ago

In section 4.4 "Future time series"

the anomaly is calculated by subtracting the average of the whole 20 years of the baseline period. This results in a plot with a strong seasonal cycle. What we really want is the anomaly of the monthly mean from the 20 year period.

So after the line

iris.save(future_land, futureout)

we want to calculate the mean of each Jan, Feb etc for the baseline:

iris.coord_categorisation.add_month_number(baseline_land, 'time', name='month_number') baseline_monthly_mean = baseline_land.aggregated_by(['month_number'], iris.analysis.MEAN)

as done in previous worksheet

this gives us a cube with just 12 points in it – one for every month. We need some data with 240 points though as the future data has 20 years of data. Add the line of code below to repeat the 12 months 20 times.

baseline_mm = np.tile(baseline_monthly_mean.data,20)

then change this line: baseline_land.data.mean() to: diff.data = future_land.data - baseline_mm

this also needs to be corrected in the solution for section h) Produce and plot a montly time series of temperature data

nhsavage commented 2 years ago

image This is what the temperature timeseries should look like - always >0 and with no seasonal cycle

AMLG22 commented 1 year ago

Thanks... it works!