[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Support #QIA-399358]: Metpy python skew-t
- Subject: [Support #QIA-399358]: Metpy python skew-t
- Date: Wed, 26 May 2021 13:27:06 -0600
Greetings,
I think one problem here is that to properly apply the virtual temperature
correction, you don't just use Tv as your starting point for parcel ascent, but
you need to correct *all* of the temperatures (since what you're doing is
correcting temperature to better represent the density of the air including
moisture). Here's some code that seemed to work for me;
import metpy.calc as mpcalc
from metpy.cbook import get_test_data
from metpy.units import units
import pandas as pd
# Read from our test dataset
col_names = ['pressure', 'height', 'temperature', 'dewpoint', 'direction',
'speed']
df = pd.read_fwf(get_test_data('may22_sounding.txt', as_file_obj=False),
skiprows=5, usecols=[0, 1, 2, 3, 6, 7], names=col_names)
# Drop any rows with all NaN values for T, Td, winds and assign units
df = df.dropna(subset=('temperature', 'dewpoint', 'direction', 'speed'),
how='all'
).reset_index(drop=True)
p = df['pressure'].values * units.hPa
t = df['temperature'].values * units.degC
td = df['dewpoint'].values * units.degC
# Calculate the parcel profile including the LCL--and get new pressure,
temperature,
# and dewpoint that include values interpolated at the LCL
p, t, td, prof_t = mpcalc.parcel_profile_with_lcl(p, t, td)
# Calculate the water vaport mixing ratio from dewpoint
mv = mpcalc.mixing_ratio(mpcalc.saturation_vapor_pressure(td), p)
# Calculate the virtual temperature for the atmospheric temperature profile
# and for the parcel's profile
tv = mpcalc.virtual_temperature(t, mv)
prof_tv = mpcalc.virtual_temperature(prof_t, mv)
# Calculate cape/cin using the virtual temperature for *both* temperatures
mpcalc.cape_cin(p, tv, td, prof_tv)
Hope that helps,
Ryan
> Hello,
>
> The Tv prints out one number as it should but when I do this:
>
> # Virtual temperature
> parcel_prof_virtual = mpcalc.parcel_profile(p, Tv, Td[0]).to('degC')
>
> # Calculate CAPEV / CINSV Not working properly
> # CAPEV, CINSV = mpcalc.capev_cinv(p, Tv, Td[0], parcel_prof_virtual,
> which_lfc='bottom', which_el='top')
>
> It throws an error for parcel_prof_virtual which also throws an error for the
> next line.
Ticket Details
===================
Ticket ID: QIA-399358
Department: Support Python
Priority: Normal
Status: Closed
===================
NOTE: All email exchanges with Unidata User Support are recorded in the Unidata
inquiry tracking system and then made publicly available through the web. If
you do not want to have your interactions made available in this way, you must
let us know in each email you send to us.