写在前面,不当之处请指出,若有用到请投币。
之前有写过用wgrib工具包读grib数据,最近在 镭雷蕾擂檑前辈的指点下尝试了nctoolbox工具包。相比之下,nctoolbox更简单方便,很好用。
1、下载nctoolbox,https://code.google.com/archive/p/nctoolbox/downloads 这个网址下载需要开外网。我下载的传到百度网盘了,放在文末最后了。
2、添加到matlab环境,后读取数据。
genpath('nctoolbox路径');
addpath('nctoolbox路径');
setup_nctoolbox
filename='gfs.0p25.2022021500.f000.grib2';
nc=ncdataset(filename);
lon=nc.data('lon');
lat=nc.data('lat');
t=nc.data('time');
pres=nc.data('pressure_difference_layer');
sigma=nc.data('sigma_layer_bounds');
u_max=nc.data('u-component_of_wind_maximum_wind');
u_tropopause=nc.data('u-component_of_wind_tropopause');
u_isobaric=nc.data('u-component_of_wind_isobaric');
u_altitude_above_msl=nc.data('u-component_of_wind_altitude_above_msl');
u_height_above_ground=nc.data('u-component_of_wind_height_above_ground');
u_wind_sigma=nc.data('u-component_of_wind_sigma');
u_pressure_difference_layer=nc.data('u-component_of_wind_pressure_difference_layer');
u_potential_vorticity_surface=nc.data('u-component_of_wind_potential_vorticity_surface');
u_planetary_boundary=nc.data('u-component_of_wind_planetary_boundary');
%%
需要读取的变量名可以利用nc.variables查看,如下:
我在上述过程有遇到,即使你把nctoolbox工具包加到了matlab环境下,也会报错找不到工具包。最好的解决办法就是把需要读取的数据和nctoolbox工具包放在同一个目录下,这样最不容易出错。
链接:https://pan.baidu.com/s/1RNzx-D6Dey_v0-lcMXPt8Q
提取码:2pzm
武汉格发信息技术有限公司,格发许可优化管理系统可以帮你评估贵公司软件许可的真实需求,再低成本合规性管理软件许可,帮助贵司提高软件投资回报率,为软件采购、使用提供科学决策依据。支持的软件有: CAD,CAE,PDM,PLM,Catia,Ugnx, AutoCAD, Pro/E, Solidworks ,Hyperworks, Protel,CAXA,OpenWorks LandMark,MATLAB,Enovia,Winchill,TeamCenter,MathCAD,Ansys, Abaqus,ls-dyna, Fluent, MSC,Bentley,License,UG,ug,catia,Dassault Systèmes,AutoDesk,Altair,autocad,PTC,SolidWorks,Ansys,Siemens PLM Software,Paradigm,Mathworks,Borland,AVEVA,ESRI,hP,Solibri,Progman,Leica,Cadence,IBM,SIMULIA,Citrix,Sybase,Schlumberger,MSC Products...