[gradsusr] Get data for two or more variables

Rajendra Man Shrestha rajendraman_shrestha at yahoo.com
Sun Nov 6 08:19:57 EST 2011


Dear sir/madam
I need to get the data for precip in txt or csv format on the basis of Lat, Lon and Time in the single file by using OpenGrads. I use fprintf command in OpenGrads.The output must be like this; (for example)
Lat          Lon          Year    Month    Day    Precipitation26.875    85.125      2007     Jan       1        0.00256


Please guide me ahead.

--- On Thu, 11/3/11, gradsusr-request at gradsusr.org <gradsusr-request at gradsusr.org> wrote:

From: gradsusr-request at gradsusr.org <gradsusr-request at gradsusr.org>
Subject: gradsusr Digest, Vol 21, Issue 10
To: gradsusr at gradsusr.org
Date: Thursday, November 3, 2011, 8:33 PM

Send gradsusr mailing list submissions to
    gradsusr at gradsusr.org

To subscribe or unsubscribe via the World Wide Web, visit
    http://gradsusr.org/mailman/listinfo/gradsusr
or, via email, send a message with subject or body 'help' to
    gradsusr-request at gradsusr.org

You can reach the person managing the list at
    gradsusr-owner at gradsusr.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of gradsusr digest..."


Today's Topics:

   1. Re: Finding the maximum value of Ri in a single grid    point
      (Jeffrey Duda)
   2. Shp File Output (Andrew Revering)
   3. Re: time stamp on map (saeed bayat)
   4. Re: time stamp on map (saeed bayat)


----------------------------------------------------------------------

Message: 1
Date: Thu, 3 Nov 2011 18:46:22 -0500
From: Jeffrey Duda <jdduda at iastate.edu>
Subject: Re: [gradsusr] Finding the maximum value of Ri in a single
    grid    point
To: GrADS Users Forum <gradsusr at gradsusr.org>
Message-ID:
    <CAP9LQ-WwHhZo-40TvQRj8KJzTTAWuw+ub9LVLoqnWmqsyKcT-g at mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

The problem is that there is a difference between grids that can be
displayed and script variables.  They can't be handled the same way.  You
can't use if statements using displayed fields.  What you need to do is to
save the output of each computation in your script to a script variable
using the subwrd command.  Here is an example:

'define th1 = temp * (pow(100000 / press , (0.286)))'
th1 = subwrd(result,4)

Hopefully you've noticed this before, but when you enter a display command
at the Grads prompt, there will be a small amount of text output.  If you
display a variable with all of the dimensions in your environment fixed,
the text will include the value of the field you are displaying.  What
subwrd does is grab the fourth word in the string variable "result".
"result" is automatically assigned each time a display command is run, so
that's why you don't see it being assigned anywhere else.  NOTE: for some
data sets and for some environment settings, Grads will interpolate the
output before displaying, so the text output from the display command will
read

"Note: interpolating variable...
Result value: _____"

In that case you'll need to use the sublin command first:
line = sublin(result,2)
th1 = subwrd(line,4)
This tells Grads to nab the second line of the output from the result
variable (result includes all of the text output from the display
command).  Then you use subwrd to nab the 4th word of the string variable
"line".  When you do this, you'll have the fields you want as Grads
scripting variables.  Then you can run if statements on them.  To output
the value of a Grads script variable, use the say command:
say th1 OR
say "th1 = "th1

ON THE OTHER HAND, you can do this without using any scripting variables.
In this case use the max/min and maxloc/minloc functions.  Then your script
would look something like this:

'set lev 'botlevel' 'toplevel

 'define th1 = temp * (pow(100000 / press , (0.286)))'
'define u1 = u'
 'define v1 = v'
'define z1 = geopot/9.81'

 'define th2 = temp(z-1) * (pow(100000 / press(z-1) , (0.286)))'
'define u2 = u(z-1)'
 'define v2 = v(z-1)'
'define z2 = geopot(z-1)/9.81'

'define
ri=9.81/(0.5*th1+th2)*(th2-th1)/(pow((u2-u1),2)+pow((v2-v1),2))*(z2-z1)'

'd ri'
say result

'd min(ri,lev='botlev',lev='toplev')'
'd minloc(ri,lev='botlev',lev='toplev')'
'd max(ri,lev='botlev',lev='toplev')'
'd maxloc(ri,lev='botlev',lev='toplev')'

Carefully follow the location of the single quotes and note that there is
no while loop here.  Also note the (z-1) appended to the *2 variables to
represent the field one level below the current level.  The whole quote
thing confuses some people, so that's understandable.  Try this and see if
it works.  Ask if you have any questions.  Good luck.

Jeff Duda

On Thu, Nov 3, 2011 at 5:23 AM, Lippo Nester <liikkuvattaakse at gmail.com>wrote:

> Hi!
>
> I've been trying to create my very first GrADS-script. The script should
> compute values of the bulk Richardson number in a specific grid point
> between predefined model levels and then find the minimum value of Ri and
> probably the model level associated with it.
>
> I tried to do this using while and if loops, but for some reason it's not
> working as I expected. Maybe I can't understand handling variables in GrADS?
>
> In this script the top and the bottom model layers are set to 40 and 50.
> Ri is computed and I get a list of the Ri at different levels, and they
> seem to be ok. However the variable "minri" gets always the value of ri at
> the lowest model level (here: ri at level 50). Variable "minlevel" is
> always the highest model level (here: level 40)!
>
> When count is 40 at the first step of the while-loop, the value of ri
> should be saved into variable minri and the model level at minlev. After
> that, if ri < minri at lower levels (count > 40), values of minri and
> minlev should be varied by the second if-loop...
>
> Is there a more simple or more correct way to do this? I thought max()
> can't make it...
>
> Any help is much appreciated!
>
> Best regards, Lippo
>
> (version of GrADS 2.0.a1)
>
> 'set lat 50.00'
> 'set lon 10.00'
> botlevel=50
> toplevel=40
>
> count=toplevel
>
> while (count <= botlevel)
>
> 'set lev 'count
>  'define th1 = temp * (pow(100000 / press , (0.286)))'
> 'define u1 = u'
>  'define v1 = v'
> 'define z1 = geopot/9.81'
>
> 'set lev 'count - 1
>  'define th2 = temp * (pow(100000 / press , (0.286)))'
> 'define u2 = u'
>  'define v2 = v'
> 'define z2 = geopot/9.81'
>
> 'define
> ri=9.81/(0.5*th1+th2)*(th2-th1)/(pow((u2-u1),2)+pow((v2-v1),2))*(z2-z1)'
>
> 'd 'ri
> say result *THIS SEEMS TO WORK AS I GET 10 DIFFERENT VALUES OF RI
>
> if (count = toplevel) *THESE IF-LOOPS AREN'T OKAY, BUT WHY?
> minri = ri
>  minlevel = count
> endif
>
> if (ri < minri)
>  minri = ri
> minlevel = count
> endif
>
> count = count+1
> endwhile
>
> 'd 'minri
> say "Min Ri " result *ALWAYS THE VALUE OF RI AT LEVEL 50 (AT THE BOTTOM
> LEVEL)
> 'd 'minlevel
> say "Model level " result *ALWAYS LEVEL 40 (TOP LEVEL)
>
>
>
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
>


-- 
Jeff Duda
Iowa State University
Meteorology Graduate Student
www.meteor.iastate.edu/~jdduda <http://www.meteor.iastate.edu/%7Ejdduda>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20111103/26251ce0/attachment-0001.html 

------------------------------

Message: 2
Date: Thu, 3 Nov 2011 22:09:18 -0500
From: Andrew Revering <andy at f5data.com>
Subject: [gradsusr] Shp File Output
To: GrADS User List <gradsusr at gradsusr.org>
Message-ID:
    <CAHXC6utdKDzEXF_0B-fM1soXTeHrX7eOcs+mBWOopjK_=sJFQg at mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Is it possible to adjust the amount of smoothing done to SHP output
polygons?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20111103/7001c529/attachment-0001.html 

------------------------------

Message: 3
Date: Fri, 4 Nov 2011 11:17:54 +0330
From: saeed bayat <saeedbayat7276 at gmail.com>
Subject: Re: [gradsusr] time stamp on map
To: GrADS Users Forum <gradsusr at gradsusr.org>
Message-ID:
    <CAAVavjqtYo7a=VkXr9rzxLfuf=rWrKE6DJW3xW4Pn6u66eoanQ at mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Dear Sytske,
Suppose you have a nc data for a month with 30 timestep(daily). Try like
this:
ti = 1
while ti <= 31
open your file and do whatever you want
 'q time'
    res = subwrd(result,3)
    basedate = substr(res,4,12)
    basetime = substr(res,1,3)
    res = subwrd(result,6)
    baseday=substr(res,1,3)
draw  title whatever you want-['basedate'-'basetime']'
 'printim whatever you want-'ti'-'basedate'-'basetime'.gif x1300 y1000
white'
    ti = ti + 1
ENDWHILE
say

Good Luck

Saeed Bayat
M.A Student of Climatology
Department of Geography
Ferdowsi University of Mashhad(FUM) - Iran

On Thu, Nov 3, 2011 at 7:23 PM, Sytske Kimball <SKimball at usouthal.edu>wrote:

>  All,
>
> When drawing a map, does anyone know how to draw the date/time on it for
> which
> the map is valid (as defined in the .ctl file)?
>
> Thanks in advance for your help,
> Sytske
>
>
>
> Sytske (seets-kah) Kimball
> Professor of Meteorology
> Director, USA Mesonet
> Dept. of Earth Sciences
> University of South Alabama
> Mobile, AL
> phone (251) 460-7031
>        or (251) 445-4294
> fax       (251) 460-7886
> email   skimball at usouthal.edu
> web:   http://chiliweb.southalabama.edu/
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20111104/c3d676cd/attachment-0001.html 

------------------------------

Message: 4
Date: Fri, 4 Nov 2011 11:20:41 +0330
From: saeed bayat <saeedbayat7276 at gmail.com>
Subject: Re: [gradsusr] time stamp on map
To: GrADS Users Forum <gradsusr at gradsusr.org>
Message-ID:
    <CAAVavjrV6U_USQb-U7o8_Tk0d67W_EQ2T90pDNgHcG4A3z-tsg at mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

My opologize,
you should correct this line:
while ti <= 30



On Thu, Nov 3, 2011 at 7:23 PM, Sytske Kimball <SKimball at usouthal.edu>wrote:

>  All,
>
> When drawing a map, does anyone know how to draw the date/time on it for
> which
> the map is valid (as defined in the .ctl file)?
>
> Thanks in advance for your help,
> Sytske
>
>
>
> Sytske (seets-kah) Kimball
> Professor of Meteorology
> Director, USA Mesonet
> Dept. of Earth Sciences
> University of South Alabama
> Mobile, AL
> phone (251) 460-7031
>        or (251) 445-4294
> fax       (251) 460-7886
> email   skimball at usouthal.edu
> web:   http://chiliweb.southalabama.edu/
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20111104/a1137aad/attachment.html 

------------------------------

_______________________________________________
gradsusr mailing list
gradsusr at gradsusr.org
http://gradsusr.org/mailman/listinfo/gradsusr


End of gradsusr Digest, Vol 21, Issue 10
****************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20111106/3eabda22/attachment-0003.html 


More information about the gradsusr mailing list