|
第13期,和大家讨论一下风玫瑰图的绘制。 风玫瑰图(Wind Rose)是气象学中描述风速和风向发生频率的图。由于风是矢量,常用的统计量如平均值、中值等可能错误地描述风速和风向在一段时间内的特征,比如反向风可能相互抵消,东北风(45°)和西北风(315°)的平均值为南风(180°)等。使用风玫瑰图,用概率来描述各风向、风速区间风的出现频率,可以避免这些问题,从而更准确地描述风在一段时间内的特征。 支持绘制风玫瑰图的工具有很多。NCL中提供WindRoseBasic等命令来实现;python的windrose库也可以绘制不同风格的风玫瑰图;R语言的windRose命令也可以提供类似操作。我最习惯使用的是MATLAB的WindRose工具箱,以下对其进行具体介绍。 WindRose工具箱由Daniel Pereira编写,至该推文撰写日,最后一次更新是在2020年3月5日,其最新代码和说明文件可从以下link下载: https://dpereira.asempyme.com/windrose/ 该工具箱的使用方法比较简单,只有WindRose一句主命令。具体语法为:
2 _- f/ g" c" n, }0 y: g, e- . K: P" M, Z/ e' k+ I5 w" w
" S% |; S) l2 N, `/ b) s2 m
[figure_handle,count,speeds,directions,Table] = WindRose(dir,spd,Options);
) {+ E7 B+ e: E: Z, \8 j 4 f- n, t8 W) v: c* z+ P
该命令中,输入量有三个:dir为风向时间序列(0-360,气象标准,0代表风从北方吹来,度数顺时针增大);spd为风速时间序列;Options为与图相关的各项设置,变量类型为Cell。Options内包含的设置选项非常多,比如风速、风向区间,colormap,文本及坐标标记,中心零风速设置,多图摆放等等。具体内容参考工具箱说明文件。 输出量有五个,使用场景不多,主要用于数据检查。figure_handle为图句柄,之前figure的所有设置参数都会保存在这里;count为矩阵,保存不同风向、风速区间风的出现频率;speeds为向量,保存风速区间分段的临界值;Table则以表格形式,具体记录的风玫瑰图中各个数值,适合检查错误。 以美国东海岸Nantucket Sound的风场观测为例。从美国NDBC的网站可以下载到该海域浮标44020在2010至2019年间的十年风场观测资料,在进行简单处理后,我们可以使用以下命令对2010-2019十年间44020站风场数据绘制风玫瑰图。由图我们可以直观的看到,该区域风速主要在4-12m/s,西南风居多。 % z* u- R, X$ p4 n* E
9 O6 c( [% f, E7 G7 V% f2 a
- z! R+ e, L F
" g1 i- L( _ T0 A- N
+ _, y- }5 p! g- ( z& V# C' R8 w3 C3 O2 ^
$ z7 H% e4 Z/ M( m4 }! N% K% Z- 7 o2 K2 I# ?' k) C% G. I8 H G1 t
- & a$ x9 X! X- m9 P, X- `9 O4 {
7 O2 u7 s) ], f- 8 _% p# ^3 h$ Y/ s! }4 `3 w
$ ]: S# L2 z( ~* u9 c
( y8 l& ~) @' D+ T6 e
Options = {'anglenorth',0,... 'angleeast',90,... 'labels',{'N (0^o)','NE (45^o)','E (90^o)','SE (135^o)','S (180^o)','SW (225^o)','W (270^o)','NW (315^o)'},... 'freqlabelangle','auto',... 'MaxFrequency',6,... 'nFreq',6,... 'vWinds',[0 4 8 12 16],... 'LabLegend','Wind Speed (m/s)',... 'legendtype',2,... 'titlestring',''};[figure_handle,count,speeds,directions,Table] = WindRose(dir,spd,Options);
1 f9 _; m7 {$ G6 V$ a; K' F& e6 h ) @) m# ^; ~# [* B' M; H) u) q. T
Q! b' G4 p+ ~0 p# U另外,该工具箱还很好地整合了MATLAB中subplot命令,进而在一张图中画多张子图。比如,对10年的风场数据按照季节分开,使用以下命令,可以绘制该海域不同季节的风场特点。可以看到,该海域夏季多西南风;冬季多西北风,且风速较大。
% t; ^/ w+ t. P1 k* U- : [+ c, y9 T% M) o
* O$ T4 |" c6 f& V1 F# K/ N- 6 z, t0 M r- f* R% G7 ~
- , c2 |" H8 u, `& l! z4 A8 `2 b
0 b* N+ ~0 S) }, r0 `. v
4 F* f' O* N! [* y Q
5 O4 B6 R2 z( q/ e( j- x
$ K1 O0 P( q; x% r
+ P' _0 @. ?& u) q
3 Z8 d" h$ |4 f; ~, I L- 3 f. W" Z5 P3 F. n
- : L, D, A6 l% S# p! w& P) C1 ]
( `2 j ?( a7 g" I. C0 i/ n
" q7 v9 O. e3 b7 }& d r' S. ^
& d; u0 y7 j$ K: R. g
figure('color','w')Options = {'anglenorth',0,... 'angleeast',90,... 'labels',{'','E','S','W'},... 'freqlabelangle','auto',... 'min_radius',0.25,... 'vWinds',[0 4 8 12 16],... 'MaxFrequency',8,... 'nFreq',4,... 'LabLegend','Wind Speed (m/s)',... };[figure_handle,count,speeds,directions,Table] = WindRose(dir_spring,spd_spring,[Options,{'titlestring','Spring'},{'legendtype',2},{'axes',subplot(2,2,1)}]);[figure_handle,count,speeds,directions,Table] = WindRose(dir_summer,spd_summer,[Options,{'titlestring','Summer'},{'legendtype',0},{'axes',subplot(2,2,2)}]);[figure_handle,count,speeds,directions,Table] = WindRose(dir_autumn,spd_autumn,[Options,{'titlestring','Autumn'},{'legendtype',0},{'axes',subplot(2,2,3)}]);[figure_handle,count,speeds,directions,Table] = WindRose(dir_winter,spd_winter,[Options,{'titlestring','Winter'},{'legendtype',0},{'axes',subplot(2,2,4)}]);
6 I4 t! M7 P6 a/ J $ _' e. \8 n% z4 ]% o
Tip: 在画多图时,最好在画图前先使用
: J. Z) a5 b) V( E( K' ]- ! Z' W. Y& m) `; |3 ?
# n" {9 w8 L6 N! L: D
figure('color','w')
6 E" Z+ l# y$ k. f ~1 u8 X # Q) e" _2 c7 Z7 N! h7 b V
否则,第一张分图和legend部分可能会变成MATLAB默认画图底色(一般为灰色)。Options中有figcolor选项来更改图底色,然而我测试时依然有上述bug。如果你也遇到相同问题,不妨尝试该方法。 Reference: 浮标数据: https://www.ndbc.noaa.gov/station_history.php?station=44020 各语言中风玫瑰图的相关命令介绍: https://www.ncl.ucar.edu/Applications/rose.shtml https://pypi.org/project/windrose/ https://www.rdocumentation.org/packages/openair/versions/2.7-2/topics/windRose https://dpereira.asempyme.com/windrose/ - V4 g- a4 g, A& n0 d
|