[ncl-talk] Regridding from fine Rectilinear data to coarse curvilinear grid

Yuqiang Zhang yuqiangzhang.thu at gmail.com
Tue Oct 21 21:31:22 MDT 2014


Hi All,

 

I need to regrid the population data from fine rectilinear grid to coarse
curvilinear grid. 

Procedure "bin_sum" will not work very efficiently for me, as 

 

Bin_Sum

"                      gbin [*][*] : numeric ,  

                        gknt [*][*] : integer ,  

                        glon    [*] : numeric ,  

                        glat     [*] : numeric ,  

                        zlon     [*] : numeric ,  

                        zlat      [*] : numeric ,  

                        z          [*] : numeric    "

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:

 

;*****************************************************************

; Variables to hold binned quantities

;*****************************************************************

 gbin  = new ( (/nlat,mlon/), float )

  gknt  = new ( (/nlat,mlon/), integer)

 

  gbin_temp = new ((/1, 1/), float )

  gknt_temp = new ((/1, 1/), integer)

 

  gbin_temp  = 0.0                      ; initialization

  gknt_temp  = 0

 

  printVarSummary(gbin_temp)

;*****************************************************************

;loop over the all the latitude and longitude in target grid

do I = 0, mlon-1

  do J = 0, nlat-1

  bin_sum(gbin_temp,gknt_temp, glon(J,I), glat(J,I), ndtooned(zlon2d),
ndtooned(zlat2d), ndtooned(z) )

 

  gbin(J, I) = gbin_temp(0,0)

  end do

  print("zyq finish "+ I)

end do

 

Any one has the idea to improve this? 

 

Thanks for all your time! 

 

Regards,

Yuqiang 

 

 

 

 

Regards,

Yuqiang

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20141021/b21a9fdf/attachment.html 


More information about the ncl-talk mailing list