Opening multiple CTL files in one gs script

Charles Seman Charles.Seman at NOAA.GOV
Tue Aug 29 12:12:46 EDT 2006


Cynthia,

Here's an idea (don't know if it will work...):

Try defining local variables like:

'open ujune.ctl'
'set x 1 144'
'set y 1 73'
'set z 1'
'set t 1'
'define ujune = u'
'close 1'
'open vjune.ctl'
'set x 1 144'
'set y 1 73'
'set z 1'
'set t 1'
'define vjune = v'
'close 1'

open ujuly.ctl'
'set x 1 144'
'set y 1 73'
'set z 1'
'set t 1'
'define ujuly = u'
'close 1'
'open vjuly.ctl'
'set x 1 144'
'set y 1 73'
'set z 1'
'set t 1'
'define vjuly = v'
'close 1'

open uaugust.ctl' * if this is the name of your file...
'set x 1 144'
'set y 1 73'
'set z 1'
'set t 1'
'define uaugust = u'
'close 1'
'open vaugust.ctl' * if this is the name of your file...
'set x 1 144'
'set y 1 73'
'set z 1'
'set t 1'
'define vaugust = v'

then try working with the locally defined variables "ujune", "vjune", etc...

Discussion and some questions:
If desired, I think you can close the last file; in experience with
this, it seems that it does not matter if a GrADs ctl file is open in
order to work with the local variables (I have found that it does not
cause any problems to leave a ctl file open, and is convenient to leave
a ctl file open to show what the (x,y,z) ranges are, for example; I
usually leave a ctl file open when working with defined variables)...
Questions to GrADS users: is what I've written about closing the last
ctl file correct? should one leave a ctl file open to provide
information for the defined variables, or should all ctl files be closed
before working with locally defined variables? does it matter whether a
ctl file is open for locally defined variables? from the GrADS web site
http://grads.iges.org/grads/gadoc/variable.html#new
it does not appear to matter... which discusses how by doing 'set t 1'
the time of the defined variables becomes a "wild card" which allows the
variables to be added together, etc...
from the above web site:
---
If you define a variable that has fixed dimensions, and then later
access this variable, the fixed dimensions are treated as "wild cards".
The best way to show this is with an example:

      |set lon -180 0
      set lat 0 90
      set lev 500
      set t 10
      define zave = ave(z,t=1,t=30)
      |

The defined variable has two varying dimensions. If we now display this
variable (or use it in an expression), the fixed dimensions of the
defined variable, namely |Z| and |T|, will match ANY |Z| and |T|
dimension setting:

      |set t 1
      set lev 200
      d zave
      |

In the above display, the variable |zave| would be displayed as it was
defined, ie you would get a time average of 500mb heights, even though
the level is set to 850.
---

I hop this helps,
Chuck




Cynthia Dettmer wrote:
>
> Aloha GrADS users!
>
> I have been playing around with GrADS for a few months now, so I’m
> still a novice, and have read previous posts but didn’t seem to find a
> question like this. I am using GrADS on a UNIX machine and have been
> able to create many useful maps with .nc data. I used FORTRAN to
> calculate tropospheric layer mean wind (TLMW) between 850-200mb, and
> separated the output into .grd files for each component and month
> (ujune, vjune, ujuly, etc). I have created several CTL files (one for
> each month/component), with each file having either ‘u’ or ‘v’ as the
> variable and want to combine them in a .gs script to create a seasonal
> average (July, August, and September for example). I have the
> following in my .gs :
>
> open ujune.ctl
>
> open vjune.ctl
>
> open ujuly.ctl
>
> open vjuly.ctl
>
> etc
>
> The first 2 files open, and will display without any problem using d
> u;v.2. The message I get when it just attempts to open the 3^rd ctl
> file (in this case ujuly) and any files after is:
>
>
> Data request error: invalid grid coordinates. World coordinates
> convert to non-integer grid coordinates
>
> Variable u.3 dimension=3
>
> Each ctl file works fine alone (and are identical, one is for u values
> in June, v values in June, etc), and if I switch the order whichever 2
> files are first open with no problem, those after do not. I am able to
> view monthly data fine, but can’t combine it as any files after 2 will
> not open. The ctl files are as follows:
>
> dset ujuly.tlmw.66-03.grd
>
> title ahfkahsdf
>
> undef -999
>
> xdef 144 linear 0 2.5
>
> ydef 73 linear -90 2.5
>
> zdef 1 linear 1 1
>
> tdef 38 linear jul1966 12mo
>
> vars 1
>
> u 0 -999 akjfdhlakjdgh
>
> endvars
>
> (the only difference between ctl files is the dset will be
> ujune.tlmw.66-03.grd, etc in each ctl file, and the tdef 38 linear
> jul1966 12mo would be jun1966, etc)
>
> Any idea how to open more than just these 2 ctl files so I can create
> an average of 3 months in one gs script, or why I’m getting that
> error? Thanks so much for your help!
>
> Cindy J
>

--

Please note that Charles.Seman at noaa.gov should be considered my NOAA
email address, not cjs at gfdl.noaa.gov.

********************************************************************
 Charles Seman                                Charles.Seman at noaa.gov
 U.S. Department of Commerce / NOAA / OAR
 Geophysical Fluid Dynamics Laboratory         voice: (609) 452-6547
 201 Forrestal Road                              fax: (609) 987-5063
 Princeton, NJ  08540-6649            http://www.gfdl.noaa.gov/~cjs/
********************************************************************

"The contents of this message are mine personally and do not reflect
any position of the Government or NOAA."



More information about the gradsusr mailing list