Andy,<br>If you have a CTL file or your data and would be willing to share I could look through it and see what you might be doing wrong. Since I don't use OpenGrads it might be a difference between the regular Grads and OpenGrads, but I don't know. There is one line that makes a difference whether you're using analysis data or model output of your own, so let me know what kind of data you're using.<br>
<br>Jeff<br><br><div class="gmail_quote">On Tue, Apr 19, 2011 at 7:50 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"><span style="font-size:11.0pt;color:#1F497D">Jeff,</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"> </span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">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.</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"> </span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">For the short version, ymax always returns :</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"> </span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">1,</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"> </span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">A few questions:</span></p>
<p><span style="font-size:11.0pt;color:#1F497D"><span>-<span style="font:7.0pt "Times New Roman"">
</span></span></span><span style="font-size:11.0pt;color:#1F497D">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?</span></p>
<p><span style="font-size:11.0pt;color:#1F497D"><span>-<span style="font:7.0pt "Times New Roman"">
</span></span></span><span style="font-size:11.0pt;color:#1F497D">When in the script, do I need the ‘’ around the
values? Likewise do I use ‘’ around my mapping variable?</span></p>
<p><span style="font-size:11.0pt;color:#1F497D"><span>-<span style="font:7.0pt "Times New Roman"">
</span></span></span><span style="font-size:11.0pt;color:#1F497D">I’m using OpenGrads, I don’t know if that makes a
difference.</span></p>
<p><span style="font-size:11.0pt;color:#1F497D"><span>-<span style="font:7.0pt "Times New Roman"">
</span></span></span><span style="font-size:11.0pt;color:#1F497D">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?</span></p>
<p><span style="font-size:11.0pt;color:#1F497D"><span>-<span style="font:7.0pt "Times New Roman"">
</span></span></span><span style="font-size:11.0pt;color:#1F497D">I’m running a customized WRF-NMM, fyi.</span></p>
<p><span style="font-size:11.0pt;color:#1F497D"> </span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">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. </span><span style="font-size:11.0pt;font-family:Wingdings;color:#1F497D">J</span><span style="font-size:11.0pt;color:#1F497D"> Obviously I’m not doing something right. Must be a
misunderstanding of the scripting language.</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"> </span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">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.</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"> </span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">Thanks for your help.</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">Andy</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"> </span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"> </span></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt">From:</span></b><span style="font-size:10.0pt">
<a href="mailto:gradsusr-bounces@gradsusr.org" target="_blank">gradsusr-bounces@gradsusr.org</a> [mailto:<a href="mailto:gradsusr-bounces@gradsusr.org" target="_blank">gradsusr-bounces@gradsusr.org</a>] <b>On
Behalf Of </b>Jeffrey Duda<br>
<b>Sent:</b> Saturday, April 16, 2011 12:03 PM<br>
<b>To:</b> GrADS Users Forum<br>
<b>Subject:</b> Re: [gradsusr] Max Value</span></p>
</div><div><div></div><div class="h5">
<p class="MsoNormal"> </p>
<p class="MsoNormal" style="margin-bottom:12.0pt">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>
<b><i><u> if (index < 1e+6 & index > -1e+6)</u></i></b>
(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</p>
<div>
<p class="MsoNormal">On Fri, Apr 15, 2011 at 5:53 PM, Andrew Revering <<a href="mailto:andy@f5data.com" target="_blank">andy@f5data.com</a>> wrote:</p>
<div>
<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>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
_______________________________________________<br>
gradsusr mailing list<br>
<a href="mailto:gradsusr@gradsusr.org" target="_blank">gradsusr@gradsusr.org</a><br>
<a href="http://gradsusr.org/mailman/listinfo/gradsusr" target="_blank">http://gradsusr.org/mailman/listinfo/gradsusr</a></p>
</div>
<p class="MsoNormal"><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/%7Ejdduda" target="_blank">www.meteor.iastate.edu/~jdduda</a></p>
</div></div></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>