Downloading GRIB files directly into Matlab

53 ビュー (過去 30 日間)
Yoni Verhaegen
Yoni Verhaegen 2019 年 5 月 30 日
コメント済み: KSSV 2022 年 5 月 20 日
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(:));
  2 件のコメント
Yoni Verhaegen
Yoni Verhaegen 2019 年 6 月 2 日
編集済み: Yoni Verhaegen 2019 年 6 月 2 日
Thanks! This is really nice!
KSSV
KSSV 2022 年 5 月 20 日

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDownloads についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by