- 积分
- 4919
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2016-6-29
- 最后登录
- 1970-1-1
|
发表于 2022-10-28 16:42:00
|
显示全部楼层
楼主及各位高人,求助问题。
我用网上的脚本画探空图。
........
p = df['pressure'].values * units.hPa # 单位:hPa
T = df['temperature'].values * units.degC # 单位:℃
Td = df['dewpoint'].values * units.degC # 单位:℃
wind_speed = df['speed'].values * units.knots # 单位:knot
wind_dir = df['direction'].values * units.degrees # 单位:°
u, v = mpcalc.wind_components(wind_speed, wind_dir) # 计算水平风速u和v
求u,v的时候出问题了。
提示:
TypeError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_746504/612715894.py in <module>
4 wind_speed = df['speed'].values * units.knots # 单位:knot
5 wind_dir = df['direction'].values * units.degrees # 单位:°
----> 6 u, v = mpcalc.wind_components(wind_speed, wind_dir) # 计算水平风速u和v
C:\Anaconda\anaconda3\lib\site-packages\metpy\xarray.py in wrapper(*args, **kwargs)
1228
1229 # Evaluate inner calculation
-> 1230 result = func(*bound_args.args, **bound_args.kwargs)
1231
1232 # Wrap output based on match and match_unit
C:\Anaconda\anaconda3\lib\site-packages\metpy\units.py in wrapper(*args, **kwargs)
286 def wrapper(*args, **kwargs):
287 _check_units_inner_helper(func, sig, defaults, dims, *args, **kwargs)
--> 288 return func(*args, **kwargs)
289
290 return wrapper
C:\Anaconda\anaconda3\lib\site-packages\metpy\calc\basic.py in wind_components(speed, wind_direction)
147
148 """
--> 149 wind_direction = _check_radians(wind_direction, max_radians=4 * np.pi)
150 u = -speed * np.sin(wind_direction)
151 v = -speed * np.cos(wind_direction)
C:\Anaconda\anaconda3\lib\site-packages\metpy\calc\basic.py in _check_radians(value, max_radians)
1269 """
1270 with contextlib.suppress(AttributeError):
-> 1271 value = value.to('radians').m
1272 if np.any(np.greater(np.abs(value), max_radians)):
1273 warnings.warn('Input over {} radians. '
C:\Anaconda\anaconda3\lib\site-packages\pint\quantity.py in to(self, other, *contexts, **ctx_kwargs)
722 other = to_units_container(other, self._REGISTRY)
723
--> 724 magnitude = self._convert_magnitude_not_inplace(other, *contexts, **ctx_kwargs)
725
726 return self.__class__(magnitude, other)
C:\Anaconda\anaconda3\lib\site-packages\pint\quantity.py in _convert_magnitude_not_inplace(self, other, *contexts, **ctx_kwargs)
671 return self._REGISTRY.convert(self._magnitude, self._units, other)
672
--> 673 return self._REGISTRY.convert(self._magnitude, self._units, other)
674
675 def _convert_magnitude(self, other, *contexts, **ctx_kwargs):
C:\Anaconda\anaconda3\lib\site-packages\pint\registry.py in convert(self, value, src, dst, inplace)
1001 return value
1002
-> 1003 return self._convert(value, src, dst, inplace)
1004
1005 def _convert(self, value, src, dst, inplace=False, check_dimensionality=True):
C:\Anaconda\anaconda3\lib\site-packages\pint\registry.py in _convert(self, value, src, dst, inplace)
1915 value, src = src._magnitude, src._units
1916
-> 1917 return super()._convert(value, src, dst, inplace)
1918
1919 def _get_compatible_units(self, input_units, group_or_system):
C:\Anaconda\anaconda3\lib\site-packages\pint\registry.py in _convert(self, value, src, dst, inplace)
1516
1517 if not (src_offset_unit or dst_offset_unit):
-> 1518 return super()._convert(value, src, dst, inplace)
1519
1520 src_dim = self._get_dimensionality(src)
C:\Anaconda\anaconda3\lib\site-packages\pint\registry.py in _convert(self, value, src, dst, inplace, check_dimensionality)
1050 value *= factor
1051 else:
-> 1052 value = value * factor
1053
1054 return value
TypeError: can't multiply sequence by non-int of type 'float'
|
|