Re: Simple? problem [message #30073 is a reply to message #30072] |
Tue, 09 April 2002 10:52   |
Jaco van Gorkom
Messages: 97 Registered: November 2000
|
Member |
|
|
"Ivan Valtchanov" <ivanv@discovery.saclay.cea.fr> wrote in message
news:20020409174917.78c62461.ivanv@discovery.saclay.cea.fr.. .
< skipped code of not quite so simple problem ... >
> This is obviously quite unoptimised - two cycles etc. Do you have any
ideas, references or do you know if it is already solved in IDL?
>
> I have looked for something similar in David Fanning pages and IDL
astronomical libraries but I couldn't find something to adapt, maybe I have
missed it?
Well, I would start by reading the dimensional juggling tutorial on David's
pages
a few times. Then read it again, and practice with the examples.
A nice compromise between the speed penalty for using loops and excessive
memory use for array operations is usually found by vectorizing the inner
loop
only. Thus FOR j=... until ENDFOR could be replaced by something along the
lines of:
ygi = findgen(ny)/ny
dy = rebin(y, 1000, ny, /sample) - rebin(reform(ygi, 1, ny), 1000, ny,
/sample)
dr = rebin(dx^2, 1000, ny, /sample) + dy^2
arg = dr^2 / rebin(w2, 1000, ny, /sample) > -20.0
image[i,0] = total(exp(arg), 1) ; the total over only the first dimension
(1000)
Probably I mixed up all the rebin statements here, since I have not read the
juggling tutorial in months. But thirty minutes of toying around on the
command
line with help statements usually gets the syntax right.
Jaco
P.S.: It is quite possible that I have misunderstood the meaning or purpose
of
your code. Maybe you could describe in words exactly what you want to
accomplish?
|
|
|