creating arrays in loops [message #91475] |
Fri, 17 July 2015 16:08  |
wdolan
Messages: 29 Registered: June 2015
|
Junior Member |
|
|
Hello again! IDL beginner here.
So I'm looping through a bunch of different scans of IR radiances. for each scan, I calculate a certain value (lets call it X). Every time it goes through the loop, I'd like it to store X, so that once it is done looping through all the scans, we have an array with all of the scans and their corresponding x value.
My later goal is to then take the scans with the top 9 X values, and use them for analysis later, and I think I know how to do the sorting. But I just don't know how to get each loop to add X to an array.
Thanks for all your help :)
|
|
|
Re: creating arrays in loops [message #91476 is a reply to message #91475] |
Fri, 17 July 2015 16:33   |
wdolan
Messages: 29 Registered: June 2015
|
Junior Member |
|
|
So I figured out how to get all the X values in an array, but I need to have a way to recognize which scan goes with which x value, so that when I sort the X's, I can still know the scan.
Any ideas?
Thanks again!
On Friday, July 17, 2015 at 4:08:06 PM UTC-7, wdo...@oxy.edu wrote:
> Hello again! IDL beginner here.
>
>
> So I'm looping through a bunch of different scans of IR radiances. for each scan, I calculate a certain value (lets call it X). Every time it goes through the loop, I'd like it to store X, so that once it is done looping through all the scans, we have an array with all of the scans and their corresponding x value.
>
> My later goal is to then take the scans with the top 9 X values, and use them for analysis later, and I think I know how to do the sorting. But I just don't know how to get each loop to add X to an array.
>
> Thanks for all your help :)
|
|
|
|
Re: creating arrays in loops [message #91479 is a reply to message #91476] |
Fri, 17 July 2015 18:47  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
wdolan@oxy.edu writes:
> So I figured out how to get all the X values in an array, but I need to have a way to recognize which scan goes with which x value, so that when I sort the X's, I can still know the scan.
Use the same sort index you get by sorting X to sort the scans:
sortIndex = Sort(x)
sortedScans = scans[sortIndex]
sortedX = X[sortIndex]
Now sortedX[0] is the biggest X, and it is associated with sortedScans
[0].
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
|
|
|