我有一些风速和方向数据,我需要绘制成python。我从数据文件中获取数据并进行了一些计算以获得风速和数据,这就是我得到的:
wind_speed = np.sqrt(u**2+ v**2)
wind_speed
wind_dir_trig_to = (np.arctan2((u/wind_speed), (v/wind_speed)))
wind_dir_trig_to_degrees = (wind_dir_trig_to * (180/np.pi))
wind_dir_trig_from_degrees = wind_dir_trig_to_degrees + 180
wind_dir_trig_from_degrees
wind_dir_cardinal = 90 - wind_dir_trig_from_degrees
wind_dir_cardinal
这是上面显示的代码的输出:
array([[ 25.05589294, 26.44908142, 25.87358856, ..., 26.09784698,
24.73834229, 23.79068756],
[ 25.00778198, 26.04024506, 25.52288055, ..., 24.56259918,
22.53238678, 21.8249054 ],
[ 23.54372406, 23.90814972, 24.1379776 , ..., 24.2286377 ,
22.26264191, 21.62586975],
...,
[ 26.37328339, 27.58541107, 27.02276611, ..., 22.10659027,
22.27283478, 23.06639862],
[ 26.5234375 , 26.64894867, 25.70041656, ..., 24.78749084,
24.94545746, 25.05831909],
[ 25.57256317, 24.58295441, 23.94006348, ..., 27.29759979,
27.22042084, 26.55405426]], dtype=float32)
如何使用此数据在python中将风速和方向绘制到同一个pcolormesh图中?
答案 0 :(得分:2)
怎么样:
import matplotlib.pyplot as pl
pl.pcolormesh(wind_dir_cardinal)