NCAS-CMS / cf-python

A CF-compliant Earth Science data analysis library
http://ncas-cms.github.io/cf-python
MIT License
124 stars 19 forks source link

Built-in support for (relative) potential vorticity #36

Open sadielbartholomew opened 4 years ago

sadielbartholomew commented 4 years ago

A user has requested direct support for potential vorticity, stating that it is rare for scientists to use the already-supported relative vorticity directly & instead they will usually work with vorticity via this potential quantity.

I've had a look at the definitions & (as conveyed well in this resource, see sections 3.5.2 & 3.5.3) it is the normalised dot product of the (absolute - but I assume relative potential vorticity is defined & used with the relative equivalent) vorticity with the gradient of some conserved quantity, in practice potential temperature.

That should not be too difficult to implement(?) as a function akin to cf.relative_voriticty taking, as well as u & v wind fields, two other input fields, temperature & pressure level. Though we might need to be careful to document mathematical assumptions made by any algorithm applied, as per the literature.

After a brief look around across other libraries, I found a pair of NCL functions that calculate the potential vorticity, possibly useful as a reference.

davidhassell commented 4 years ago

Sounds like a good addition, and I agree that it should be straightforward to implement.

The appropriate NCL function (http://www.ncl.ucar.edu/Document/Functions/Built-in/uv2vr_cfd.shtml) was used as the reference for the existing relative vorticity function (https://ncas-cms.github.io/cf-python/function/cf.relative_vorticity.html), so NCL could be a good starting point again.

sadielbartholomew commented 4 years ago

I'm just thinking this involves (two consecutive) binary operations such that, whilst the logic may be simple, implementing it with a LAMA approach would be more involved, as per #38. So I think this needs to wait on that Issue.