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

Home » Public Forums » archive » How to make IDL faster
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
How to make IDL faster [message #36775] Tue, 28 October 2003 21:35 Go to next message
parkkw is currently offline  parkkw
Messages: 4
Registered: October 2003
Junior Member
Hello
I write message first time.
If I want to compare trmm satellite data with ground point data,
I used to this line.

geo(0,207,2985) : trmm latitute
geo(1,*,*) : trmm longitute
lat : ground location(latitute)
lon : ground location(longitute)
rain : automatic weather system rainfall data
highf(0,207,2985) : trmm brightness temperature data

for i=0,207 do begin
for j=1200,1700 do begin
for k=0,di(0)-1 do begin

if geo(0,i,j) gt lat(k)-0.04 and geo(0,i,j) lt lat(k)+0.04 and $
geo(1,i,j) gt lon(k)-0.04 and geo(1,i,j) lt lon(k)+0.04 then begin
printf,lun3,loc(k),lon(k),lat(k),rain1(k),rain(k),highf(0,i, j)
endif

endfor
endfor
endfor

When I caculate 26 trmm data, I wait almost 2hour.
How can I change this program?
Help me.
Re: How to make IDL faster [message #36828 is a reply to message #36775] Sun, 02 November 2003 09:17 Go to previous messageGo to next message
Robert Moss is currently offline  Robert Moss
Messages: 74
Registered: February 1996
Member
Yes, but not as much as using only one character variable names. :P

trouble wrote:
> MKatz843@onebox.com (M. Katz) wrote in message news:<4a097d6a.0310291118.2ceed6d5@posting.google.com>...
>
>> This is minor, but you can get a small speed advantage by taking out
>> the begin...end where possible. <snip>
>>
>
> This is truly scraping the barrel. I guess cutting out all white-space
> might help too??
Re: How to make IDL faster [message #36844 is a reply to message #36775] Fri, 31 October 2003 18:49 Go to previous messageGo to next message
the_cacc is currently offline  the_cacc
Messages: 104
Registered: October 2001
Senior Member
MKatz843@onebox.com (M. Katz) wrote in message news:<4a097d6a.0310291118.2ceed6d5@posting.google.com>...
>
> This is minor, but you can get a small speed advantage by taking out
> the begin...end where possible. <snip>
>

This is truly scraping the barrel. I guess cutting out all white-space
might help too??
Re: How to make IDL faster [message #36862 is a reply to message #36775] Wed, 29 October 2003 16:35 Go to previous messageGo to next message
parkkw is currently offline  parkkw
Messages: 4
Registered: October 2003
Junior Member
parkkw@mail1.pknu.ac.kr (Park Kyung Won) wrote in message news:<eceee805.0310282135.5448e3af@posting.google.com>...
> Hello
> I write message first time.
> If I want to compare trmm satellite data with ground point data,
> I used to this line.
>
> geo(0,207,2985) : trmm latitute
> geo(1,*,*) : trmm longitute
> lat : ground location(latitute)
> lon : ground location(longitute)
> rain : automatic weather system rainfall data
> highf(0,207,2985) : trmm brightness temperature data
>
> for i=0,207 do begin
> for j=1200,1700 do begin
> for k=0,di(0)-1 do begin
>
> if geo(0,i,j) gt lat(k)-0.04 and geo(0,i,j) lt lat(k)+0.04 and $
> geo(1,i,j) gt lon(k)-0.04 and geo(1,i,j) lt lon(k)+0.04 then begin
> printf,lun3,loc(k),lon(k),lat(k),rain1(k),rain(k),highf(0,i, j)
> endif
>
> endfor
> endfor
> endfor
>
> When I caculate 26 trmm data, I wait almost 2hour.
> How can I change this program?
> Help me.

Thank you for your answer.
I have mistake.

geo(0,*,*) : trmm latitute
geo(1,*,*) : trmm longitute
lat : ground location(latitute)
lon : ground location(longitute)
rain : automatic weather system rainfall data
highf(0,207,2985) : trmm brightness temperature data

k : number of ground station
Re: How to make IDL faster [message #36865 is a reply to message #36775] Wed, 29 October 2003 13:28 Go to previous messageGo to next message
Ken Knapp is currently offline  Ken Knapp
Messages: 14
Registered: April 2003
Junior Member
My two cents:
Only loop over the rainfall data (k). Use rebin and reform to create
large (and constant) arrays, then simply difference the arrays to find
where the lat and lon matchup:

nelem = 207
nscan = 2985

trmmlat = reform(geo(0,*,*))
trmmlon = reform(geo(1,*,*))
trmmtb = reform(highf(0,*,*))

for k=0,di(0)-1 do begin
;remap the 1 lat value to match the trmmlat coordinates
lat = rebin(reform([lat(k)]),1,1),nelem,nscan)
lon = rebin(reform([lon(k)]),1,1),nelem,nscan)
match = where(abs(lat-trmmlat) lt 0.04 and $
abs(lon-trmmlon) lt 0.04,nmatch)
if (nmatch gt 0) then begin
for im=0,nmatch-1 do begin
print,loc(k),lon(k),lat(k),rain1(k),$
rain(k),trmmtb(match(im))
endfor
endif
endfor


Park Kyung Won wrote:

> Hello
> I write message first time.
> If I want to compare trmm satellite data with ground point data,
> I used to this line.
>
> geo(0,207,2985) : trmm latitute
> geo(1,*,*) : trmm longitute
> lat : ground location(latitute)
> lon : ground location(longitute)
> rain : automatic weather system rainfall data
> highf(0,207,2985) : trmm brightness temperature data
>
> for i=0,207 do begin
> for j=1200,1700 do begin
> for k=0,di(0)-1 do begin
>
> if geo(0,i,j) gt lat(k)-0.04 and geo(0,i,j) lt lat(k)+0.04 and $
> geo(1,i,j) gt lon(k)-0.04 and geo(1,i,j) lt lon(k)+0.04 then begin
> printf,lun3,loc(k),lon(k),lat(k),rain1(k),rain(k),highf(0,i, j)
> endif
>
> endfor
> endfor
> endfor
>
> When I caculate 26 trmm data, I wait almost 2hour.
> How can I change this program?
> Help me.
Re: How to make IDL faster [message #36867 is a reply to message #36775] Wed, 29 October 2003 11:42 Go to previous messageGo to next message
mchinand is currently offline  mchinand
Messages: 66
Registered: September 1996
Member
In article <4a097d6a.0310291118.2ceed6d5@posting.google.com>,
M. Katz <MKatz843@onebox.com> wrote:
>
> if geo(0,i,j) gt lat(k)-0.04 and geo(0,i,j) lt lat(k)+0.04 and $
> geo(1,i,j) gt lon(k)-0.04 and geo(1,i,j) lt lon(k)+0.04
>
> to this
>
> if (abs(geo(0,i,j) - lat(k)) LT 0.04) and $
> (abs(geo(1,i,j) - lon(k)) LT 0.04) then . . .
>
> Here I am thinking that you minimize the number of times you have to
> go to the geo() array and get the (0,i,j) element.
>
> M. Katz


Do both conditional clauses always get evaluated, even if the first one is false? If so,
it might be faster to add a second if statement:

if (abs(geo(0,i,j) - lat(k)) LT 0.04) then $
if (abs(geo(1,i,j) - lon(k)) LT 0.04) then print, loc(k), etc...

I haven't tried this on a large dataset, but it might be worth investigating.

--Mike


--
Michael Chinander
m-chinander@uchicago.edu
Department of Radiology
University of Chicago
Re: How to make IDL faster [message #36868 is a reply to message #36775] Wed, 29 October 2003 11:18 Go to previous messageGo to next message
MKatz843 is currently offline  MKatz843
Messages: 98
Registered: March 2002
Member
> for i=0,207 do begin
> for j=1200,1700 do begin
> for k=0,di(0)-1 do begin
>
> if geo(0,i,j) gt lat(k)-0.04 and geo(0,i,j) lt lat(k)+0.04 and $
> geo(1,i,j) gt lon(k)-0.04 and geo(1,i,j) lt lon(k)+0.04 then begin
> printf,lun3,loc(k),lon(k),lat(k),rain1(k),rain(k),highf(0,i, j)
> endif
>
> endfor
> endfor
> endfor
>
> How can I change this program?
> Help me.

This is minor, but you can get a small speed advantage by taking out
the begin...end where possible. For example your code could be

for i=0,207 do $
for j=1200,1700 do $
for k=0,di(0)-1 do $
if geo(0,i,j) gt lat(k)-0.04 and geo(0,i,j) lt lat(k)+0.04 and $
geo(1,i,j) gt lon(k)-0.04 and geo(1,i,j) lt lon(k)+0.04 $
then printf,lun3,loc(k),lon(k),lat(k),rain1(k),rain(k),highf(0,i, j)

It makes a small difference but it can help. You have to use
begin...end only when there is more than one line of code to execute.
Here, you can string them together.

You could change

if geo(0,i,j) gt lat(k)-0.04 and geo(0,i,j) lt lat(k)+0.04 and $
geo(1,i,j) gt lon(k)-0.04 and geo(1,i,j) lt lon(k)+0.04

to this

if (abs(geo(0,i,j) - lat(k)) LT 0.04) and $
(abs(geo(1,i,j) - lon(k)) LT 0.04) then . . .

Here I am thinking that you minimize the number of times you have to
go to the geo() array and get the (0,i,j) element.

M. Katz
Re: How to make IDL faster [message #36916 is a reply to message #36828] Mon, 03 November 2003 10:37 Go to previous message
the_cacc is currently offline  the_cacc
Messages: 104
Registered: October 2001
Senior Member
Robert Moss <rmmoss@cox.net> wrote in message news:<J_apb.135922$k74.131604@lakeread05>...
> Yes, but not as much as using only one character variable names. :P
>

Heck with it, recode in assembler.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Solving nonlinear equations
Next Topic: vector t-test?

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

Current Time: Wed Oct 08 14:55:38 PDT 2025

Total time taken to generate the page: 0.00434 seconds