<html><head></head><body>Thanks Tom,<br>
Very helpful. I like the new function better than the old.<br>
<br>
I also figured out how to get the old maxloc to work. Like you said, I had to figure out how many lines of output to scan to get the result. I wasn't scanning deep enough into the pile. <br>
<br>
Appreciate your help!<br><br><div class="gmail_quote">On April 29, 2015 4:33:41 PM PDT, Thomas Robinson <ter@hawaii.edu> wrote:<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div dir="ltr">Aloha Mark, <div><br /></div><div>I've had much better luck using amaxlocx and amaxlocy over maxloc.</div><div><a href="http://www.iges.org/grads/gadoc/gradfuncamaxlocx.html">http://www.iges.org/grads/gadoc/gradfuncamaxlocx.html</a><br /></div><div><br /></div><div>It's two lines of code instead of one, but then you don't have to deal with the nightmare of output from the maxloc function. When you use maxloc, it produces a lot of output, so your script is just grabbing the wrong line. amaxlocx and amaxlocy produce only 1 line of output. </div><div><br /></div><div>That's what I used as a work around for this same problem. Here is the code to replace what you are doing. I hope it works for you.</div><div><br /></div><div>**Find the x-coordinate of the maximum htsgw (xc)</div><div><span style="font-size:12.8000001907349px">'d a</span><span class="" style="font-size:12.8000001907349px;background-color:rgb(255,255,255)">maxlocx</span><span
style="font-size:12.8000001907349px">(</span><span style="font-size:12.8000001907349px">htsgw,lon='lon1',</span><span style="font-size:12.8000001907349px">lon='lon2',lat='lat1',lat='</span><span style="font-size:12.8000001907349px">lat2')'</span></div><div><span style="font-size:12.8000001907349px">xc=subwrd(result,4)</span></div><div>**Find the y-coordinate of the maximum htsgw (yc)<span style="font-size:12.8000001907349px"><br /></span></div><div><span style="font-size:12.8000001907349px">'d a</span><span class="" style="font-size:12.8000001907349px">maxlocy</span><span style="font-size:12.8000001907349px">(</span><span style="font-size:12.8000001907349px">htsgw,lon='lon1',</span><span style="font-size:12.8000001907349px">lon='lon2',lat='lat1',lat='</span><span style="font-size:12.8000001907349px">lat2')'</span><span style="font-size:12.8000001907349px"><br /></span></div><div><span
style="font-size:12.8000001907349px">yc=subwrd(result,4)</span></div><div><br /></div><div>-Tom</div><div><br /></div><div><br /></div><div class="gmail_extra"><br /><div class="gmail_quote">On Sun, Apr 26, 2015 at 8:39 AM, Mark Sponsler <span dir="ltr"><<a href="mailto:msponsler@comcast.net" target="_blank">msponsler@comcast.net</a>></span> wrote:<br /><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div>Hello everyone,</div>
<div>I'm struggling with maxloc. For whatever reason - I cannot get valid results out of it</div>
<div></div>
<div>I'm using a simple 0.5 X 0.5 deg grid.</div>
<div></div>
<div>I can find the max value just fine. It's the location of that value that is the issue.</div>
<div>Specifically selecting the correct record to read to obtain the x value (nxp3 in this example):</div>
<div></div>
<div>'d maxloc(max(htsgw,lat='lat1',lat='lat2'),lon='lon1',lon='lon2')'<br /> rec=sublin(result,nxp3)</div>
<div></div>
<div>The last valid line of data from maxloc looks like this (the next line is undefined values):</div>
<div> rec = MAXing. dim = 1, start = 146, end = 286<br /><br />Where is the actual grib point or longitude where the max value is located?</div>
<div>The results I'm getting are the same for every time step in the grib file.... dim = 1</div>
<div></div>
<div>Or should I be looking somewhere else?</div>
<div></div>
<div>Thanks for your help.</div>
<div></div>
<div>Here's the whole script:</div>
<div></div>
<div>********************************<br />* Define number of grid points to scan<br />********************************</div>
<div>lon1 = 120<br />lon2 = 255<br />lat1 = -5<br />lat2 = 65</div>
<div></div>
<div>nxp = (lon2-lon1)<br />* say ' nxp = 'nxp<br />nyp = (lat2-lat1)<br />* say ' nyp = 'nyp<br />* Grid dimensions are 0.5 x 0.5<br />nxp1 = nxp/0.5<br />* say 'nxp1 = 'nxp1<br />nyp1 = nyp/0.5<br />* say 'nyp1 = 'nyp1<br />nxp2 = math_int(nxp1)<br />nyp2 = math_int(nyp1)<br />* say 'nxp2 nyp2 = 'nxp2' 'nyp2<br /><br />********************************<br />* Find Max Longitude (x dim)<br />********************************<br />* There are 'nxp1' number of data points over the longitude range plus 1 for MAXLOCing<br />* and 1 for the result value line. So add 2. <br />********************************<br /> nxp3 = (nxp2 + 2)<br /> say 'nxp3 = 'nxp3<br /><br />'set gxout print'<br />'d maxloc(max(htsgw,lat='lat1',lat='lat2'),lon='lon1',lon='lon2')'<br /> rec=sublin(result,nxp3)<br /> say 'rec =
'rec<br /> xc=subwrd(rec,4)<br /> say 'Max height lon = 'xc<br /><br />********************************<br />* Find max Latitude (y dim)<br />********************************<br />* There are 'nyp1' number of data points over the long range plus 1 for MAXLOCing <br />* and 1 for the result value line. So add 2. <br />********************************<br /> nyp3 = (nyp2 + 2)<br /> say 'nyp3 = 'nyp3<br />'d maxloc(max(htsgw,lon='lon1',lon='lon2'),lat='lat1',lat='lat2')'<br /> rec=sublin(result,nyp3)<br /> say 'rec = 'rec<br /> yc=subwrd(rec,4)<br /> say 'Max height lat = 'yc<br /><br /> say 'location of max seas = 'xc' 'yc<br /><br />**************<br />* Draw Max Location<br />**************<br />'q gr2xy 'xc' 'yc<br /> rec2=sublin(result,1)<br /> say 'rec2 = 'rec2<br />
xc2 = subwrd(result,3)<br /> yc2 = subwrd(result,6)<br /> say 'Max Height coords = 'xc2' 'yc2</div>
<div></div>
<div><span style="font-size:small" size="2">Thanks,<br />Mark</span></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><div><br /></div>
</div></div>
<p style="margin-top: 2.5em; margin-bottom: 1em; border-bottom: 1px solid #000"></p><pre class="k9mail"><hr /><br />gradsusr mailing list<br />gradsusr@gradsusr.org<br /><a href="http://gradsusr.org/mailman/listinfo/gradsusr">http://gradsusr.org/mailman/listinfo/gradsusr</a><br /></pre></blockquote></div><br>
Thanks,<br>
Mark Sponsler</body></html>