Lonlat2reg.pro vs. Grid program [message #56421] |
Sat, 20 October 2007 02:25 |
Nick[1]
Messages: 10 Registered: May 2007
|
Junior Member |
|
|
Hello, thankful users.
As you know, lonlat2reg.pro is a very useful grid program.
Yesterday I compared the result from lonlat2reg with code which I
made.
I anticipated that these results would be the same, but weren't.
Why are they different? Could you please let me know?
My code is like this..
;=====lonlat2reg
result = lonlat2reg(value,lon,lat, lon0=-180.,lat0=90.,dlon=1.,
dlat=-1., nlon=360., nlat=180.)
Average_value1 = result.avg(*,*)
;=====My code
glon = findgen(360) - 179.5
glat = -findgen(180) + 89.5
for k=0, 179 do begin
for j=0, 359 do begin
idx = where(lon lt glon(j)+0.5 and lon ge glon(j)-0.5 and lat le
glat(k)+0.5 and lat gt glat(k)-0.5, nn)
if nn ge 1 then begin
S_value(j,k) = S_value(j,k) + total(value(idx),/nan)
N_value(j,k) = N_value(j,k) + nn
endif
endfor ;j
endfor ;k
Average_value2 = S_value / N_value
My code is really slow, but I think it is easier understandable than
lonlat2reg.pro
So I was supposed to use lonlat2reg.pro if Average_value1 and
Average_value2 would be the same.
Thank you for your attention, Nick
|
|
|