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

Home » Public Forums » archive » help needed to make the program run faster
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: help needed to make the program run faster [message #93622 is a reply to message #93621] Fri, 09 September 2016 02:11 Go to previous messageGo to previous message
Markus Schmassmann is currently offline  Markus Schmassmann
Messages: 129
Registered: April 2016
Senior Member
On 09/09/2016 08:04 AM, sid wrote:
> I need to read 500 fits files and do analysis for all this,
>
> So im doing like this,
>
> file=file_search('*.fts')
> nn=n_elements(file)
> for ii=0,nn-1 do begin
> img=readfits(file(ii),h)
> ----
> ---some analysis----
>
> endfor
> end
>
> in the analysis part also i have some for loops so the program takes so much time to process this job.
>
> So can anybody let me know whether any other faster methods are there to do this.
Hi Sid,

- use PROFILER and/or TIC & TOC to figure out what part of your code is slow
- remove loops by vectorising
- if all fits-images have the same dimensions and header structures you
can put all into one array and then do analysis on all images at once, e.g.:

file=file_search('*.fts')
nn=n_elements(file)
img0=readfits(file(0),h0)
img=fltarr([size(img0,/dim),nn])
img[*,*,0]=temporary(img0)
h=strarr([size(h0,/dim),nn])
h[*,0]=temporary(h0)
for i=1,nn-1 do begin
img[*,*,i]=readfits(file(i),hi)
h[*,i]=hi
endfor

---some analysis----

- not knowing what analysis you do it is difficult to tell how to speed
it up, but using, WHERE, SORT, UNIQ, HISTOGRAM, VALUE_LOCATE and the
like sometimes makes it a lot faster

Good luck, Markus


[1] http://www.harrisgeospatial.com/docs/PROFILER.html
[2] http://www.idlcoyote.com/code_tips/slowloops.html
[3] http://www.harrisgeospatial.com/docs/WHERE.html
[4] http://www.harrisgeospatial.com/docs/SORT.html
[5] http://www.harrisgeospatial.com/docs/UNIQ.html
[6] http://www.harrisgeospatial.com/docs/HISTOGRAM.html
[7] http://www.harrisgeospatial.com/docs/VALUE_LOCATE.html
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: TS_HANTS function question
Next Topic: Need e-book of Image Analysis, Classification and Change Detection in Remote Sensing: With Algorithms for ENVI/IDL and Python by Mort Canty

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

Current Time: Sat Oct 11 16:00:08 PDT 2025

Total time taken to generate the page: 0.32018 seconds