This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Greetings! No, MetPy does not rely on the same code as NCL to compute cape. Unfortunately, the use of dewpoint or relatively humidity doesn't affect the problem--in fact, MetPy's `dewpoint_from_relative_humidity` function works fine on grids of data. The reason NCL's works quickly is because it is written manually in C/FORTRAN and loops over values in the compiled language. In Python, function calls are slow, so looping over a 2D array in Python and calling a function (e.g. some kind of calculation) will be a slow process. Thus, we have NumPy arrays that help speed up many calculations by performing the entire calculation across the entire array at once (and NumPy handles looping under the hood in C). Unfortunately, this only works for calculations that can readily be expressed as array operations. The calculations involved in calculating CAPE (integrals, finding per-grid point LCL, LFC, and EL points) don't lend themselves to NumPy's looping capabilities, so it requires doing it manually. We are planning on addressing this in the future, but there's nothing we have to offer besides manually looping at the moment. Cheers, Ryan > Hi Ryan, > > Sorry, misclicked the send button. > > I noticed that NCL's cape function used relative humidity as input, > not the dew-point. Should this > make the array operation a bit more doable with MetPy too? > > > > > Hi Ryan, > > > > plt.savefig(...) works. Thank you! > > > > I've tested that NCL can handle 2-dimensional arrays for cape and > > helicity calculation, not sure if you may use their core? > > Ticket Details =================== Ticket ID: TWK-728245 Department: Support Python Priority: Normal Status: Closed =================== NOTE: All email exchanges with Unidata User Support are recorded in the Unidata inquiry tracking system and then made publicly available through the web. If you do not want to have your interactions made available in this way, you must let us know in each email you send to us.