Re: Looping through arrays [message #94123 is a reply to message #94122] |
Sat, 21 January 2017 10:46   |
wlandsman
Messages: 743 Registered: June 2000
|
Senior Member |
|
|
The main change I would suggest is to replace
image[*,*,k] = readfits(Files[index],hdr,/silent)
with
image[0,0,k] = readfits(Files[index],/silent)
http://www.idlcoyote.com/code_tips/asterisk.html
(I also omit the 'hdr' output parameter. You never use it so no need to create it.)
Loops in IDL are OK so long as you get a lot of work done on each iteration, which your program already does. --Wayne
On Saturday, January 21, 2017 at 1:05:24 PM UTC-5, Ben wrote:
> I work with defocused stellar images and use IDL to do the photometry. This is a great platform without which I don't think I could have done anything.
>
> But, I am self taught and have tended to just do what works and move on. Now, going back through through my code, I want to become a better person and clean up some of the Fortran-like inclusions.
>
> For example, over a night's observations I might have 50 sets, 5 images each of the same target and I loop through them like this:
>
> index = 0
> For m = 0, n_groups-1 do begin
> For k = 0, n_imagespergroup-1 do begin
> image[*,*,k] = readfits(Files(index,hdr,/silent)
> index += 1
> endfor ;k
>
> ;(do some stuff on this group of images}
>
> endfor ;m (go on to the next group)
>
> I'm wondering if there would be a more IDL-like way to accomplish the same thing. Does anyone have any ideas?
|
|
|