nctoolkit features built in methods for horizontal and vertical interpolation.
We will illustrate how to carry out horizontal interpolation using a global dataset of global SST from NOAA. Find out more information about the datset here.
The data is available using a thredds server. So we will work with the first time step, which looks like this:
import nctoolkit as nc ds = nc.open_thredds("https://psl.noaa.gov/thredds/dodsC/Datasets/COBE2/sst.mon.mean.nc") ds.subset(time = 0) ds.plot()
Interpolating to a regular lonlat grid#
If you want to interpolate to a regular latlon grid, you can use
lat specify the minimum and maximum longitudes and latitudes, while
res, a 3 variable list specifies the resolution. For example, if we wanted to regrid the globe to 0.5 degree north-south by 1 degree east-west resolution, we could do the following:
ds = nc.open_thredds("https://psl.noaa.gov/thredds/dodsC/Datasets/COBE2/sst.mon.mean.nc") ds.subset(timestep = 0) ds.to_latlon(lon = [-79.5, 79.5], lat = [0.75, 89.75], res = [1, 0.5]) ds.plot()