Re: A ruby script to parse Grads CTL files

From: Saji N. Hameed <saji_at_nyahnyahspammersnyahnyah>
Date: Thu, 6 Mar 2008 07:00:27 +0900

Dear Mary,

I have fixed some bugs and added a few more features to ctl2ncl.rb,
thanks to testing and feedback from Esther Brady.

These include:

   1. The software can now handle "LEVELS" option in the xdef,ydef,zdef
   2. User can chose variables to retrieve
   3. User can also chose the times for which data is to be retrieved

The software can be downloaded from the following link
http://210.98.49.34:1919/software/ctl2ncl

  (can you please update the version in the following page
   http://www.ncl.ucar.edu/Applications/grads.shtml)
  (also in the same page, a minor edit for the link
   "feedback and reports"..the email should be saji_at_apcc21.net)

The standard way of interaction is through the command line. For folks
who may have older ruby versions, the interaction will be automatically
redirected to take place through an interactive interface.
The help screen for the first
mode and interface for the second one is shown below:

cheers!
saji

;--------------------%< standard mode : help screen
Usage: ctl2ncl.rb [options]
A grads ctl parser and NCL code generator based on ruby
Specific options:
    -i, --infile CTLFILE the grads ctl file
    -o, --outfile NCLFILE the NCL script file
    -v, --vars *NUM variables to retrieve
                                     e.g: --vars u850 t850 prec
                                     or -v u850 t850 prec
    -t, --time time(s) -t : supply time as indices
                                     e.g -t 1:5 retrieves data
                                     from t=1 to 5

                                     --time : supply calendar time
                                     e.g --time Jan2005:Dec2005
                                     retrieves data from
                                     time =Jan2005 to Dec2005
        --plot add code to display figures

Common options:
        --help Show this message
        --version Show version
;------------------------------------------------------

interactive mode for users with older ruby installations (<1.8.2??)

%> This is an alternative version of the program
%> Please input the following
%> Input File? sst.ctl
%> Output File? sst.ncl
%> List of variables? Press enter to choose all variables |all|
                   
;------------------------------------------------------

* Mary Haley <haley_at_ucar.edu> [2008-02-12 15:19:26 -0700]:

>
> Hi Saji,
>
> Thanks for this contribution! We would like to put this in the NCL
> Applications page section, if you are agreeable. We could start a
> separate Ruby or GrADS page, or we can add it to an existing file I/O
> page.
>
> We encourage other users who have things they'd like to contribute to
> let us know (via ncl-talk if possible). We are happy to include them
> and give you proper credit, of course.
>
> --Mary
>
>
> On Mon, 11 Feb 2008, Saji N Hameed wrote:
>
>> Dear NCL-ers,
>>
>> Here is a ruby script that is "supposed to" parse a GrADs ctl file and
>> generate NCL code to read in the data and create a COARDS
>> compliant netcdf data object.
>>
>> This is a preview version and some essential features may
>> not be implemented: for example currently there is only
>> support for linear grids (I will add support for gaussian
>> grids over the weekend or better if somebody chipped in
>> and added those code, that will be nice too). Meanwhile
>> I would appreciate feedback and reports on possible bugs/errors.
>>
>> To use:
>> -1. Hopefully you have ruby installed in your system
>>
>> 0. untar the attached tar file ctl2ncl.tar, in somewhere like
>> $HOME/bin
>>
>> 1. point the $PATH variable to this location
>> for example, PATH=$PATH:$HOME/bin ; export PATH
>> OR
>> set path=($HOME/bin $path)
>>
>> 2. after sourcing your .cshrc or .bashrc,
>> run ctl2ncl.rb and follow the instructions
>>
>> 3. the help screen is shown below:
>> Usage: ctl2ncl.rb [options]
>> A grads ctl parser and NCL script generator based on ruby
>> Specific options:
>> -i, --infile=CTLFILE the grads ctl file
>> -o, --outfile=NCLFILE the NCL script file
>> -v, --vars *NUM The variables
>> --plot add code to display figures
>>
>> Common options:
>> --help Show this message
>> --version Show version
>>
>>
>> cheers,
>>
>> saji
>> ...
>>
>> * David F Porter <PorterDF_at_Colorado.EDU> [2008-01-23 15:53:23 -0700]:
>>
>>> Sorry if this has been covered, by I've exhausted the search function with
>>> no real results.
>>>
>>> I am looking to read in some large 4-Byte Float big-endian binary data onto
>>> my little-endian machine. The problem I am having is that each file
>>> corresponds to ONE time period, but each variable in the file has different
>>> dimensions, some 2D and some 3D. Because of the varying sizes, I feel that
>>> I cannot simply use the "record number". Also, I only want some of the
>>> variables (to save space after loading 300 of these files).
>>>
>>> I'm not sure if it matters at this point, but the variables are on a
>>> gaussian grid.
>>>
>>> Dave
>>>
>>
>> --
>> Saji N. Hameed
>>
>> APEC Climate Center +82 51 668 7470
>> National Pension Corporation Busan Building 12F
>> Yeonsan 2-dong, Yeonje-gu, BUSAN 611705 saji_at_apcc21.net
>> KOREA
>>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-- 
Saji N. Hameed
APEC Climate Center          				+82 51 668 7470
National Pension Corporation Busan Building 12F         
Yeonsan 2-dong, Yeonje-gu, BUSAN 611705			saji_at_apcc21.net
KOREA
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Mar 05 2008 - 15:00:27 MST

This archive was generated by hypermail 2.2.0 : Thu Mar 13 2008 - 17:22:55 MDT