|
|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
6 u% l. I3 f8 Y3 L6 P
一、matlab读取NCEP再分析数据并绘制风场' q4 U: ]: U9 w: j% `( _
1 m! e$ H3 p# q1 K4 n
%该程序用于求水汽通量散度/ A6 t2 o1 {& X x0 f# i9 E/ W
%注意!我们这里读到的u是四维矩阵,分别是lon*lat*level*time,
9 }! j0 `- e' m9 M' q( B! [clc;clear;close all
" f/ e9 k/ ~( s0 X; af_hgt = 'ps_level_20170121_0130.nc';: _$ K& r3 J. e, \
% ncdisp(f_hgt);! Z$ Q- V7 U: T+ j1 t
time=ncread(f_hgt,'time');0 c$ j5 g, i: g
level=ncread(f_hgt,'level');
. G- j$ b" v( ]5 d! h) |lon=ncread(f_hgt,'longitude');
& K% d9 B4 b; X8 g5 t2 a' \# ]lat=ncread(f_hgt,'latitude');1 U( K- r+ m1 v7 W
%%%%%%时间转换$ e& ^0 h3 }6 Z* C7 K2 B j4 I
time = double(time);
' Y/ W6 y% l) t! K/ e3 Nformat = 'mm dd, yyyy HH:MM:SS.FFF AM';%转换格式' b1 r# ?! G/ D }8 K% X: V2 R% N
dstr = datestr((datenum('1900-01-01') + time./24),format);%转换后时间字符串存储3 |% @5 G4 R6 `2 k
TM = datevec(dstr);%将时间字符数组转化为数值数组" p3 x- U& t$ N2 J. x8 b% v
tidx=find(TM(:,2)==1 & TM(:,3)==28 & TM(:,4)==00);%筛选7月25日08时(世界时加8)7 W7 n, I }0 ]2 N" y
ps_lev=find(level ==850);%%删选出850hPa高度" u* R$ L5 P& y0 U6 M0 s
start=[1,1,ps_lev,tidx];%所指定变量的每一维的开始读取的位置
6 N/ z3 J9 r/ F% H' B$ Kcount=[41,31,1,1];%从start指定的开始位置算起,一共读取的每一维要素的数目: O6 R3 N+ ?1 [' d# {
strip=[1,1,1,1];%从start开始,每一维读取的数目为count时,每一维的读取的步长2 T: h! j3 f. }5 K* n7 `1 ?
hgt=ncread(f_hgt,'z',start,count,strip);%读取温度值,单位K4 V; v) _5 n- M: V# S
u=ncread(f_hgt,'u',start,count,strip);%读取温度值,单位K
9 y; @" k3 _! z% x, Iv=ncread(f_hgt,'v',start,count,strip);%读取温度值,单位K
8 R! a P5 g8 z; K. O# `* a7 L2 d[X,Y]=meshgrid(lon,lat);
( J2 W0 E8 s: Y6 P6 P' nfigure(1)- U' d, p+ |4 C# a
m_proj('Mercator','lat',[25,35],'lon',[100,115]);3 N2 q) ~( J3 P
% m_grid('linestyle','none','tickdir','out','fontsize',12,'fontname','Times New Roman');
' P E9 L" ^& l& F& w) y* Q c/ K1 Dm_grid('linestyle','none','box','fancy','fontsize',11,'tickdir','in','xtick',[100:3:115],'ytick',[25:2:35]);0 D/ x/ e1 B3 B. w0 f; Z
hold on
2 j7 O8 A% o. F1 i' rm_windbarb(X',Y',u,v,'color','k')
3 x) p: } O2 @* s: |%m_coast('patch',[.9 .9 .9],'edgecolor','none');
% R3 i6 i/ @. P/ |' h1 C[C,h]=m_contour(X',Y',hgt/10 ,'color','k','LineWidth',1);%[5000:80:5900]%[1520:25:1680]5 C% E$ U# L0 y" i8 d
%set(b,'ShowText','on','TextStep',get(b,'LevelStep'),'fontsize',12,'fontname','Times New Roman'); %在等高线上叠加数值(文后详情)- V& j* M1 S1 \, K, y9 z" F
clabel(C,h,'FontSize',13,'fontname','Times New Roman');
7 \3 I# t& o6 ~* c7 X6 y; rma=shaperead('F:/RMeteoInfo/data/map/bou2_4l.shp');
% H4 ?! x/ s) c, r7 ]4 J% m_line( [ma(:).X], [ma(:).Y],'color',[0.5,0.5,0.5]);%绘制范围内的地图
2 @& r6 Q( f. r! m; [m_line([ma(:).X],[ma(:).Y],'color','r');%绘制范围内的地图; [% J# L+ l% Z$ [' {- d) S
m_plot(105.5,29.43,'marker','^','MarkerSize',7,'color','k','MarkeRFaceColor','k')
0 @. K- |+ P: W# m' a2 X, G
L" v1 V" y2 z1 x
# \( H. `$ Z3 l b
7 U% A7 u( l3 V6 T3 b7 N6 U$ A( r$ Z! C/ s8 j/ B
二、matlab读取ERA5并绘制全球风场图6 H5 g9 `1 i# D3 L% E3 B' K: B
# ^7 S" P6 H+ a# sclc;clear;close all
" [8 U' H; @3 c6 Ou0=ncread('202008muwind.nc','uas'); %读取其中一项
+ T9 K- d2 |. b# ^; G- f' K9 T' o5 e: O0 Rv0=ncread('202008mvwind.nc','vas');0 e$ ?5 \9 a; [5 q2 S! A
time0=ncread('202008muwind.nc','time');
8 l1 f ^0 k" ]; T& V. Olat0=ncread('202008muwind.nc','lat');
! q# X4 Q# p5 D8 ]" dlon0=ncread('202008muwind.nc','lon');
* N6 x9 N* w( u w0 ]$ X[lat,lon]=meshgrid(lat0,lon0);
/ c; Y# }7 e4 ]0 ^2 ~/ q9 Mu=u0(:,:,2);
3 S$ ?% \ S2 Y1 l+ k3 @) Ev=v0(:,:,2);( K0 ? a4 ^- V! n& X% D' Z
b=sqrt(u.^2+v.^2);" e! i1 h, s+ [- t4 W4 a
figure(1);
) X1 j" ?6 B5 T1 U. ]m_proj('Equidistant Cylindrical','long',[-180 180],'lat',[-90 90]);%矩形投影;取区域观察3 o, @2 w5 b) ^! ]+ h' n6 _# D5 |/ g
[lon1,lat1]=meshgrid([-180:2.5:179.75],[-90:2.5:90]);; q2 L I) ?; U @! a8 N
u2=u(1:10:end,1:10:end)';/ W" P0 X/ U4 Y' R* Y$ E
% u3=[u2,u2(:,end)];& v6 u7 E. _# m6 b; @$ F: Z
v2=v(1:gap:end,1:gap:end)';0 U. k+ G. Q8 m6 n" Y! A
% v3=[v2,v2(:,end)];
6 r: K Z. v Lm_quiver(lon1,lat1,u2,v2,0);) V4 V" R9 f/ B' C- w9 i& p9 M3 N
hold off
! b3 i$ z% f4 U- ?m_coast('patch',[1 .85 .7]);2 Z& V z6 G5 q6 b
m_grid('box','on','tickdir','out');% @% q/ h I8 M B9 _% n x9 i. Q4 H
1 i2 ]* l5 j: n8 z, ~9 X
# ?: }* m$ J: B* {
: V5 e" C1 L! L; O& Z* ~9 j4 ]" [' s% |& q* ` N2 M6 ?
, Z1 z) w, a1 Gm_contourf(lon,lat,b);%在mmap基础上的画
" e) \$ N3 C% d/ A4 {shading interp;%使数据插值4 Z3 E: ^7 d: f& `1 v! W$ V" Z
hold on;
$ @' @9 ?8 Z0 F% n/ Cm_quiver(lon1,lat1,u2,v2,0);
! w+ n o3 W( G% H+ G( T. C' B4 Uhold off;+ d" J9 t N- ?1 s7 [
4 T: W8 l6 O7 C
2 ]2 P$ c( j1 M8 e
9 b& t' M, v5 s2 A6 ^
& X2 y! s2 }) F* e3 O( \
0 G+ @1 T# `6 n6 c3 u
m_quiver(lon1,lat1,u2,v2,0);
( r- _4 [, e" u( X- j. j$ V' h* [3 s% \4 \9 l
$ y" h; o" D$ F4 ]0 x X6 b
$ J( ` l$ f4 I' `2 y& r2 b. P2 y+ r' @% P/ v% r2 h
$ e s0 @% Z1 l/ c2 J6 D
m_contourf(lon,lat,b,500,'linestyle','none') %在mmap基础上的画5 |/ |& e; ^( p$ E b$ f
shading interp; %使数据插值
1 w* o% ?( e; a/ t9 y/ O$ R
& N R' s" i; E9 F1 C( a* o& V5 d, D
" \( i4 G: W7 K. T& ?. c" Y
4 A& Y% B* Y+ T# u# w5 Z& b
|
|