Downloading GRIB files directly into Matlab

25 次查看(过去 30 天)
I want to read in data from the GFS weather forecasting model. The NOAA has some URL links from which the data can be downloaded, e.g.:
In the internet browser, this link autmatically downloads a file. In Matlab I do the following:
fullURL = ['https://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_0p25_1hr.pl?file=gfs.t06z.pgrb2.0p25.f011&lev_surface=on&var_CAPE=on&leftlon=0&rightlon=360&toplat=90&bottomlat=-90&dir=%2Fgfs.2019053006'];
filename = 'cape_test.anl';
urlwrite(fullURL,filename);
These files open well in GIS software such as QGIS or ArcGIS. But how can I now read in these files automatically in MatLab so I can display them with the imagesc() command? Can someone help me?
Thanks already!

采纳的回答

meghannmarie
meghannmarie 2019-6-2
I would download nctoolbox from:
Below is some example code to get data using toolbox.
fullURL = ['https://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_0p25_1hr.pl?file=gfs.t06z.pgrb2.0p25.f011&lev_surface=on&var_CAPE=on&leftlon=0&rightlon=360&toplat=90&bottomlat=-90&dir=%2Fgfs.2019053006'];
filename = 'cape_test.anl';
urlwrite(fullURL,filename);
addpath('nctoolbox-1.1.3');
setup_nctoolbox;
grib = ncgeodataset(filename);
variables = grib.variables;
data = grib.geovariable('Convective_available_potential_energy_surface');
grib_data = double(data.data(:));
lat = grib.geovariable('lat');
grib_lat = double(lat.data(:));
lon = grib.geovariable('lon');
grib_lon = double(lon.data(:));
time = grib.geovariable('time');
grib_time = double(time.data(:));

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Downloads 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by