<p>Metpy 1.0 has a <a href="https://unidata.github.io/MetPy/latest/api/generated/metpy.calc.lifted_index.html" rel="nofollow noreferrer">lifted_index</a> function, which requires a profile temperature parameter, which in turn can be calculated using the <a href="https://unidata.github.io/MetPy/latest/api/generated/metpy.calc.parcel_profile.html" rel="nofollow noreferrer">parcel_profile</a> 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 <code>r</code> variable is, so I'm not sure whether that could help you with such a calculation. Also, rather than using numpy arrays, using <a href="http://xarray.pydata.org/en/stable/" rel="nofollow noreferrer">xarray</a> for working with netcdf input variables tends to be easier and more efficient.</p>

CC BY-SA 4.0
2021-03-31T14:21:06.793Z
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.
BarocliniCplusplus
CC BY-SA 4.0
2021-03-31T13:10:05.590Z
2021-03-31T13:10:05.590Z
climatestudent
<p>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.    </p>

<pre><code>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)
</code></pre>

CC BY-SA 4.0
2019-07-09T16:49:01.590Z
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?
Semidiurnal Simon
CC BY-SA 4.0
2019-07-10T04:18:12.120Z
@SemidiurnalSimon thanks fo reply. Can you open this link https://weather.cod.edu/sirvatka/si.html . You may understand my query.
Miss Priya Kumari
<era><python>
How to calculate Lifted Index from ERA5 pressure level data?
Miss Priya Kumari
# How to calculate Lifted Index from ERA5 pressure level data?

(Asked by: username_0 on 2019-07-09)

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)

```

**Tags:** era, python

> **Comments:**
> **username_1**: 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?  
> **username_0**: @username_1 thanks fo reply. Can you open this link https://weather.cod.edu/sirvatka/si.html . You may understand my query.  

---

## 1 answers

### Answer by username_2 on 2021-03-31. Score: 2

Metpy 1.0 has a [lifted\_index](https://unidata.github.io/MetPy/latest/api/generated/metpy.calc.lifted_index.html) function, which requires a profile temperature parameter, which in turn can be calculated using the [parcel\_profile](https://unidata.github.io/MetPy/latest/api/generated/metpy.calc.parcel_profile.html) 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](http://xarray.pydata.org/en/stable/) for working with netcdf input variables tends to be easier and more efficient.

> **Comments:**
> **username_3**: 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.  

---

