No BSD License  

Highlights from
GrADS - Matlab Interface

4.0

4.0 | 4 ratings Rate this file 16 Downloads (last 30 days) File Size: 37.44 KB File ID: #15326

GrADS - Matlab Interface

by Christophe Sturm

 

16 Jun 2007 (Updated 18 Jun 2007)

Read the GrADS control file and retrieves the variable accordingly into the Matlab workspace

| Watch this File

File Information
Description

I introduce here an interface between GrADS and Matlab: the read_grads.m routine reads the GrADS control file and retrieves the variable from the binary file accordingly. As far as possible, the components of the GrADS Data Descriptor File (or control file) were implemented in this routine. The companion routine write_grads.m writes a variable in the Matlab workspace as a binary file, with the appropriate control file. Examples are given hereafter.
Example:

[data,header]=read_grads('filename.ctl',''); % Reads only the header
[data,header]=read_grads('filename.ctl','varname'); % Reads the header and <varname>
[data,header]=read_grads('filename.ctl','varname','z',[z1,z2],'lon',[lon1,lon2],'lat',[lat1,lat2],'t',[t1,t2]);
[data,header]=read_grads('filename.nc','varname'); % Extension of read_grads.m to NetCDF variables

    * data is a 4-D variable, with X/lon as the first dimension, Y/lat as second dimension, Z/lev as third dimension and time in fourth dimension.
    * header is a structure variable, which contains all relevant information from the GrADS control file. In particular, the header.XDEF and header.YDEF sub-structures contain information for plotting the variable. header.XDEF.num is the number of X fields, and header.XDEF.vec the X coordinates.

Further details can be seen from the dedicated page: http://www.uib.no/People/kst064/REMOiso-toolbox/Matlab_Toolbox.html

MATLAB release MATLAB 7.3 (R2006b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (5)
03 Aug 2007 Caroline Bain

Thanks! Nice function, works well

05 Feb 2008 sisily lowrence  
19 May 2008 gaoli su

read grads file using the matlab code

18 Sep 2008 trent biggs

I just had to change the date format to hh:mmZddmmyyyy (I had ddmmyyyy).
thanks!

20 Jan 2012 Jesus Portilla

beautiful! thanks.

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
data import Christophe Sturm 22 Oct 2008 09:16:04
data export Christophe Sturm 22 Oct 2008 09:16:04
grads binary climate io Christophe Sturm 22 Oct 2008 09:16:04

Contact us at files@mathworks.com