- 积分
- 26283
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2012-6-1
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本人在网上看到有MATLAB计算水汽通量的程序,特别感兴趣。
目前论坛和网上做水汽分析大都用NCL和GrADS,而MATLAB则几乎很少,这对于用MATLAB的同学来说,可能不太方便。
由于对本人不是大气科学背景,因此,可能对以下程序理解上有误,特把程序贴在这里,让大家帮忙看看。
核心想解决的问题是:
1.计算水汽通量WVF
2.计算水汽通量散度Div-WVF
3.计算从东西南北不同方向的水汽输入输出
程序如下:
% http://blog.sina.com.cn/s/blog_4cfb5a620101cesh.html
% 资料:hgt.mon.mean.nc;uwnd.mon.mean.nc,vwnd.mon.mean.nc;shum.mon.mean.nc(比湿);
% 数据下载:http://www.esrl.noaa.gov/psd/dat ... lysis.pressure.html
%% -------------------------------------------------------------------------------------------------------------------------------
clc %清屏
clear %清内存变量
cd('D:\BaiduYunDownload');
filename='hgt.mon.mean.nc';
ncdisp(filename)
hgt1 = double(ncread('hgt.mon.mean.nc','hgt',[9 13 1 1],[65 37 8 793],[1 1 1 1]));
lon1 = double(ncread('hgt.mon.mean.nc','lon',9,64,1));
lat1 = double(ncread('hgt.mon.mean.nc','lat',13,37,1));
j=1;
for i=6:12:740
hgt(:,:,:,[j,j+1,j+2])=squeeze(hgt1(:,:,:,[i,i+1,i+2]));
j=j+1;
end
logc1=hgt<0;
hgt(logc1)=0.0;
sum11=62*3-sum(logc1);
sum1=sum(hgt);
[ii]=find(sum11==0);
sum11(ii)=1;
hgtm=squeeze(sum1./sum11);
clear file f hgt hgt1 logc1 sum11 sum1 ii
%% -------------------------------------------------------------------------------------------------------------------------------
filename1='uwnd.mon.mean.nc';
ncdisp(filename1)
uwnd1 = double(ncread('uwnd.mon.mean.nc','uwnd',[9 13 1 1],[65 37 8 793],[1 1 1 1]));
j=1;
for i=6:12:740
uwnd(:,:,:,[j,j+1,j+2])=squeeze(uwnd1(:,:,:,[i,i+1,i+2]));
j=j+1;
end
logc1=uwnd>200;
uwnd(logc1)=0.0;
sum11=62*3-sum(logc1);
sum1=sum(uwnd);
[ii]=find(sum11==0);
sum11(ii)=1;
uwm=squeeze(sum1./sum11);
clear file f uwnd uwnd1 logc1 sum11 sum1 ii j
%% -------------------------------------------------------------------------------------------------------------------------------
filename2='vwnd.mon.mean.nc';
ncdisp(filename2)
vwnd1 = double(ncread('vwnd.mon.mean.nc','vwnd',[9 13 1 1],[65 37 8 793],[1 1 1 1]));
j=1;
for i=6:12:740
vwnd(:,:,:,[j,j+1,j+2])=squeeze(vwnd1(:,:,:,[i,i+1,i+2]));
j=j+1;
end
logc1=vwnd>200;
vwnd(logc1)=0.0;
sum11=62*3-sum(logc1);
sum1=sum(vwnd);
[ii]=find(sum11==0);
sum11(ii)=1;
vwm=squeeze(sum1./sum11);
clear file f vwnd vwnd1 logc1 sum11 sum1 ii j
%% -------------------------------------------------------------------------------------------------------------------------------
filename3='shum.mon.mean.nc';
ncdisp(filename3)
shum1 = double(ncread('shum.mon.mean.nc','shum',[9 13 1 1],[65 37 8 793],[1 1 1 1]));
j=1;
for i=6:12:740
shum(:,:,:,[j,j+1,j+2])=squeeze(shum1(:,:,:,[i,i+1,i+2]));
j=j+1;
end
logc1=shum>2000;
shum(logc1)=0.0;
sum11=62*3-sum(logc1);
sum1=sum(shum);
[ii]=find(sum11==0);
sum11(ii)=1;
shm=squeeze(sum1./sum11);
clear file f shum shum1 logc1 sum11 sum1 ii j
%% -------------------------------------------------------------------------------------------------------------------------------
g = 9.8;
qu = squeeze(sum((hgtm(:,1:7,:)-hgtm(:,2:8,:)).*(uwm(:,1:7,:)+uwm(:,2:8,:)).*(shm(:,1:7,:)+shm(:,2:8,:))/4,2));
qv = squeeze(sum((hgtm(:,1:7,:)-hgtm(:,2:8,:)).*(vwm(:,1:7,:)+vwm(:,2:8,:)).*(shm(:,1:7,:)+shm(:,2:8,:))/4,2));
qu=qu/g;
qv=qv/g;
zz=sqrt(qu.*qu + qv.*qv);
[x,y] = meshgrid(lon1,lat1);
load coast
lonlim=[70 160];
latlim=[10 60];
[Lat,Lon]=meshgrid(lat1(1:1:end),lon1(1:1:end));
%% Figure
figure('Color', 'w')
axesm('MapProjection', 'Eqdcylin', 'MapLatLimit', latlim, 'MapLonLimit', lonlim);
framem on; gridm on; plabel on; mlabel('South')
setm(gca, 'MLineLocation', 10, 'PLineLocation', 10)
setm(gca, 'MLabelLocation', 10, 'PLabelLocation', 10)
setm(gca, 'fontsize', 20, 'fontname','times new roman')
tightmap; axis off; hold on
linem(lat, long, 'Color', 'k', 'LineWidth', 1.5)
% quiver
Handle=quiverm(Lat, Lon, -qv',-qu', 1.0); % <--------------------------- size: 2.0
set(Handle, 'Color', 'b', 'LineWidth', 1.0);
% hold on;
% [cs,hh]=contourfm(Lat, Lon, zz',0:100:max(zz),'linestyle','none');
% % contourcmap('jet', 'Colorbar', 'on', 'Location', 'vertical', 'TitleString', 'Contour Intervals in 100','fontsize', 20);
% colormap(jet(20));
% caxis([0 1350]);
% colorbar('location','eastoutside','fontsize', 20);
%% quiver label
labelx=[72 73];
labely=[12.5 13]; % location of label % <------- Use the actual grid distance of the data
labelu=[500 0];
labelv=[0 0]; % set 25m/s as a standard
scale_auto=Get_Autoscale(Lon, Lat, -qv',-qu');
scale_label=Get_Autoscale(labelx, labely, labelu, labelv);
scale_factor=scale_auto/scale_label;
Handle=quiverm(labely, labelx, labelv, labelu, 2.0*scale_factor); % <----- size: 2.0*scale_factor
set(Handle, 'Color', 'r', 'LineWidth', 1.5)
textm(labely(1)+1.5, labelx(2), [num2str(labelu(1)) ' m/s'],...
'FontWeight', 'bold', 'Color', 'r', 'FontName', 'times new roman', 'FontSize', 20)
title('\fontsize{14}Water Vapor Flux', 'FontWeight', 'bold', 'FontName', 'Helvetica')
print(gcf,'-r300','-djpeg','NCEP_Water Vapor Flux');
来自群组: 北京师范大学地学-气象 |
|