Filter löschen
Filter löschen

Downloading GRIB files directly into Matlab

36 Ansichten (letzte 30 Tage)
Yoni Verhaegen
Yoni Verhaegen am 30 Mai 2019
Kommentiert: KSSV am 20 Mai 2022
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!

Akzeptierte Antwort

meghannmarie
meghannmarie am 2 Jun. 2019
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 Kommentare
Yoni Verhaegen
Yoni Verhaegen am 2 Jun. 2019
Bearbeitet: Yoni Verhaegen am 2 Jun. 2019
Thanks! This is really nice!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Downloads finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by