[gradsusr] Max Value

Andrew Revering andy at f5data.com
Tue Apr 19 20:50:44 EDT 2011


Jeff,

 

I appreciate all your help with this. every time I try one of these
solutions it doesn't work for me. I'm not sure what I'm doing wrong.

 

For the short version, ymax always returns :

 

1,

 

A few questions:

-          Am I supposed to be using something like x=0,x=1078 (IE the
dimensions of my image) or lon=-98,lon=-80 (the coordinates of the map
edges?

-          When in the script, do I need the '' around the values? Likewise
do I use '' around my mapping variable?

-          I'm using OpenGrads, I don't know if that makes a difference.

-          Where you have y1, y2, x1, x2, I'm replacing that with my actual
values, correct? Or do I need to create those variables and populate those
with my coordinates?

-          I'm running a customized WRF-NMM, fyi.

 

I tried the long version but had no success there either. When I tried to
display the contents of max_locx and max_locy it simply displayed max_locx
and max_locy. J Obviously I'm not doing something right. Must be a
misunderstanding of the scripting language.

 

Do you have a working script you could post that I could try to get to work
with my CTL files. If I can get one that works (prints coordinates on an
image) I can work backwards from there to see what I'm doing wrong.

 

Thanks for your help.

Andy

 

 

From: gradsusr-bounces at gradsusr.org [mailto:gradsusr-bounces at gradsusr.org]
On Behalf Of Jeffrey Duda
Sent: Saturday, April 16, 2011 12:03 PM
To: GrADS Users Forum
Subject: Re: [gradsusr] Max Value

 

Andrew,

I made a script to do the same thing.  I've noticed in mine that I broke up
your one line into two.  That might make the difference.  I think what is
going on is the command is searching through your UNDEF values and finding
those to be the max.  Here's how it goes in my code:

'define mxy = max('ans',x='x1',x='x2')'
'd maxloc(mxy,y='y1',y='y2')'
ymax = subwrd(result,4)

Attached is an image showing how it works.  The field is 850 mb theta-e.
Script output is:

The actual maximum location is at (x,y) = (223,36) or (lat,lon) =
(36.0997,-97.4195) and is 340.864
The actual minimum location is at (x,y) = (146,279) or (lat,lon) =
(42.9153,-100.243) and is 310.718

Before I learned the faster way of doing this, I made another script that
does it using arrays.  It took a bit longer to run, but I never had a
problem with accuracy.  It rejects candidates that are too high or too low.
Here's the beef of that code:

*Finding the location of maximum value
max = -999999
yy = y1
while (yy <= y2)
 'set y 'yy
 'd maxloc('ans',x='x1',x='x2')'
 line = sublin(result,2)
 index = subwrd(line,4)
 if (index < 1e+6 & index > -1e+6)  (THIS TELLS THE SCRIPT TO REJECT A POINT
IF IT ESSENTIALLY IS OFF THE GRID, I.E., AN UNDEF)
  'set x 'index
  'd 'ans
  line = sublin(result,2)
  act_max = subwrd(line,4)
*setting index of max value into array
  max.yy.1 = index
*setting actual max value into array
  max.yy.2 = act_max
  'set x 'x1' 'x2
  if (max.yy.2 > max)
   max_val = max.yy.2
   max_locx = max.yy.1
   max_locy = yy
   max = max_val
  endif
 endif
 yy = yy + 1
endwhile

Let me know if you have further questions.

Jeff Duda

On Fri, Apr 15, 2011 at 5:53 PM, Andrew Revering <andy at f5data.com> wrote:

I'm trying to do a max value plot. I got it to give me coordinates, but it's
not quite right. No matter what the variable is on the map that I'm trying
to find the max value for, it always gives me coordinates (and plots
visually) in the far lower left corner of the screen where there are no
values.

 

Here is my code:

 

 

'd maxloc(max(tt,x=0,x=1028),y=0,y=768)'

Line=sublin(result,2)

Ygrd=subwrd(line,4)

'd maxloc(max(tt,y=0,y=768),x=0,x=1028)'

Line=sublin(result,2)

Xgrd=subwrd(line,4)

 

'set x 'xgrd

Lonval = subwrd(result,4)

 

'set y 'ygrd

Latval = subwrd(result,4)

 

'q w2xy 'lonval' 'latval

Xpos = subwrd(result,3)

Ypos = subwrd(result,6)

 

Then I go further to plot the coordinate, which works. The printed lat/lon
is correct for where the marker is, but it is NOT where the max val is. Its
way down in the lower left corner of the image.

 

 


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




-- 
Jeff Duda
Iowa State University
Meteorology Graduate Student
3134 Agronomy Hall
www.meteor.iastate.edu/~jdduda

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20110419/fba533d7/attachment-0003.html 


More information about the gradsusr mailing list