<div dir="ltr">To get the max index out of a 2D array, you need to use a combination of ndtooned, maxind, and ind_resolve.<div><br></div><div>If &quot;qi&quot; is the variable you want the maximum from, then here&#39;s a three-step process. </div>
<div><br></div><div>    dims = dimsizes(qi)   ; 1D array containing the three dimension sizes </div><div><br></div><div><div>    qi1d = ndtooned(qi(it,:,:))   ; convert to one-dimensional array</div></div><div><div>    ii = maxind(qi1d)               ; get index where first maximum value occurs</div>
</div><div><div>    ij= ind_resolve(ii,dims)      ; resolve back to original 2D array index locations</div></div><div><br></div><div>The &quot;ij&quot; should be a 1 x 2 array, where ij(0,0) is the index of the middle dimension, and ij(0,1) is the index of the rightmost dimension of &quot;qi&quot;</div>
<div><br></div><div>Here&#39;s one-step process you can use:</div><div><br></div><div><div>    ij= ind_resolve(maxind(ndtooned(qi(it,:,:))),dims(1:2))</div></div><div><br></div><div>You can print the results with:</div><div>
<br></div><div>    print(&quot;max qi = &quot; + qi(it,ij(0,0),ij(0,1)) + &quot; at indexes &quot; + ij(0,0) + &quot;,&quot; + ij(0,1))</div><div><br></div><div>To then get the lat,lon location of this ij location, use wrf_user_ij_to_ll</div>
<div><br></div><div>







<p class="">    latlon = wrf_user_ij_to_ll(a, ij(0,0), ij(0,1), True)</p><p class="">    print(&quot;lon location is: &quot; + latlon(0))</p><p class="">    print(&quot;lat location is: &quot; + latlon(1))<br><br></p><p class="">
--Mary</p></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jul 1, 2014 at 2:25 AM, grace <span dir="ltr">&lt;<a href="mailto:313695096@qq.com" target="_blank">313695096@qq.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><font size="3"><span style="line-height:24px">Hi,all</span></font><div><font size="3"><span style="line-height:24px">  I have calculated the max Qgraup of each time from the wrfout data with the following program,</span></font></div>
<div><font size="3"><span style="line-height:24px">but how can I know  the (i,j)or (lat,lon) of the max <span style="line-height:0px">‍</span></span></font><span style="font-size:medium;line-height:24px">Qgraup of each time?<span style="line-height:0px">‍</span></span></div>
<div><span style="font-size:medium;line-height:24px">any information will be appreciated!</span></div><div><font size="3"><span style="line-height:24px"><br></span></font></div><div><font size="3"><div>  ascii_file = &quot;shishidataGRAUP1B333.txt&quot;</div>
<div>  str = new(ntimes, &quot;string&quot;)</div><div><span style="line-height:0px">‍</span>  do it =0, ntimes-1,1        ; TIME LOOP</div><div style="line-height:24px"><br></div><div style="line-height:24px">    print(&quot;Working on time: &quot; + times(it) )</div>
<div style="line-height:24px">    res@TimeLabel = times(it)   ; Set Valid time to use on plots</div><div style="line-height:24px"><br></div><div style="line-height:24px">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</div>
<div style="line-height:24px">; First get the variables we will need        </div><div style="line-height:24px">    if(isfilevar(a,&quot;QGRAUP&quot;))</div><div style="line-height:24px">      qi = wrf_user_getvar(a,&quot;QGRAUP&quot;,it)</div>
<div style="line-height:24px">      qi = qi*1000.</div><div style="line-height:24px">      qi@units = &quot;g/kg&quot; </div><div style="line-height:24px"><span style="white-space:pre-wrap">        </span>  qis=dim_max_n_Wrap(qi(13:15,:,:),0)</div>
<div style="line-height:24px">    end if</div><div style="line-height:24px"><span style="white-space:pre-wrap">        </span>;print(qis)</div><div style="line-height:24px"><span style="white-space:pre-wrap">        </span>printVarSummary(qis)</div>
<div style="line-height:24px">    wmax1 = dim_max_n_Wrap(qis(:,:),0)</div><div style="line-height:24px"><span style="white-space:pre-wrap">        </span>;print(wmax1)</div><div style="line-height:24px"><span style="white-space:pre-wrap">        </span>printVarSummary(wmax1)</div>
<div style="line-height:24px">    wmax2 = dim_max_n_Wrap(qis,0)</div><div style="line-height:24px"><span style="white-space:pre-wrap">        </span>;print(wmax2)</div><div style="line-height:24px"><span style="white-space:pre-wrap">        </span>printVarSummary(wmax2)</div>
<div style="line-height:24px">    wmax=max(wmax2)<span style="line-height:0px">‍</span></div><div> str(it) = sprintf(&quot;%12.8f&quot;, wmax)<span style="line-height:0px">‍</span></div></font></div><br>_______________________________________________<br>

ncl-talk mailing list<br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>