Translation of Paul O'Gorman's matlab code into python. Calculation is eqn. 2 in O'Gorman and Schneider, PNAS, 106, 14773-14777, 2009. Takes vertical profile of vertical velocity; vertical profile of temperature; vertical profile of pressure levels; and surface pressure, and outputs rainfall in kg/m^2/s. Results are the same as the matlab equivalent to ~6 decimal places. Note that the highest pressure must be the first element of the input arrays.
Please first run the following example code to check if you get the same precip amount. Old versions of numpy can result in an incorrect result.
import numpy as np
from precip_extremes_scaling import scaling
# generate dummy data for this example
omega = np.linspace(-0.3, 0.2, 10)
temp = np.linspace(270, 220, 10)
plev = np.linspace(100000, 10000, 10)
ps = 100000
precip = scaling(omega, temp, plev, ps) # result is 6.1e-05 kg/m^2/s.
# multiply by 86400 for mm/day