Hi, all. Could I request some help with this issue I've run into when calculating specific humidity? Thanks in advance from a humble oceanographer who is trying to work with atmospheric data (and learn python).
@Kyl67899 Your problem is this code:
p,t,td,prof_t = mpcalc.parcel_profile_with_lcl(p,T,Td)
You overwrite the original
p variable, which doesn't contain the LCL level, with a new array
p that contains the LCL. You then use this
p with the extra level together with your original
Td arrays, rather than the new ones that contain the interpolated values for the LCL, which you put in
td. Thus they contain different amounts of data and lead to the error message:
ValueError: x and y must have same first dimension, but have shapes (95,) and (96,)
Hi, I'm getting a strange behavior of the parcel_profile method when using in a skew-t plot. The thing is that it seems to be drawing a bigger area between the parcel path and the observed air temperature. I'm also getting different values of some indexes related of this profile (CAPE, CIN, LIFT, EQLV, and so on)compared with the Wyoming sounding calculation.
I'm calculating this path as follow:
parcel_path = mpcalc.parcel_profile(d['pressure'], d['temperature'], d['dewpoint']).
dewpointvalues you pass to
parcel_profile. In the code above, you are passing
d['dewpoint'], so you are telling it to use a surface profile. If you want a mixed parcel like Wyoming uses, look at the
Can anyone help me as to why when I calculate the mix layer I am getting an error on the height?
p = data['pressure'] T = data['temperature'] Td = data['dewpoint'] hei = data['height'] #https://stackoverflow.com/questions/65985185/cape-cin-returning-incorrect-values # Calculate the mixed parcel--need to pass pressure as an additional variable to "mix" so that we get # an appropriate "average pressure" to use as the mixed parcel parcel_temp, parcel_dewp, mixed_press = mpcalc.mixed_layer(data['pressure'], data['temperature'], data['dewpoint'], data['pressure'], height=data['height'], depth=500 * units.m) #also calculates the same thing parcel_temp, parcel_dewp, mixed_press = mpcalc.mixed_layer(p, T, Td, p, hei, depth=500 * units.m)
Traceback (most recent call last): File "/home/students/parsotak/wx367/Advanced_Sounding.py", line 168, in <module> height=data['height'], depth=500 * units.m) File "/wx/python/anaconda3/envs/metpy/lib/python3.7/site-packages/metpy/xarray.py", line 677, in wrapper return func(*args, **kwargs) File "/wx/python/anaconda3/envs/metpy/lib/python3.7/site-packages/metpy/units.py", line 305, in wrapper bound_args = sig.bind(*args, **kwargs) File "/wx/python/anaconda3/envs/metpy/lib/python3.7/inspect.py", line 3015, in bind return args._bind(args[1:], kwargs) File "/wx/python/anaconda3/envs/metpy/lib/python3.7/inspect.py", line 3006, in _bind arg=next(iter(kwargs)))) TypeError: got an unexpected keyword argument 'height'
relative_humidity_from_specific_humiditygiven arguments with incorrect units:
temperaturerequires "[temperature]" but given "dimensionless"
cross_section. I'm not quite sure if this is a bug in MetPy or a metadata issue.
cross_sectionissue? I can take a look if you point me to the source files and code. From what I can gather in the replies above, my guess is something weird with xarray's keep_attrs behavior (which MetPy's internals may or may not be correctly handling), but won't be able to tell for sure without digging into the actual data and code.
Hello. I'm trying to calculate the horizontal distribution of the depth of a MAUL (∂θe/∂z < 0). Thanks for the suggestion in stackexhange to try asking here.
I'm processing a WRFout file. First, I tried this
import numpy as np import xarray as xr from wrf import (getvar) eth = np.array(getvar(ncfile, "eth", timeidx=time)) z = np.array(getvar(ncfile, "z", timeidx=time, units="km")) deth = np.gradient(eth, axis=0) dz = np.gradient(z, axis=0) deth_dz = deth/dz dthdz = xr.DataArray(data=deth_dz, dims=['Height', 'Latitude', 'Longitude'])
But when I do
dthdz.sum(dim='Height'), I get very low depth values.
So I tried the suggestion of using
eth = getvar(ncfile, "eth", timeidx=time) pres = getvar(ncfile, "pressure", timeidx=time) dthdz = mpcalc.thickness_hydrostatic(pres, eth)
However, the results are in 1D so I'm not sure how to do the horizontal plot of the depth.
I would just like to know where I'm doing it wrong. Thank you!