Examples

This tutorial runs through a number of example work flows.

Global sea surface temperature since 1850

This example analyzes a global sea surface temperature dataset, covering the years since 1850. The data is available from the National Oceanic and Atmospheric Administration (NOAA) here.

We are looking at global sea surface temperature since 1850, so an obvious question is how much the oceans have warmed over this time period. We can use nctoolkit’s spatial_mean method to calculate this:

Once the file is downloaded, we should set it to ff:

[1]:
import nctoolkit as nc
ff = "sst.mon.mean.nc"
nctoolkit is using Climate Data Operators version 1.9.10
[2]:
ds = nc.open_data(ff)
ds.spatial_mean()
ds.plot()
[2]:

We can see a clear temperature rise of about 1 degree Celcius. But this is monthly data, so a bit noisy. We can smooth it out by taking an annual mean. In this case we send “year” to tmean to tell it to calculate the mean for each year:

[3]:
ds = nc.open_data(ff)
ds.tmean(["year"])
ds.spatial_mean()
ds.plot("sst")
[3]:

That is getting better. But again, we possibly want a rolling average. We can use the rolling_mean method to calculate the mean over every 20-year period:

[4]:
ds = nc.open_data(ff)
ds.tmean(["year"])
ds.spatial_mean()
ds.rolling_mean(20)
ds.plot("sst")
[4]:

We’ll finish things off by tweaking this so that we can work out how much temperature has increased since the first 20 years in the time period. For this we can use the annual_anomaly method.

[5]:
ds = nc.open_data(ff)
ds.annual_anomaly(baseline = [1850, 1869], window = 20)
ds.spatial_mean()
ds.plot("sst")
[5]:

More to come….