Vertical methods
nctoolkit features built in methods for handling files with multiple vertical levels. They work for datasets with fixed vertical levels, for example ocean data with z-levels, as well as files with varying vertical levels such as terrain following coordinates.
The vertical methods available will be illustrated using depth-resolved ocean temperatures from NOAA’s World Ocean Atlas for January to a depth of 500 metres. The vertical_interp
method requires a levels
argument, which is sea-depth in this case.
[1]:
import nctoolkit as nc
nc.deep_clean()
ds = nc.open_thredds("https://data.nodc.noaa.gov/thredds/dodsC/ncei/woa/temperature/A5B7/1.00/woa18_A5B7_t01_01.nc")
ds.subset(variables="t_an")
ds.run()
nctoolkit is using the latest version of Climate Data Operators version: 2.0.5
We can see right awy that there are 57 vertical levels, going as deep as 1500 metres.
[2]:
len(ds.levels)
min(ds.levels)
max(ds.levels)
[2]:
57
[2]:
0.0
[2]:
1500.0
Calculating simple vertical statistics
If we want to calculate the mean temperature across all vertical levels, we can do the following. Note: that you must specify the fixed arg, which tells nctoolkit whether the vertical levels are consistent in this space. In this case they are. Note: this method will account for cell thickness when calculating the mean.
[3]:
ds_mean = ds.copy()
ds_mean.vertical_mean(fixed = True)
ds_mean.plot()