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

Home » Public Forums » archive » Re: Is there a better way?
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: Is there a better way? [message #9162] Wed, 11 June 1997 00:00 Go to previous message
Stein Vidar Hagfors H is currently offline  Stein Vidar Hagfors H
Messages: 32
Registered: May 1997
Member
Kelly Dean wrote:
>
> Is there a better way to locate a value in a table (or array)? I would
> like to come in with an array of radaince values and convert them to
> temperatures. The method below only takes the one number (rad) then
> search for the best match in the table (or array).
>
> If you can thing of a better method, send me a note.

Well, I can suggest a couple of things that will probably
speed up the routine considerably, though I can't guarantee
that it's the *best* way...


> =================================================
> FUNCTION IS_THERE_A_BETTER_WAY, rad
>

If the table you're using is actually created this way,
I'd use a common block as a cache to avoid initializing
the tables on each call, e.g.:

COMMON IS_THERE_A_BETTER_WAY_CACHE,WVTEMParr,WVRADarr

IF n_elements(WVTEMParr) eq 0 THEN BEGIN
<initialize arrays here>
ENDIF

Instead of looping etc, I'd put my money on IDL's array processing
capabilities:

absdiff = abs(WVRADarr - rad)
dummy = min(absdiff,minix) ; Minix now contains the index of
; the point with the minimum abs diff.

return,WVTEMParr(minix)

> END

Unless your real arrays are very large, this is probably
faster than a search in a sorted array, due to the slow
execution of single statements vs array operations.

A native IDL routine doing a sorted search should be
available, though.... haven't found one yet....

Stein Vidar
[Message index]
 
Read Message
Read Message
Previous Topic: AVI in PV-Wave
Next Topic: watershed segmentation

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

Current Time: Wed Oct 08 19:23:01 PDT 2025

Total time taken to generate the page: 0.00448 seconds