ESMValGroup / ESMValCore

ESMValCore: A community tool for pre-processing data from Earth system models in CMIP and running analysis scripts.
https://www.esmvaltool.org
Apache License 2.0
42 stars 38 forks source link

`extract_levels` fails silently when scheme='nearest' or 'linear' and layer is shallower than shallowest point in z axis. #1493

Open ledm opened 2 years ago

ledm commented 2 years ago

The extract_levels preprocessor fails silently when a layer is requested which is shallower than the shallowest point in the ocean z axis, for the schemes nearest and linear. The resulting output is a cube where all points are masked.

Many ocean models first layer is around 1m thick, and the cell centre will be around 0.5m deep. If you use extract_levels to request a layer close to the surface, like 0.1m deep, it will produce a fully masked cube silently.

ie:

    extract_levels:
       scheme: nearest
       levels: [0.1 ,]

The solution to this problem exists already (yay!), we need to use the scheme nearest_extrapolate or linear_extrapolate, but some kind of warning or error would be useful. This information may exist in the documentation, but a clear error message is worth ten pages of documentation.

The check would be to look whether any of the depth values in the input list fall outside the min/max z range given by the model. The output message would be something like: "It looks like this depth level is output the depth cell centres. Please use the nearest_extrapolate or linear_extrapolate schemes. "

Alternatively, perhaps we also fix the “nearest” calculation so that it looks at the lat/lon/depth boundaries? @schlunma and @valeriupredoi think this is harder to do though.

Note that this problem may also occur in the atmosphere or at the sea floor, but I haven't checked.

valeriupredoi commented 2 years ago

cheers @ledm - a good issue indeed! :beer: