I have taken a thunderstorm case where I need to calculate indices but I am not getting any code related stability indices in Python language, the code is available in GRADS, NCL for me it's difficult to understand. I used MetPy code but they are not calculated LI, KI, and other indices...Thanks in advance Below code is wrong that I know I used the formula but tell me the correct way.

lon1= np.array(nc1.variables['longitude'])
lev= np.array(nc1.variables['level'])
time= nc1.variables['time']
r= nc1.variables['r'][:,:,25:28,20:25]
t= nc1.variables['t']
u= nc1.variables['u'][:,:,25:28,20:25]
v= nc1.variables['v'][:]
w= nc1.variables['w']

t_500= nc1.variables['t'][:,21,:,:] ### domain Air Temperture  at 500 Pressure_level
tp_500= nc1.variables['t'][:,21,25:28,20:25] ## at specfific location temperature (parcel temperture)


  • $\begingroup$ Hi, welcome to Stackexchange. Some may argue that this is off-topic here. I'd say it is on topic, but you'll need to be a lot clearer in explaining exactly what you're trying to do, and what you don't understand. "I need to calculate indices" doesn't tell me very much! What indices? $\endgroup$ – Semidiurnal Simon Jul 9 '19 at 16:49
  • $\begingroup$ @SemidiurnalSimon thanks fo reply. Can you open this link weather.cod.edu/sirvatka/si.html . You may understand my query. $\endgroup$ – Miss Priya Kumari Jul 10 '19 at 4:18

Metpy 1.0 has a lifted_index function, which requires a profile temperature parameter, which in turn can be calculated using the parcel_profile function. That requires having the dew point temperature, which you would either have to have directly, or calculate from another moisture content variable. I'm not sure what your r variable is, so I'm not sure whether that could help you with such a calculation. Also, rather than using numpy arrays, using xarray for working with netcdf input variables tends to be easier and more efficient.

  • 2
    $\begingroup$ It is worth noting, using the lifted index function expects a 1D array. In other words, OP will have to loop through all of the times and all of the horizontal gridpoints. $\endgroup$ – BarocliniCplusplus Mar 31 at 14:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.