Plotting¶
nctoolkit provides automatic plotting of netCDF data in a similar way to the command line tool ncview.
If you have a dataset, simply use the plot
method to create an interactive plot that matches the data type.
We can illustate this using a sea surface temperature dataset available here.
Let’s start by calculating mean sea surface temperature for the year 2000 and plotting it:
[1]:
import nctoolkit as nc
ff = "sst.mon.mean.nc"
ds = nc.open_data(ff)
ds.subset(year = 2000)
ds.tmean()
ds.plot()
nctoolkit is using Climate Data Operators version 1.9.10
[1]:
We might be interested in the zonal mean. nctoolkit can automatically plot this easily:
[2]:
ff = "sst.mon.mean.nc"
ds = nc.open_data(ff)
ds.subset(year = 2000)
ds.tmean()
ds.zonal_mean()
ds.plot()
[2]:
nctoolkit can also easily handle heat maps. So, we can easily plot the change in zonal mean over time:
[3]:
ff = "sst.mon.mean.nc"
ds = nc.open_data(ff)
ds.zonal_mean()
ds.annual_anomaly(baseline = [1850, 1869], window = 20)
ds.plot()
[3]:
In a similar vein, it can automatically handle time series. Below we plot a time series of global mean sea surface temperature since 1850:
[4]:
ff = "sst.mon.mean.nc"
ds = nc.open_data(ff)
ds.spatial_mean()
ds.plot()
[4]:
Internal: ncplot¶
Plotting is carried out using the ncplot package. If you come across any errors, please raise an issue here.
This is a package that aims to deliver easy use. Colour scales for heat map default to a diverging blue-to-red pallette when there are positives and negatives and a viridis palette otherwise.