- 积分
- 26283
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2012-6-1
- 最后登录
- 1970-1-1
|
发表于 2014-3-13 11:12:44
|
显示全部楼层
木市街8号 发表于 2014-3-13 10:27
能否发个例子给我分享下,谢谢了
clc,clear; %清屏,清空
ncid = netcdf.open('D:\precip.mon.1981-2010.ltm.nc','NOWRITE'); %打开nc文件
ncdisp('precip.mon.1981-2010.ltm.nc'); %在命令窗中显示nc文件的变量
% [ndims,nvars,ngatts,unlimdimid]=netcdf.inq(ncid)
PrecipData = ncread('precip.mon.1981-2010.ltm.nc','precip'); %读入变量precip
TimeData = ncread('precip.mon.1981-2010.ltm.nc','time'); %读入变量time
LonData = ncread('precip.mon.1981-2010.ltm.nc','lon'); %读入变量lon
LatData = ncread('precip.mon.1981-2010.ltm.nc','lat'); %读入变量lat
Valid_yr_countData = ncread('precip.mon.1981-2010.ltm.nc','valid_yr_count'); %读入变量validprecip_yr_count
ClimatologyData = ncread('precip.mon.1981-2010.ltm.nc','climatology_bounds'); %读入变量climatology_bounds
[X, Y] = meshgrid(LatData,LonData);
contourf(Y-180.0,X,PrecipData(:,:,9)); %画9月份等值面图
shading flat; %去掉等值线
colorbar('SouthOutside','Position',[0.142,0.03,0.75,0.04]); %添加颜色条 [左右,上下,长,宽]
load coast %加载全球海岸线,但是不显示出来
geoshow(lat,long,'DisplayType','line','Color','White'); %显示出海岸线,lat和long是coast的属性
hold on;
set(gca,'LineWidth',1,'FontSize',10,'Ylim',[-90,90],'Xlim',[-180,180],'Position',[0.142,0.105,0.75,0.84]...
,'XTick',[-180:60:180],'XTicklabel',{'-180W','-120W','-60W','0','60E','120E','180E'},'XGrid','on'...
,'YTick',[-90:30:90],'YTicklabel',{'-90S','-60S','-30S','0','30N','60N','90N'}, 'YGrid','on'); %添加经纬度信息
xlabel({'经度'}); %添加x轴名称
ylabel({'纬度'}); %添加y轴名称
title(['\fontsize{16}precip.mon.1981-2010.ltm']); %添加地图题目
annotation('textbox',[0.838711566617862,0.045,0.0431918008784773,0.0579710144927536],'String',{'Unit(mm/d)'},'EdgeColor','none'); %添加文本框
hold off; |
|