用matlab画风场
重点1:
m_quiver(x(1:d:end,1:d:end),y(1:d:end,1:d:end),ustr_1_2(1:d:end,1:d:end)'./dd,vstr_2_1(1:d:end,1:d:end)'./dd,0);
m_quiver(30,-80,500./dd.*cosd(-80),0,0)
为了使得风场和标尺的大小一致,在m_quiver中最后一个值设置为“0”,即令scale=0
quiver(x,y,u,v,scale);
重点2:
d = 3;dd =10;
m_quiver(x(1:d:end,1:d:end),y(1:d:end,1:d:end),ustr_1_2(1:d:end,1:d:end)'./dd,vstr_2_1(1:d:end,1:d:end)'./dd,0);
通过d来调整箭头间距,dd来调整箭头长度(数值大小)
重点3:
ustr_1_2=ustr_1_1.*cosd(y');
h=m_quiver(30,-80,500./dd.*cosd(-80),0,0);
m_map 中用的是球坐标系,所以要在所有的纬向量上面乘以cosd(纬度) 注意:是cosd(纬度) cos(弧度)
其中纬度是每个纬向量所对应的纬度
在ustr_1_2=ustr_1_1.*cosd(y');里面,乘以cosd(y')要仔细检查,可以一步一步对应着去找。
%*********************************************************************
clear all;close all;clc
% 利用NCEP_Real-time_Marine_Data的风应力数据
%(http://www.esrl.noaa.gov/psd/data/gridded/data.nmc.marine.html)
% 绘制全球风场分布
%地形
m_proj('miller','lat',[-90,90],'lon',[0,360]);
m_coast('patch',[.6 .6 .6],'edgecolor','none');
m_grid('box','fancy','linestyle','none');
hold on
%NCEP mean风场数据
datapath_1='E:dataNCEPNCEP_Real-time_Marine_DataU-wind_Stressustr.mean.nc';
ncdata_1=netcdf.open(datapath_1,'NC_NOWRITE');
lat_1=netcdf.getVar(ncdata_1,0);
lon_1=netcdf.getVar(ncdata_1,1);
time_1=netcdf.getVar(ncdata_1,2);
ustr_1=netcdf.getVar(ncdata_1,3);
ustr_1_1=ustr_1(:,:,200);
datapath_2='E:dataNCEPNCEP_Real-time_Marine_DataV-wind_Stressvstr.mean.nc';
ncdata_2=netcdf.open(datapath_2,'NC_NOWRITE');
lat_2=netcdf.getVar(ncdata_2,0);
lon_2=netcdf.getVar(ncdata_2,1);
time_2=netcdf.getVar(ncdata_2,2);
vstr_2=netcdf.getVar(ncdata_2,3);
vstr_2_1=vstr_2(:,:,200);
[x,y]=meshgrid(lon_1,lat_1);
ustr_1_1(ustr_1_1<-1e+6)=nan;
ustr_1_2=ustr_1_1.*cosd(y');
vstr_2_1(vstr_2_1<-1e+6)=nan;
d = 3;dd =10;
m_quiver(x(1:d:end,1:d:end),y(1:d:end,1:d:end),ustr_1_2(1:d:end,1:d:end)'./dd,vstr_2_1(1:d:end,1:d:end)'./dd,0);
hold on
h=m_quiver(30,-80,500./dd.*cosd(-80),0,0);
set(h,'color','r','linewidth',1);
hold on
m_text(30,-75,'50m^2/s^2','fontsize',12);
print(gcf,'-djpeg','-r300','E:quiver_ncep');
%*********************************************************************
修改
% quiver问题:在不同的图中,令箭头大小一致。于是做了以下的实验:
%*********************************************************************
%% quiver test
%%
clear;clc;close all
figure
axes('position',[0.2,0.7,0.4,0.2]);
quiver(0,0,10,0,0); hold on
quiver(0,-0.5,20,0,0);
set(gca,'xlim',[0,25],'ylim',[-1.5 1.5])
axes('position',[0.2,0.4,0.4,0.2]);
quiver(0,0,20,0,0);
set(gca,'xlim',[0,25],'ylim',[-1.5 1.5])
axes('position',[0.2,0.1,0.6,0.2]);
quiver(0,0,20,0,0);
set(gca,'xlim',[0,25],'ylim',[-1.5 1.5])
print(gcf,'-djpeg','-r300','E:quiver_test');
%*********************************************************************
结论:quiver命令中,令scale为0时,在不同图中的箭头长短与坐标轴的长度有关。第1个图和第2个图可以反映箭头的长度系统。而第3个图是第2个图的拉长版。