Andrew,<br><br>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:<br>
<br>'define mxy = max('ans',x='x1',x='x2')'<br>'d maxloc(mxy,y='y1',y='y2')'<br>ymax = subwrd(result,4)<br><br>Attached is an image showing how it works. The field is 850 mb theta-e. Script output is:<br>
<br>The actual maximum location is at (x,y) = (223,36) or (lat,lon) = (36.0997,-97.4195) and is 340.864<br>The actual minimum location is at (x,y) = (146,279) or (lat,lon) = (42.9153,-100.243) and is 310.718<br><br>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:<br>
<br>*Finding the location of maximum value<br>max = -999999<br>yy = y1<br>while (yy <= y2)<br> 'set y 'yy<br> 'd maxloc('ans',x='x1',x='x2')'<br> line = sublin(result,2)<br> index = subwrd(line,4)<br>
<u><b><i> if (index < 1e+6 & index > -1e+6)</i></b></u> (THIS TELLS THE SCRIPT TO REJECT A POINT IF IT ESSENTIALLY IS OFF THE GRID, I.E., AN UNDEF)<br> 'set x 'index<br> 'd 'ans<br> line = sublin(result,2)<br>
act_max = subwrd(line,4)<br>*setting index of max value into array<br> max.yy.1 = index<br>*setting actual max value into array<br> max.yy.2 = act_max<br> 'set x 'x1' 'x2<br> if (max.yy.2 > max)<br>
max_val = max.yy.2<br> max_locx = max.yy.1<br> max_locy = yy<br> max = max_val<br> endif<br> endif<br> yy = yy + 1<br>endwhile<br><br>Let me know if you have further questions.<br><br>Jeff Duda<br><br><div class="gmail_quote">
On Fri, Apr 15, 2011 at 5:53 PM, Andrew Revering <span dir="ltr"><<a href="mailto:andy@f5data.com">andy@f5data.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div link="blue" vlink="purple" lang="EN-US">
<div>
<p class="MsoNormal">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.</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">Here is my code:</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">‘d maxloc(max(tt,x=0,x=1028),y=0,y=768)’</p>
<p class="MsoNormal">Line=sublin(result,2)</p>
<p class="MsoNormal">Ygrd=subwrd(line,4)</p>
<p class="MsoNormal">‘d maxloc(max(tt,y=0,y=768),x=0,x=1028)’</p>
<p class="MsoNormal">Line=sublin(result,2)</p>
<p class="MsoNormal">Xgrd=subwrd(line,4)</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">‘set x ‘xgrd</p>
<p class="MsoNormal">Lonval = subwrd(result,4)</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">‘set y ‘ygrd</p>
<p class="MsoNormal">Latval = subwrd(result,4)</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">‘q w2xy ‘lonval’ ‘latval</p>
<p class="MsoNormal">Xpos = subwrd(result,3)</p>
<p class="MsoNormal">Ypos = subwrd(result,6)</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">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.</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"> </p>
</div>
</div>
<br>_______________________________________________<br>
gradsusr mailing list<br>
<a href="mailto:gradsusr@gradsusr.org">gradsusr@gradsusr.org</a><br>
<a href="http://gradsusr.org/mailman/listinfo/gradsusr" target="_blank">http://gradsusr.org/mailman/listinfo/gradsusr</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Jeff Duda<br>Iowa State University<br>Meteorology Graduate Student<br>3134 Agronomy Hall<br><a href="http://www.meteor.iastate.edu/~jdduda">www.meteor.iastate.edu/~jdduda</a><br>