[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
decoding GRIB files in Octave
From: |
Alexander Barth |
Subject: |
decoding GRIB files in Octave |
Date: |
Fri, 28 Oct 2005 15:35:11 -0500 |
User-agent: |
Mozilla Thunderbird 1.0 (Windows/20041206) |
Hi all,
With those poor people (like me) who need to decode a cryptic GRIB file,
I want to share loadgrib (http://ocgmod1.marine.usf.edu/loadgrib/), a
octave function to import variables from a GRIB file. GRIB is the file
format used by most weather forecasting centers to store their model
forecasts. It is standardized by the World Meteorological Organization.
This function is based on the wgrib tool of Wesley Ebisuzaki which he
placed into the public domain.
To install and compile this function, type:
wget -O - http://ocgmod1.marine.usf.edu/loadgrib/loadgrib-0.1.tar.gz | tar
xvfz -
cd loadgrib
make
The example below shows the usage of loadgrib. It gives the air
temperature forecast in your home town (based on forecast of the NCEP
Global Forecast System). You will need wget and octave-forge.
Cheers
Alex
my_lon = 278; % your longitude in degrees East [0:360]
my_lat = 28; % your latitude in degrees North [-90:90]
t = floor(time/86400) * 86400; % epoch time of last midnight
my_date = strftime('%Y%m%d',gmtime(t)); % current date in UTC
% load about 41 MB from NCEP GFS
system(['wget -O gfs.grib
ftp://ftpprd.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/gfs.' my_date
'/gfs.t00z.sfluxgrbf24']);
airtemp = loadgrib('gfs.grib',38);
lon = linspace(0,359.687,1152);
lat = linspace(-89.761,89.761,576);
my_airtemp = interp2(lon,lat,airtemp(:,end:-1:1)',my_lon,my_lat);
my_airtemp = my_airtemp - 273.15;
disp(['Forcasted temp. for ' strftime('%d-%b-%y %H:%M:%S CUT',gmtime(t+86400))
': ' num2str(my_airtemp) ' deg C']);
%colormap(hsv); imagesc(airtemp')
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- decoding GRIB files in Octave,
Alexander Barth <=