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 #93628 is a reply to message #93626] Mon, 12 September 2016 01:52 Go to previous messageGo to previous message
Markus Schmassmann is currently offline  Markus Schmassmann
Messages: 129
Registered: April 2016
Senior Member
On 09/12/2016 05:58 AM, sid wrote:
> On Friday, September 9, 2016 at 2:42:00 PM UTC+5:30, Markus Schmassmann wrote:
>> 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.
>> - 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
>
> Thanks for the info,
> Actually the main problem im facing is im using where function and
> for example if im searching where(image(*,i) gt threshold,count=c)
> for some rows counts will be zero,
> so in that case im using if statement, that way my program becomes much slow.
> Is there any way to get out of this problem.
depending on the analysis you make, you can use

image[where(image(*,i) gt threshold,/null),i]

which is !null for rows with count 0. If you can get it work without
throwing an error, you should be fine
[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: Wed Oct 08 17:30:20 PDT 2025

Total time taken to generate the page: 0.00408 seconds