<div dir="ltr"><div>The &#39;bin_sum&#39; function was developed to process multiple satellite swaths onto a *rectilinear* grid. Each swath&#39;s latitude and longitude arrays are typically 2-dimensional (think, curvilinear). Hence: curvilinear ==&gt; 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 &#39;location finding&#39; algorith is used to determine the location of each input  data.<br><br></div><div>You have &#39;shoe-horned&#39; the &#39;bin-sum&#39; function to do just the opposite. Yes, it works BUT you are invoking the function for EACH &#39;fine resolution&#39; 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 (&#39;fine&#39;) 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, &#39;conservative remapping&#39; is what you want<br><br></div><div>So, your &#39;src&#39; (source) information is the rectilinear data.<br></div><div>The &#39;dst&#39; (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">&lt;<a href="mailto:yuqiangzhang.thu@gmail.com" target="_blank">yuqiangzhang.thu@gmail.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 link="blue" vlink="purple" lang="EN-US"><div><p class="MsoNormal"><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;">Hi All,<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;">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:&quot;Times New Roman&quot;,&quot;serif&quot;">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:&quot;Times New Roman&quot;,&quot;serif&quot;"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;">Bin_Sum<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;">“                      gbin [*][*] : numeric ,  <u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;">                        gknt [*][*] : integer ,  <u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;">                        <b>glon    [*] : numeric ,  <u></u><u></u></b></span></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;">                        glat     [*] : numeric ,  <u></u><u></u></span></b></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;">                        zlon     [*] : numeric ,  <u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;">                        zlat      [*] : numeric ,  <u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;">                        z          [*] : numeric    ”<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;">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:&quot;Times New Roman&quot;,&quot;serif&quot;"><u></u> <u></u></span></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;">;*****************************************************************<u></u><u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;">; Variables to hold binned quantities<u></u><u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;">;*****************************************************************<u></u><u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;">  gbin  = new ( (/nlat,mlon/), float )<u></u><u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;">  gknt  = new ( (/nlat,mlon/), integer)<u></u><u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;"><u></u> <u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;">  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:&quot;Arial&quot;,&quot;sans-serif&quot;">  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:&quot;Arial&quot;,&quot;sans-serif&quot;"><u></u> <u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;">  gbin_temp  = 0.0                      ; initialization<u></u><u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;">  gknt_temp  = 0<u></u><u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;"><u></u> <u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;">  printVarSummary(gbin_temp)<u></u><u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;">;*****************************************************************<u></u><u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;">;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:&quot;Arial&quot;,&quot;sans-serif&quot;"> do I = 0, mlon-1<u></u><u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;">  do J = 0, nlat-1<u></u><u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;">  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:&quot;Arial&quot;,&quot;sans-serif&quot;"><u></u> <u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;">  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:&quot;Arial&quot;,&quot;sans-serif&quot;">  end do<u></u><u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;">  print(&quot;zyq finish &quot;+ I)<u></u><u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;"> end do<u></u><u></u></span></b></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;">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:&quot;Times New Roman&quot;,&quot;serif&quot;"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;">Thanks for all your time! <u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;">Regards,<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;">Yuqiang <u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;">Regards,<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;">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>