Skip to content

Problem with metpy.calc.lifted_index #3279

@fuliii1

Description

@fuliii1

Hi Team,

I test metpy.calc.lifted_index calculation with University of Wyoming Upper air observations data. In this database the lifted index is provided but if I calculate lifted index with Metpy I get different result and sometimes runtime warnings.

In the code example I used this database:
https://weather.uwyo.edu/cgi-bin/sounding?region=europe&TYPE=TEXT%3ALIST&YEAR=2023&MONTH=07&FROM=1412&TO=1412&STNM=12843

from metpy.calc import dewpoint_from_relative_humidity, lifted_index, parcel_profile
from metpy.units import units

p = [1002.0, 1000.0, 993.0, 925.0, 850.0, 846.0, 843.0, 826.0, 823.0, 766.0,
    748.0, 734.0, 723.0, 711.0, 700.0, 686.0, 668.0, 658.0, 637.0, 632.0,
    579.0, 568.0, 550.0, 549.0, 511.0, 500.0, 479.0, 439.0, 420.0, 400.0,
    373.0, 356.0, 300.0, 284.0, 280.0, 273.0, 267.0, 250.0, 242.0, 241.0,
    239.0, 230.0, 215.0, 213.0, 212.0, 207.0, 204.0, 200.0, 196.0, 195.0,
    163.0, 150.0, 140.0, 135.0, 131.0, 127.0, 115.0, 112.0, 108.0, 100.0,
    93.0, 91.0, 87.1, 87.0, 81.0, 79.0, 77.0, 73.0, 72.7, 70.0, 69.0,
    67.0, 66.0, 64.0, 62.0, 54.6, 52.0, 51.0, 50.0, 47.0, 44.0, 42.0,
    41.0, 38.0, 37.0, 36.4, 36.0, 32.0, 31.0, 30.0, 29.0, 28.3, 28.0,
    26.0, 25.0, 23.0, 22.8, 20.0, 19.0, 18.0, 17.0, 16.4, 15.6, 15.0,
    14.0, 11.0, 10.0, 9.2, 9.0, 8.6
] * units.hPa

T = [28.2, 27.0, 25.4, 19.4, 12.8, 12.3, 12.0, 10.8, 11.2, 6.4, 
     4.8, 3.6, 4.2, 4.0, 3.8, 4.0, 2.2, 1.9, 1.2, 0.8, -3.5, -4.3,
     -5.7, -5.8, -9.9, -10.9, -12.7, -16.9, -18.3, -21.1, -25.2,
     -27.9, -38.5, -41.7, -42.6, -44.3, -45.5, -49.5, -51.7, -51.7,
     -52.3, -54.3, -57.5, -57.9, -58.1, -57.1, -56.5, -57.5, -58.5,
     -58.3, -52.3, -52.9, -53.9, -54.5, -54.9, -55.4, -56.9, -57.3,
     -56.4, -54.5, -57.0, -57.8, -59.3, -59.3, -59.0, -58.9, -58.8,
     -58.5, -58.5, -57.5, -57.2, -56.6, -56.3, -55.6, -55.0, -52.3,
     -52.9, -53.1, -53.3, -53.3, -53.4, -53.4, -53.4, -53.5, -53.5,
     -53.5, -53.3, -51.4, -50.8, -50.3, -49.4, -48.7, -48.8, -49.2,
     -49.4, -49.9, -49.9, -47.9, -47.3, -46.6, -45.9, -45.5, -45.9,
     -45.0, -43.4, -37.7, -35.5, -34.5, -34.6, -34.7
] * units.degC

rh = [.42, .45, .44, .60, .84, .86, .88, .86, .67, .76,
      .79, .82, .41, .23, .13, .6, .23, .17, .8, .27,
      .15, .33, .11, .11, .37, .28, .10, .46, .37, .37,
      .29, .25, .24, .20, .23, .28, .58, .67, .73, .73,
      .48, .42, .56, .49, .46, .26, .18, .20, .20, .19,
      .2, .1, .1, .1, .1, .1, .1, .1, .1, .1, .1, .1, 
      .1, .1, .1, .1, .1, .1, .1, .1, .1, .1, .1, .1,
      .1, .1, .1, .1, .1, .1, .1, .1, .1, .1, .1, .1,
      .1, .1, .1, .1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0
] * units.dimensionless

Td = dewpoint_from_relative_humidity(T, rh)
prof = parcel_profile(p, T[0], Td[0])
lift_index = lifted_index(p, T, prof)
print(f'   Lifted Index: {lift_index:.2f}')

lifted index provided by University of Wyoming:
Lifted index: 2.02
LIFT computed using virtual temperature: 1.72

But the calculated with Metpy is
Lifted Index: [-0.25] delta_degree_Celsius

The runtime warning logs:
C:\Users\fulopg\AppData\Roaming\Python\Python312\site-packages\metpy\calc\thermo.py:1396: RuntimeWarning: divide by zero encountered in log val = np.log(vapor_pressure / mpconsts.nounit.sat_pressure_0c) C:\Users\fulopg\AppData\Roaming\Python\Python312\site-packages\metpy\calc\thermo.py:1397: RuntimeWarning: invalid value encountered in divide return mpconsts.nounit.zero_degc + 243.5 * val / (17.67 - val) Lifted Index: [-0.25] delta_degree_Celsius

Please help to judge which is the accurate lifted index.

Thanks for you help,
Gabor Fulop

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: DocsAffects documentationType: EnhancementEnhancement to existing functionality

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions