第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一句主命令。具体语法为: ; z- y% [- @* B( \6 m
4 r9 e0 k" m1 _5 D% v4 {
* N0 \# J6 Z" Y O
[figure_handle,count,speeds,directions,Table] = WindRose(dir,spd,Options);' T* M) L! o+ P0 c. V
% q6 Y7 V4 s- J- Z! _: o
该命令中,输入量有三个: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,西南风居多。
& A; |3 i( b/ @& u+ i, P! N
, l6 X% o2 m9 ~3 r# O- * {' r1 k& M- ^* _
7 i: U o: F! \& \! S
( c' S7 x. [# k
9 n1 f8 M: S4 |) j; l
+ g* i; ]8 Y1 O2 ~6 y; A- : f( [/ |+ n" R; W d, }
- 8 E6 f5 A& ?5 w' `6 p! D
* B2 J: e6 L6 s E1 O- * E* m# s8 Q5 ^+ I! p& o* p
; V2 T2 s# o# L$ n9 V+ Y$ f# O0 ~9 o* u6 o4 X: ]
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);) D/ f3 h# ~9 t4 f0 w _5 r
/ N/ K$ Y* L9 s. {
6 o# N( z1 a6 z' B2 b另外,该工具箱还很好地整合了MATLAB中subplot命令,进而在一张图中画多张子图。比如,对10年的风场数据按照季节分开,使用以下命令,可以绘制该海域不同季节的风场特点。可以看到,该海域夏季多西南风;冬季多西北风,且风速较大。 - & o/ T* ~1 B# K# r
- $ H( D3 c8 J8 K( I# P
- $ k1 G) i( S3 Q, J# `; S2 o# t
2 g6 f2 p! D q4 i6 v# A5 q- ' B. h# L8 e# l7 s5 ~# N
- : v* ^; ?: V( W1 \: x# ?1 I
! \1 n) a% S3 y
9 }0 ]% W$ a) x4 Y J+ t: Y8 s- 5 m/ o3 a: Z4 n* m f/ K! K
7 m% C0 \ M( @0 `* {2 e9 y- 3 x2 y b8 Q; D8 j0 W# d
: q5 N/ q( ?) f) |; T/ ?6 z
& ]% g' N/ E% y' j8 A0 }8 n' F- ; b2 t4 V' x/ e2 [+ ^) z b
! u+ P9 @0 M% V7 D E F# Z5 s8 h/ F4 o3 l+ L
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)}]);( |- y% F2 i6 q6 p7 |! e$ B
8 V L" M I; |/ ~3 |) G6 N" m
Tip: 在画多图时,最好在画图前先使用
3 R1 Q/ ^) f" p3 I: a. X- , x- c5 c( h; K7 U& _
1 _ n# M7 Q* F, r; {9 w
figure('color','w')
3 N) c! G7 G, o5 d, Q' c- E$ m# `
/ e% k! n+ }8 Z9 [4 ?" R否则,第一张分图和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/
1 Q: ~$ ^$ N% ]& S |