lsoda when setting up parcel_profile function for cape_cin function #3144
Replies: 2 comments
-
So on the current version of MetPy, that output is accompanied by:
Essentially the ODE integrator we use to calculate the moist adiabats doesn't like that you're trying to calculate down to 0.1 hPa. You're also doing a lot of fighting with the units above. The original netCDF file has unit metadata, so let's just let things flow naturally. This is how I'd write that code above, which slices off the last 15 values of the pressure array so we're only dealing with data up to 50 hPa: import metpy.calc as mpcalc
from metpy.units import units
import xarray as xr
nc_file = xr.open_dataset('/Users/rmay/Downloads/MERRA2_400.inst3_3d_asm_Np.20190629.nc4')
# Create a slice from 0 to 15 indices from the end of the array
p_slice = slice(0, -15)
# Use this slice on all the arrays to keep them in agreement
press = nc_file.lev[p_slice]
temp = nc_file.T[0, p_slice, 300, 400]
rel_hum = nc_file.RH[0, p_slice, 300, 400]
dewpoint = mpcalc.dewpoint_from_relative_humidity(temp, rel_hum)
Td0 = dewpoint[0]
profile = mpcalc.parcel_profile(press, temp[0], Td0)
sb_cape, sb_cin = mpcalc.surface_based_cape_cin(press, temp, dewpoint) |
Beta Was this translation helpful? Give feedback.
-
Thank you for this solution. I has some help to come to this same conclusion. |
Beta Was this translation helpful? Give feedback.
-
Hello
I am attempting to use the metpy cape_cin function but I cannot get past an error with the parcel_profile function. Here is the error below:
I set up the necessary variables and dataframe for the parcel_profile function as follows
Am I applying the units correctly or not setting up the function properly to get the above error?
Thanks
Jonathan
Beta Was this translation helpful? Give feedback.
All reactions