Re: Is it possible to speed up the Interpolate command? [message #89299 is a reply to message #89255] |
Thu, 14 August 2014 17:04   |
Stephen Messenger
Messages: 3 Registered: August 2014
|
Junior Member |
|
|
On Friday, August 8, 2014 7:19:23 PM UTC-4, Stephen Messenger wrote:
> On Thursday, August 7, 2014 10:52:37 PM UTC-4, wlandsman wrote:
>
>> On Thursday, August 7, 2014 6:11:29 PM UTC-4, Stephen Messenger wrote:
>
>>
>
>>> I've been stuck on figuring out how to speed up an interpolation calculation and wondered if anyone has any suggestions?
>
>>
>
>>
>
>>
>
>>> for i=0, numlines-1 do begin
>
>>
>
>>> Values(*,i)=interpolate(datacube(*,*,i),x_loc,y_loc)
>
>>
>
>>> endfor
>
>>
>
>>
>
>>
>
>> One suggestion is to replace the above with
>
>>
>
>>
>
>>
>
>> for i=0,numlines-1 do begin
>
>>
>
>> values[0,i] = interpolate(data cube[*,*,i],x_loc,y_loc)
>
>>
>
>> endfor
>
>>
>
>>
>
>>
>
>> https://www.idlcoyote.com/code_tips/asterisk.html
>
>>
>
>>
>
>>
>
>> You might also find a slight speed improvement with by writing
>
>>
>
>>
>
>>
>
>> for i=0,numlines-1 do $
>
>>
>
>> values[0,i] = interpolate(data cube[*,*,i],x_loc,y_loc)
>
>>
>
>>
>
>>
>
>> though the improvement will be less than it was in old versions of IDL.
>
>
>
> Hi all,
>
>
>
> Thank you for the suggestions.
>
>
>
> Mike: I'm going to check if that will work for me. Thank you for that suggestion.
>
>
>
> Craig: I followed the code you wrote below and the math and reasoning makes sense. However, it actually takes almost 5 times longer to run. I'm thinking that this may have to do with the "values" line that requires accessing entries within the large data cube. I'm hammering away at figuring out how to modify the suggested method to calculate faster, but wanted to check if there were any suggestions? Thank you for your help!
>
>
>
> wlandsman: I hadn't seen that trick yet. Thank you for the suggestion! I didn't detect a bump in speed, but I'm using 8.1, so maybe they fixed it since the earlier versions.
>
>
>
> I haven't been able to find the source code for INTERPOLATE within the IDL lib files. If you happen to know how to dig that source code out of IDL, I would definitely appreciate the expertise.
>
>
>
> Thanks!
>
>
>
> Stephen
Hi all,
Interestingly, for the bilinear interpolation, if you rearrange the datacube to put the longest dimension (in this case, the 450,000) first, then that code calculates about 5 times faster.
Stephen
|
|
|