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.26k stars 415 forks source link

Tropical Cyclone Potential Intensity #3677

Open stella-bourdin opened 2 weeks ago

stella-bourdin commented 2 weeks ago

What should we add?

Hello, Would it be possible to add a function to compute tropical cyclone (TC) potential intensity (PI) in MetPy? PI is a widely used variable in the TC community. It defines the theoretical maximum intensity of a tropical cyclone in a given environment as defined by temperature and humidity. The only existing Python package to compute it (Gilford et al., 2021) is a Python translation of K. Emanuel's Matlab code, it is not built in a very flexible manner, does not handle units well and is very slow. I tried improving the existing code but find myself going back to the fundamentals, so I believe it would make more sense to include it within MetPy's already existing infrastructure and take advantage of the existing functions, as well as MetPy's visibility. I am considering contributing it myself, however, I am not well acquainted with both the meteorological concepts behind PI, nor MetPy's infrastructure, so it might take quite a lot of time before I can... So I thought maybe someone here is better equipped to do so? Or at least to help me? Thanks, Stella

Reference

Bister & Emanuel, 1998 Wing et al., 2015 Gilford et al., 2021 Wikipedia

DWesl commented 1 week ago

Do you have an equation in mind? There's a few in the referenced papers. MetPy has moist static energy, saturation mixing ratio, and CAPE, if that is where your problem is.

If it is primarily speed you are after, would it make more sense to grab the Fortran version the other package links, wrap it with f2py, then wrap the result with pint.wraps to handle units? I don't know that that will beat the numba.njit decorators currently on the python version for repeated computation, but it should help with the first dozen calculations (alternately, I think numba has functions for ahead-of-time compiling if you want to go that route instead).

stella-bourdin commented 13 hours ago

Hi, I don't know that one equation/way of computing is better than another. I am aware of existing methods, but I get different results with tcPIpy's CAPE and MetPy's one and I can't understand why... I did not think about wrapping FORTRAN, I can consider that. Do you think it would be out of place to implement this within MetPy though? I see value in it.