|
第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一句主命令。具体语法为: 6 Q' v" r a0 F, w6 t5 X
* i) i7 E$ v. t4 `) d8 s5 o/ G) g) q4 ~& Q
[figure_handle,count,speeds,directions,Table] = WindRose(dir,spd,Options);. F7 q* c9 i& y* v; x, H! \* h
0 v+ n) F8 M! z6 a% v4 R+ Q
该命令中,输入量有三个: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,西南风居多。 " g0 o( a% T& |/ g: m6 F
- 9 U3 R5 X& |0 E( X/ ~3 H
' y" j$ t% B& Y" }3 }7 t. J, f) Q5 T- - \: s2 {' U8 `: U
2 j" J( o" L8 V; G4 }8 Y
1 @. [! q5 C7 O- 3 z8 t6 ]% M3 m- O$ z/ P
) w* [- ]" m4 p$ V5 p; k- ' @5 t2 u% @, Q, O6 |
- & ~7 S: O; H7 t. A8 c4 P6 k0 H. W
- ! b5 e8 p9 f# @
/ ]& I; g6 c6 a8 ~. t1 ` l/ M
- N+ e5 W9 Z% A% X+ u u
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);$ b9 S$ M/ o) G; L, f+ U
0 }# o5 N" L$ k& Y3 \. W
- B9 }& u! w( B4 O4 R
另外,该工具箱还很好地整合了MATLAB中subplot命令,进而在一张图中画多张子图。比如,对10年的风场数据按照季节分开,使用以下命令,可以绘制该海域不同季节的风场特点。可以看到,该海域夏季多西南风;冬季多西北风,且风速较大。
/ A- q9 u0 V5 S" J& Q8 L
7 U1 m: e8 y% N! `4 z% [. Q4 j- 1 a( o6 j; [" T- g
- ( T" \ C1 V W
- / [" M" F" [$ U9 Q1 e) p! k* U
- # W) T4 ~6 M3 j
- 2 e" o5 R Y+ e/ s k `
6 f' `. b( a7 m; m* Q6 w- 0 k2 ^5 ^2 ^) ^! H& [, |3 \
6 q; p7 b$ v! a i/ E! ]; ]% P$ Q; p
) {( X0 J: S0 Y$ D$ i+ k* [
+ m9 H3 ]8 {1 r. r
D, b0 H" X. }0 P! T- Y1 G# V: a+ ^
9 C$ E6 B: J+ s1 @ M- " i9 n! ?- g" `! k& J8 M4 u
- \! C: a7 ]5 r$ |# [- P
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 h% w x' p& H9 u
8 L; i7 J/ f2 v- i
Tip: 在画多图时,最好在画图前先使用
+ C/ r3 c! [3 G/ Q
+ w3 h* Q3 u3 f( F# L, N5 {: t) w" C, M) M6 u% \ m0 b
figure('color','w')
/ ?8 h4 n/ L4 d% k" F' C3 q) n , z: Y! x, }7 p: H$ X" G
否则,第一张分图和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/ ' }* k6 e. N. \
|