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

Home » Public Forums » archive » about color table
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: about color table [message #67118 is a reply to message #66904] Sun, 21 June 2009 12:46 Go to previous messageGo to previous message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
David Fanning wrote:
> Jeremy Bailin writes:
>
>> Yeah, value_locate is very handy for problems like this! I
>> particularly like using it as a precursor to histogram - i.e. if you
>> want to do something fancy using reverse_indices but don't have
>> uniformly-spaced bins, first use value_locate to get integer indices
>> and then use histogram to do the heavy lifting.
>
> All right, I'll bite. Let's see an example of this.
> Maybe you can write an article and become the JD Smith
> of Value_Locate. :-)

No article, but I think this is what Jeremy is talking about:

IDL> ; get some random data
IDL> d = randomu(12345678L, 20)
IDL> print, d
0.765989 0.0234537 0.589727 0.535102 0.982231
0.693016 0.328147
0.295642 0.849918 0.592262 0.558133 0.534926
0.541119 0.594831
0.410172 0.928598 0.161021 0.928724 0.952072
0.522173

IDL> ; specify cutoffs
IDL> cutoffs = [0.3, 0.4, 0.8]

IDL> ; compute index of "bin" to put each value into
IDL> bins = value_locate(cutoffs, d) + 1L
IDL> print, ind
2 0 2 2 3
2 1 0
3 2 2 2 2
2 2 3
0 3 3 2

IDL> ; compute histogram of bins
IDL> h = histogram(bins, reverse_indices=r)
IDL> print, h
3 1 11 5

IDL> ; values less than 0.3
IDL> print, d[r[r[0]:r[1] - 1]]
0.0234537 0.295642 0.161021

IDL> ; values between 0.3 and 0.4
IDL> print, d[r[r[1]:r[2] - 1]]
0.328147

IDL> ; values between 0.4 and 0.8
IDL> print, d[r[r[2]:r[3] - 1]]
0.765989 0.589727 0.535102 0.693016 0.592262
0.558133 0.534926
0.541119 0.594831 0.410172 0.522173

IDL> ; values greater than 0.8
IDL> print, d[r[r[3]:r[4] - 1]]
0.982231 0.849918 0.928598 0.928724 0.952072

Mike
--
www.michaelgalloy.com
Associate Research Scientist
Tech-X Corporation
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: about color table
Next Topic: matrix - element extraction

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

Current Time: Fri Oct 10 19:57:57 PDT 2025

Total time taken to generate the page: 0.00193 seconds