comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Lonlat2reg.pro vs. Grid program
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Lonlat2reg.pro vs. Grid program [message #56401] Tue, 23 October 2007 05:41
Nick[1] is currently offline  Nick[1]
Messages: 10
Registered: May 2007
Junior Member
Thank you, Peter.
I could solve the problems because of you.
As you said, I changed my code and it really worked!
Thank you very much.

Cheers, Nick
Re: Lonlat2reg.pro vs. Grid program [message #56402 is a reply to message #56401] Tue, 23 October 2007 02:38 Go to previous message
Peter Albert is currently offline  Peter Albert
Messages: 3
Registered: April 2007
Junior Member
Hi Nick,

it has been quite a while since I wrote lonlat2reg, and it has even
been quite a while since I quit using IDL, so my comments here should
be taken with a pinch of salt. However, when looking at the source
code, I am pretty sure that your problem has to do with setting dlat
to a negative number. In the end, this leads to negative elements in
the one-dimensional index variable "s" which is sent to histogram, and
in turn to negative index values "iy" which point into the output
field. I'd guess that half of your Average_value1 is just zero (or
no_data), but again, I can't test this. If you could do a test with
lat0 = -90.0 and dlat = 1.0, things could possibly be better (but
please be aware that in this case you either have to modify your code,
too, or swap one of the two average arrays: "your" glat[0,0] is 89.5,
the glat[0,0] as returned from lonlat2reg would be -89.5; with other
words, glat = findgen(180) - 89.5 should be o.k.)


Cheers,

Peter
On 20 Okt., 11:25, Nick <jungbin...@hotmail.com> wrote:
> 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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Geotiff coor
Next Topic: scatter plot...

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 23:19:00 PDT 2025

Total time taken to generate the page: 0.32041 seconds