All, The MetPy get_layer function returns only the first 3 pressure values from the following pressure array (is that is correct?)
import numpy as np
from metpy.calc import get_layer
plev = np.array(( 1000.,950.,900.,850.,800.,750.,700.,650.,600.,
550.,500.,450.,400.,350.,300.,250.,200.,
175.,150.,125.,100., 80., 70., 60., 50.,
40., 30., 25., 20.,10. ))*100 # Pascall
pre = plev*units.Pa
print(get_layer(pre))
[<Quantity([100000. 95000. 90000.], 'pascal')>]
I just found that when I use this function "mean_pressure_weighted(pre,tem)" which seems, after comparison with "print(np.trapz(tem[:3]*pre[:3],x=pre[:3])/np.trapz(pre[:3],x=pre[:3]))", to use the first three values only.
tem is defined as
t =np.array((29.3,28.1,23.5,20.9,18.4,15.9,13.1,10.1, 6.7, 3.1, \
-0.5,-4.5,-9.0,-14.8,-21.5,-29.7,-40.0,-52.4, \
-59.2,-66.5,-74.1,-78.5,-76.0,-71.6,-66.7,-61.3, \
-56.3,-51.7,-50.7,-47.5 ))
tkel = t+273.15
tem = tkel*units.degK
I am not sure exactly how get_layer work, yet I think that mean_pressure_weight would not work probably with the current output of the get_layer. Thanks
get_layer()
returns a layer out of an array, given the bottom and depth of the layer (optionally working with either pressures or heights). When depth is not passed in, it defaults to a depth of 100 hPa. When bottom is not specified, it defaults to the maximum pressure it was given.
So in your case, with those defaults, it's going to give the levels in the lowest 100 hPa, which would be 1000, 950, and 900, as shown in your example above.