<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'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't appear you are doing this, so I'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"><<a href="mailto:313695096@qq.com" target="_blank">313695096@qq.com</a>></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 " ind_resolve","maxind" and "wrf_user_ij_to_ll" 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 "$NCARG_ROOT/lib/ncarg/<wbr>nclscripts/csm/gsn_code.ncl" <br>load "$NCARG_ROOT/lib/ncarg/<wbr>nclscripts/csm/gsn_csm.ncl" <br>load "$NCARG_ROOT/lib/ncarg/<wbr>nclscripts/wrf/WRFUserARW.ncl"</div>
<div>begin<br>;<br>; The WRF ARW input file. <br>; This needs to have a ".nc" appended, so just do it.<br> a = addfile("/backup/hl/z_20min/<wbr>wrfout_d03_2010-08-11_00:00:<wbr>00"+".nc","r") </div>
<div><br>; We generate plots, but what kind do we prefer?<br>; type = "eps"<br> type = "pdf"<br>; type = "ps"<br>; type = "ncgm"<br> wks = gsn_open_wks(type,"plt_<wbr>Cloudgraup_20min_20100811")<br> ;colors = (/"white","black","white","<wbr>royal blue","light sky blue",\<br> ; "powder blue","light sea green","pale green","wheat","brown",\<br> ; "pink"/)<br> gsn_define_<wbr>colormap(wks,"<wbr>BlAqGrYeOrRevi200") ; 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> = "REAL-TIME WRF"</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 = "Lambert"<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,"times",-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("Working on time: " + 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,"QGRAUP"))<br> qi = wrf_user_getvar(a,"QGRAUP",it )<br> qi = qi*1000.<br> <a href="mailto:qi@units" target="_blank">qi@units</a> = "g/kg" <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("X/Y location is: "+ loc1)<br> <br> loc2=wrf_user_ll_to_ij(a,112.<wbr>0,38.0,tes)<br> ; print("X/Y location is: "+ 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> = " Level -10 - -20 ~S~o~N~C " <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("qi"))<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' 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>;>============================<wbr>==============================<wbr>==<<br>; add map<br>;>----------------------------<wbr>------------------------------<wbr>--<</div>
<div> <br> shp_name2 = "/public/home/huanglei/map/<wbr>shaanxi_city_l.shp"</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> = "black"<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> = "Blue"<br> txdum1 =gsn_add_text(wks, plot, "Xian", 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 = "/public/home/huanglei/z_data/<wbr>20100811graup.txt"<br> write_table(output_file,"w",[<wbr>/times,lon,lat/],"%s%9.4f%9.<wbr>4f")<br>end<br></div></div>
<div><br></div>
<div><span style="LINE-HEIGHT:23px;FONT-FAMILY:'lucida Grande',Verdana,'Microsoft YaHei'"> 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>