【matlab程序】matlab利用工具包nctool读取grib2、nc、opendaf、hdf5、hdf4等格式数据

【matlab程序】matlab利用工具包nctool读取grib2、nc、opendaf、hdf5、hdf4等格式数据
引用:
B. Schlining, R. Signell, A. Crosby, nctoolbox (2009), Github repository, https://github.com/nctoolbox/nctoolbox

Brief summary:
nctoolbox is a Matlab toolbox that provides read-only access to common data model datasets. Under the hood, nctoolbox uses NetCDF-Java as the data access layer. This allows nctoolbox to access NetCDF, OPeNDAP, HDF5, GRIB, GRIB2, HDF4 and many (15+) other file formats and services using the same API. It works with Matlab 2008a and later.
更多内容请点击阅读原文!
工具包下载地址:https://github.com/nctoolbox/nctoolbox

工具包介绍:NCTOOLBOX Tools for read-only access to Common Data Model dataset.

版本: Version 1.1.1-13-g8582810++ 12-03-2015

文件或函数的功能:

01: setup_nctoolbox - sets your path and classpath to access the nctoolbox functions

02:cfdataset - Provide access to CF/COARDS convention datasets accessable by the

03: ncdataset - Provide access to datasets accessable by the NetCDF 4 API

04: ncgeodataset - NCGEODATASET

05:ncgeovariable - Provide advanced access to variables and their related

06: nctoolbox_info - nctoolbox_info Provide information on the NCTOOLBOX version and dependencies

07: ncugrid - Extention of dataset object class for unstructured grid datasets.

08: ncuvariable - Extention of variable object class for unstructured grid/mesh variables.

09 ncvariable - Provide advanced access to variables and their related

简单例子:

本次数据来源于:fnl.
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

clc;clear;close all
cd nctoolbox-master/
setup_nctoolbox
cd ..
data=ncgeodataset('fnl_20090601_00_00.grib2');
data.variables
% Extract the Temperature_surface
param='Temperature_surface';
air_temperature=data{param}(1,:,:);
lat=data{'lat'}(:);
lon=data{'lon'}(:);
% From this point on the code is identical to the previous example:
air_temperature=double(squeeze(air_temperature));
lat=double(lat);
lon=double(lon)-180;
%% figure
close all
figure
m_proj('Equidistant Cylindrical','lon',[-180 180],'lat',[-90 90]);
m_contourf(lon,lat,air_temperature-273.15,1000,'linestyle','none');
m_coast('patch',[0.1 .85 .7],'edgecolor',[0 0 0],'linewidth',1);
m_grid('ytick',[-90:30:90],'xtick',[-180:60:180],'tickdir','out','linest','none','fontname','Times','fontsize',12,'linewidth',1.5);
% 调用ncl色带
rainbow_r=textread('D:\matlab_work\函数名为colormore的颜色索引表制作\ncl_color_txt\BlueWhiteOrangeRed.txt');
colormap(rainbow_r(:,1:3));
hold on
c=colorbar('eastoutside','ticklength',0);
clim([-60,40])
% 调整colorbar
ax = gca;
axpos = ax.Position;
c.Position(3) = 0.5*c.Position(3);
ax.Position = axpos;
cbarrow;
title('nctoolbox read grib2');
xlabel({'time:20231125','海洋与大气科学'})
export_fig('12nctoolbox read grib2.png','-r300')
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

海洋与大气科学

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值