<div dir="ltr"><div>The 'bin_sum' function was developed to process multiple satellite swaths onto a *rectilinear* grid. Each swath's latitude and longitude arrays are typically 2-dimensional (think, curvilinear). Hence: curvilinear ==> rectilinear. More specifically, the ndtooned function is used on the lat2d, lon2d and data array so, internally the data are treated as random. The reason for confining the output to a rectilinear grid is that a simple 'location finding' algorith is used to determine the location of each input data.<br><br></div><div>You have 'shoe-horned' the 'bin-sum' function to do just the opposite. Yes, it works BUT you are invoking the function for EACH 'fine resolution' grid point via the double do-loop. EACH invocation requires the underlying code to reinitialize. This imposes a huge penalty.<br><br>===<br></div><div>The procedure can go fron one rectilinear grid to another.<br></div><div>An example of going from an input high ('fine') resolution rectilinear grid to an output coarser rectilinear grid is<br><br><a href="http://www.ncl.ucar.edu/Applications/binning.shtml">http://www.ncl.ucar.edu/Applications/binning.shtml</a><br></div><div>Example 3<br></div><div><br>===<br><br></div><div>It may be best to use ESMF Regridding<br><br><a href="http://www.ncl.ucar.edu/Applications/ESMF.shtml">http://www.ncl.ucar.edu/Applications/ESMF.shtml</a><br><br></div><div>See: Example 9<br><br></div><div>Likely, 'conservative remapping' is what you want<br><br></div><div>So, your 'src' (source) information is the rectilinear data.<br></div><div>The 'dst' (destination) is the curvilinear grid.<br><br></div><div>Note: the weight file need be generated only once. Subsequently, you can reuse it.<br><br></div><div>Good Luck<br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 21, 2014 at 9:31 PM, Yuqiang Zhang <span dir="ltr"><<a href="mailto:yuqiangzhang.thu@gmail.com" target="_blank">yuqiangzhang.thu@gmail.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:12.0pt;font-family:"Times New Roman","serif"">Hi All,<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif""><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif"">I need to regrid the population data from fine rectilinear grid to coarse curvilinear grid. <u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif"">Procedure “bin_sum” will not work very efficiently for me, as <u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif""><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif"">Bin_Sum<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif"">“ gbin [*][*] : numeric , <u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif""> gknt [*][*] : integer , <u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif""> <b>glon [*] : numeric , <u></u><u></u></b></span></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:"Times New Roman","serif""> glat [*] : numeric , <u></u><u></u></span></b></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif""> zlon [*] : numeric , <u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif""> zlat [*] : numeric , <u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif""> z [*] : numeric ”<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif"">The targeted output “glon” and “glat” are one-dimension and need to be equals to the rightmost and leftmost dimension of the gbin. However, I need all of them at the same dimension (lat2d, lon2d). What I am doing right now is loop over each grid cell, and then apply the “bin_sum” procedure. It works fine, but just run very slowly. I copied part of my scripts down here:<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif""><u></u> <u></u></span></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:"Arial","sans-serif"">;*****************************************************************<u></u><u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:"Arial","sans-serif"">; Variables to hold binned quantities<u></u><u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:"Arial","sans-serif"">;*****************************************************************<u></u><u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:"Arial","sans-serif""> gbin = new ( (/nlat,mlon/), float )<u></u><u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:"Arial","sans-serif""> gknt = new ( (/nlat,mlon/), integer)<u></u><u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:"Arial","sans-serif""><u></u> <u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:"Arial","sans-serif""> gbin_temp = new ((/1, 1/), float )<u></u><u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:"Arial","sans-serif""> gknt_temp = new ((/1, 1/), integer)<u></u><u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:"Arial","sans-serif""><u></u> <u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:"Arial","sans-serif""> gbin_temp = 0.0 ; initialization<u></u><u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:"Arial","sans-serif""> gknt_temp = 0<u></u><u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:"Arial","sans-serif""><u></u> <u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:"Arial","sans-serif""> printVarSummary(gbin_temp)<u></u><u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:"Arial","sans-serif"">;*****************************************************************<u></u><u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:"Arial","sans-serif"">;loop over the all the latitude and longitude in target grid<u></u><u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:"Arial","sans-serif""> do I = 0, mlon-1<u></u><u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:"Arial","sans-serif""> do J = 0, nlat-1<u></u><u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:"Arial","sans-serif""> bin_sum(gbin_temp,gknt_temp, glon(J,I), glat(J,I), ndtooned(zlon2d), ndtooned(zlat2d), ndtooned(z) )<u></u><u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:"Arial","sans-serif""><u></u> <u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:"Arial","sans-serif""> gbin(J, I) = gbin_temp(0,0)<u></u><u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:"Arial","sans-serif""> end do<u></u><u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:"Arial","sans-serif""> print("zyq finish "+ I)<u></u><u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:"Arial","sans-serif""> end do<u></u><u></u></span></b></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif""><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif"">Any one has the idea to improve this? <u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif""><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif"">Thanks for all your time! <u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif""><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif"">Regards,<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif"">Yuqiang <u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif""><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif""><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif""><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif""><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif"">Regards,<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif"">Yuqiang<u></u><u></u></span></p><p class="MsoNormal"><u></u> <u></u></p></div></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>