Unidata / MetPy

MetPy is a collection of tools in Python for reading, visualizing and performing calculations with weather data.
https://unidata.github.io/MetPy/
BSD 3-Clause "New" or "Revised" License
1.24k stars 413 forks source link

Adding equation and code for Ertel Potential Vorticity #231

Open winash12 opened 7 years ago

winash12 commented 7 years ago

EPV is a well known equation in meteorology. Any interest in adding it ?

dopplershift commented 7 years ago

I would absolutely accept a pull request implementing such a function somewhere in the metpy.calc package. I can also add it myself, but make no promises as to when that would climb to the top of my todo list.

Either way, we'd need a solid reference (not some random web page) to include in the documentation and on which to base the implementation.

dopplershift commented 7 years ago

Actually, the only thing missing from MetPy is density. NumPy has gradient and diff, and we have a wrapper for gradient to handle units.

jrleeman commented 7 years ago

Density was added in #337

ahaberlie commented 7 years ago

Working on project implementing eq. 2.2 from this paper: http://journals.ametsoc.org/doi/pdf/10.1175/1520-0493(1991)119%3C1929:PVDOC%3E2.0.CO;2

spherical_epv

which is EPV using spherical coordinates. By the way, its not pi in that equation, it is something called the Exner function. Thought it might be a good addition to MetPy and it is related to this issue.

Would the ideal function interface (in relation to other EPV types) be something like:

epv(..., kind='spherical')

or

spherical_epv(...)

Trying to figure out if can be generalized.

jrleeman commented 7 years ago

I would argue for spherical_epv(...) to keep the functions as simple and encapsulated as possible.

dopplershift commented 7 years ago

@ahaberlie happy to have the functionality

In my ideal world, this would be encapsulated by projection and coordinate information attached to the relevant variables. But:

  1. We're not yet able to utilize xarray
  2. I'm not even sure that would work for something as complex as this

While I agree with @jrleeman in principle, what about vertical vorticity? Advection? Geostrophic wind? Just a nasty rabbit hole.

Go with spherical_epv for now, and we can revisit if/when a better solution presents itself.

dopplershift commented 6 years ago
  1. For now, just use metpy's existing vorticity implementation. We can go back and add support for map factors there (however we end up doing that) and everything will benefit.

  2. I don't think they should need to be

  3. If you pass the proper sign for the increment in the longitudinal direction, then the calculation should work correctly. (i.e. if the data are N-S oriented, the increments should be negative, and vice-versa for S-N oriented data)

dopplershift commented 6 years ago

Looks smooth. My question is: have you actually tried interpolating using T vs. ln P? Is the difference discernible?