<div dir="ltr">Hi Grace,<div><br></div><div>One thing that is unusual (and confusing) about the wrf_user_ll_to_ij and wrf_user_ij_to_ll routines is that they use Fortran 1-based indexing, rather than NCL&#39;s 0-based indexing.  So, when you get the result from wrf_user_ll_to_ij, you need to subtract 1 from that result.  When you use wrf_user_ij_to_ll, you need to add 1 to the i,j arguments.  At a first glance at your script, it doesn&#39;t appear you are doing this, so I&#39;d try that first and see if that helps.  </div><div><br></div><div>Bill</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 26, 2016 at 9:24 PM, 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"><div> Hi:</div>
<div>       All,I am trying to find out the lat and lon location of the max graup of wrfout data,I have used the funtion &quot; ind_resolve&quot;,&quot;maxind&quot; and &quot;wrf_user_ij_to_ll&quot; according to the web examples.</div>
<div>       But after I compared the output data with the contour plot that I ploted ,them are not <span>corresponding.</span></div>
<div><span>       I thought maybe I confused the lat and lon ,but after I switch it ,the output data are not <span>correspond to the plots too.</span></span></div>
<div><span><span>       I can not figure out where the problem is? I think maybe it is because of the zoom ?</span></span></div>
<div><span><span>       But I do not know how to fix it,can you guys fix this?</span></span></div>
<div> </div>
<div><br></div>
<div>This is my script:</div>
<div>
<div>;   Example script to produce plots for a WRF real-data run,<br>;   with the ARW coordinate dynamics option.</div>
<div>load &quot;$NCARG_ROOT/lib/ncarg/<wbr>nclscripts/csm/gsn_code.ncl&quot; <br>load &quot;$NCARG_ROOT/lib/ncarg/<wbr>nclscripts/csm/gsn_csm.ncl&quot; <br>load &quot;$NCARG_ROOT/lib/ncarg/<wbr>nclscripts/wrf/WRFUserARW.ncl&quot;</div>
<div>begin<br>;<br>; The WRF ARW input file.  <br>; This needs to have a &quot;.nc&quot; appended, so just do it.<br>  a = addfile(&quot;/backup/hl/z_20min/<wbr>wrfout_d03_2010-08-11_00:00:<wbr>00&quot;+&quot;.nc&quot;,&quot;r&quot;)            </div>
<div><br>; We generate plots, but what kind do we prefer?<br>;  type = &quot;eps&quot;<br> type = &quot;pdf&quot;<br>; type = &quot;ps&quot;<br>; type = &quot;ncgm&quot;<br>  wks = gsn_open_wks(type,&quot;plt_<wbr>Cloudgraup_20min_20100811&quot;)<br>   ;colors = (/&quot;white&quot;,&quot;black&quot;,&quot;white&quot;,&quot;<wbr>royal blue&quot;,&quot;light sky blue&quot;,\<br>           ;  &quot;powder blue&quot;,&quot;light sea green&quot;,&quot;pale green&quot;,&quot;wheat&quot;,&quot;brown&quot;,\<br>            ; &quot;pink&quot;/)<br>             gsn_define_<wbr>colormap(wks,&quot;<wbr>BlAqGrYeOrRevi200&quot;)   ; overwrite the .hluresfile color map<br><br>; Set some basic resources<br>  res = True<br>  <a href="mailto:res@MainTitle" target="_blank">res@MainTitle</a> = &quot;REAL-TIME WRF&quot;</div>
<div>  mpres  = True  ; Map resources<br>  <a href="mailto:mpres@mpOutlineOn" target="_blank">mpres@mpOutlineOn</a> = False  ; Turn off map outlines<br>  <a href="mailto:mpres@mpFillOn" target="_blank">mpres@mpFillOn</a>    = False  ; Turn off map fill<br>  <a href="mailto:mpres@mpGridAndLimbOn" target="_blank">mpres@mpGridAndLimbOn</a> = True<br> ;res@mpProjection          = &quot;Lambert&quot;<br>  pltres = True ; Plot resources<br>  <a href="mailto:pltres@PanelPlot" target="_blank">pltres@PanelPlot</a>  = True   ; Tells wrf_map_overlays not to remove overlays</div>
<div><br>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<wbr>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<wbr>;;;;<br>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<wbr>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<wbr>;;;;</div>
<div>; What times and how many time steps are in the data set?<br>  times = wrf_user_getvar(a,&quot;times&quot;,-1)  ; get all times in the file<br>  ntimes = dimsizes(times)         ; number of times in the file<br> lat = new(ntimes,float)  ;creat new variable to store the lat of the max qi<br> lon = new(ntimes,float)<br>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<wbr>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<wbr>;;;;</div>
<div>  do it =0, ntimes-1,1        ; TIME LOOP</div>
<div>    print(&quot;Working on time: &quot; + times(it) )<br>    <a href="mailto:res@TimeLabel" target="_blank">res@TimeLabel</a> = times(it)   ; Set Valid time to use on plots<br>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<wbr>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<wbr>;;;;<br>; First get the variables we will need        <br>    if(isfilevar(a,&quot;QGRAUP&quot;))<br>          qi = wrf_user_getvar(a,&quot;QGRAUP&quot;,it )<br>      qi = qi*1000.<br>      <a href="mailto:qi@units" target="_blank">qi@units</a> = &quot;g/kg&quot;   <br>         ; qiav = dim_avg_n_Wrap(qi, 0)<br>    end if<br>   tes=True<br>   <a href="mailto:tes@returnInt" target="_blank">tes@returnInt</a> = False<br>   loc1=wrf_user_ll_to_ij(a,105.<wbr>0,32.0,tes)<br>   ;print(&quot;X/Y location is: &quot;+ loc1)<br>   <br>   loc2=wrf_user_ll_to_ij(a,112.<wbr>0,38.0,tes)<br>  ; print(&quot;X/Y location is: &quot;+ loc2)<br>   x_start = 15<br>   x_end   = 227<br>   y_start = 71<br>   y_end   = 274</div>
<div>     level = 13</div>
<div>      display_level = level + 2<br>      opts = res<br>      <a href="mailto:opts@cnFillOn" target="_blank">opts@cnFillOn</a>         = True<br>      <a href="mailto:opts@gsnSpreadColors" target="_blank">opts@gsnSpreadColors</a>  = False<br>      <a href="mailto:opts@ContourParameters" target="_blank">opts@ContourParameters</a>       = (/ 1, 5, 0.5 /)<br>      <a href="mailto:opts@PlotLevelID" target="_blank">opts@PlotLevelID</a>      = &quot; Level -10 - -20 ~S~o~N~C &quot; <br>          <a href="mailto:opts@gsnDraw" target="_blank">opts@gsnDraw</a>      =  False                  <br>      <a href="mailto:opts@gsnFrame" target="_blank">opts@gsnFrame</a>     =  False</div>
<div><br>      if (isvar(&quot;qi&quot;))<br>        qis  = qi(level + (/0,1,2,3,4,5,6/),:,:)<br>        qisum = dim_sum_n_Wrap(qis, 0)<br>        mpres1 = True<br>        <a href="mailto:mpres1@ZoomIn" target="_blank">mpres1@ZoomIn</a> = True<br>        <a href="mailto:mpres1@Xstart" target="_blank">mpres1@Xstart</a> = x_start<br>        <a href="mailto:mpres1@Ystart" target="_blank">mpres1@Ystart</a> = y_start<br>        <a href="mailto:mpres1@Xend" target="_blank">mpres1@Xend</a>   = x_end<br>        <a href="mailto:mpres1@Yend" target="_blank">mpres1@Yend</a>   = y_end<br>      ;  printVarSummary(qisum)<br>        qi_zoom = qisum(y_start:y_end,x_start:x_<wbr>end)<br>       ; printVarSummary(qi_zoom)<br>       ;;;;;;;convert to 1D;;;;;;;;<br>        qi_zoom1D  = ndtooned(qi_zoom)<br>        dsizes_a = dimsizes(qi_zoom)<br>      ;;;;;;resolve the 1D indices back to their original 2D arry.;;;<br>        indices = ind_resolve(maxind(qi_zoom1D),<wbr>dsizes_a)<br>       ; print(indices)<br>        ilatlon = wrf_user_ij_to_ll(a, indices(0,1),indices(0,0),<wbr>True)  ; select the latitude index where the X array is at its&#39; maximum <br>        lon(it)= ilatlon(0)<br>        lat(it)= ilatlon(1)<br>                              <wbr>        <br>        contour = wrf_contour(a,wks,qi_zoom,<wbr>opts)<br>        plot = wrf_map_overlays(a,wks,(/<wbr>contour/),pltres,mpres1)</div>
<div>        delete(contour)<br>      end if<br>;&gt;============================<wbr>==============================<wbr>==&lt;<br>;                      add  map<br>;&gt;----------------------------<wbr>------------------------------<wbr>--&lt;</div>
<div>     <br>  shp_name2    = &quot;/public/home/huanglei/map/<wbr>shaanxi_city_l.shp&quot;</div>
<div>  prres=True<br>  <a href="mailto:prres@gsLineThicknessF" target="_blank">prres@gsLineThicknessF</a> = 1.0       <br>  <a href="mailto:prres@gsLineColor" target="_blank">prres@gsLineColor</a> = &quot;black&quot;<br>  plotcn3 = gsn_add_shapefile_polylines(<wbr>wks,plot,shp_name2,prres)</div>
<div>   txres2  = True<br>   <a href="mailto:txres2@txFont" target="_blank">txres2@txFont</a>  = 10<br>   <a href="mailto:txres2@txFontHeightF" target="_blank">txres2@txFontHeightF</a> =0.01<br>   <a href="mailto:txres2@txFontColor" target="_blank">txres2@txFontColor</a> = &quot;Blue&quot;<br>   txdum1 =gsn_add_text(wks, plot, &quot;Xian&quot;, 108.93,34.27, txres2)</div>
<div>  draw(plot)       ; This will draw the map and the shapefile outlines.<br>  frame(wks)<br>   delete(opts)</div>
<div> </div>
<div>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<wbr>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<wbr>;;;;</div>
<div>  end do        ; END OF TIME LOOP     <br> <br> output_file = &quot;/public/home/huanglei/z_data/<wbr>20100811graup.txt&quot;<br> write_table(output_file,&quot;w&quot;,[<wbr>/times,lon,lat/],&quot;%s%9.4f%9.<wbr>4f&quot;)<br>end<br></div></div>
<div><br></div>
<div><span style="LINE-HEIGHT:23px;FONT-FAMILY:&#39;lucida Grande&#39;,Verdana,&#39;Microsoft YaHei&#39;"> How can I slove the problem?</span></div>
<div></div><br>______________________________<wbr>_________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/<wbr>mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>