[gradsusr] Max Value
Jeffrey Duda
jdduda at iastate.edu
Sat Apr 16 13:03:29 EDT 2011
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/20110416/e3470395/attachment-0003.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 850_TH_E_example.gif
Type: image/gif
Size: 64210 bytes
Desc: not available
Url : http://gradsusr.org/pipermail/gradsusr/attachments/20110416/e3470395/attachment-0003.gif
More information about the gradsusr
mailing list