How to calculate Lifted Index from ERA5 pressure level data?
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.