필터 지우기
필터 지우기

Downloading GRIB files directly into Matlab

조회 수: 35 (최근 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 CenterFile Exchange에서 Downloads에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by