# How to calculate Lifted Index from ERA5 pressure level data?

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.

nc1=Dataset('pl_120415.nc')
lat1=np.array(nc1.variables['latitude'])
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)

li=np.subtract(t_500,tp_500,dtype=np.float32)

print("LI",li)

• 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? Jul 9 '19 at 16:49
• @SemidiurnalSimon thanks fo reply. Can you open this link weather.cod.edu/sirvatka/si.html . You may understand my query. 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.