jhardenberg / smmregrid

A compact regridder using sparse matrix multiplication
Apache License 2.0
8 stars 0 forks source link

Atmospheric data with changing vertical mask #19

Open oloapinivad opened 1 year ago

oloapinivad commented 1 year ago

Somehow unexpectedly, I stepped on CMIP6 data where I would like to use smmregrid but where it is not possible. Indeed, 3D atmospheric data from IPSL model set NaN values at invalid pressure levels, i.e. where mountain ranges are found at lower levels. See figure here below:

Schermata 2023-07-04 alle 09 33 29

This means we have a changing mask along the plev dimension. Interpolation works, but leads to absurd values.

Although it should be possible to ask for level-dependent weights by specifying the vert_coord at the initiliazation, we need to add at least 1) a warning when we detect a changing mask along the vertical levels 2) the possibility of re-computing the weights on the flight if the weights have changed, just as CDO is doing...

oloapinivad commented 6 months ago

After a discussion we agreed that the possible is solution is to scan the along the vertical dimension only when generating weights and verify if the 3d treatment (i..e different weights for different vertical dimension) is required or not. This will be done only once for each dataset.