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

Home » Public Forums » archive » Data elimination from array
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Data elimination from array [message #51799] Fri, 08 December 2006 09:07 Go to next message
StevenM is currently offline  StevenM
Messages: 9
Registered: June 2006
Junior Member
Firstly, thanks to those of you who have replied to my posts, the
replies have been very helpful and I really appreciate the time that
has been taken on them.

I am trying to re-organise an array of numbers into 4 new arrays. The
array has 21446656 data points, and I would like to split it up into
four arrays of 5361664 data points. I would like the first 1792 data
points in the first new array, the second 1792 data points in the
second new array and so on. I would then like for the 5th set of 1792
data points (ie starting at data point 8959) to be put in the first new
array and so on.

To make this a bit clearer here is an example
array{0,12,14,16,22,43,12,35,67,88,12,11}

would become

array1{0,22,67}
array2{12,43,88}
array3{14,12,12}
array4{16,35,11}

thanks in advance

Steven
Re: Data elimination from array [message #51924 is a reply to message #51799] Sat, 09 December 2006 16:08 Go to previous message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
Braedley wrote:
> And after some optimizations of your code, Mike, it's on par with mine,
> so I offer up the choice to you, Steven.

OK, I took out all the repetitive calls to N_ELEMENTS and fixed the bugs
on array2, array3, array4 which were all identical to array1.

I think the only real difference is stride notation versus creating an
index array.

array = findgen(21446656)
nlen = 1792

n = n_elements(array)
r = reform(array, nlen, n / nlen)
array1 = reform(r[*, 0:*:4], n / 4)
array2 = reform(r[*, 1:*:4], n / 4)
array3 = reform(r[*, 2:*:4], n / 4)
array4 = reform(r[*, 3:*:4], n / 4)

Mike
--
www.michaelgalloy.com
Re: Data elimination from array [message #51929 is a reply to message #51799] Fri, 08 December 2006 18:55 Go to previous message
Braedley is currently offline  Braedley
Messages: 57
Registered: September 2006
Member
And after some optimizations of your code, Mike, it's on par with mine,
so I offer up the choice to you, Steven.

Braedley

Braedley wrote:
> Yeah, it just doesn't look as clear to me (plus, I think you still have
> an error in there). Mine is also a fair amount faster on my machine
> (AMD 64 X2 4800+, IDLv6.2). It does provide the correct result.
>
> Braedley
>
> mgalloy@gmail.com wrote:
>> Bob Crawford wrote:
>>> On Dec 8, 3:45 pm, "Braedley" <mike.braed...@gmail.com> wrote:
>>>> Except that it doesn't work.
>>>
>>> What doesn't work? Wox's code? It worked when I tried it.
>>
>> Mine original code doesn't work (or it only works for the case the
>> length of each "block" is 1).
>>
>> I think this should be more general:
>>
>> array = findgen(21446656)
>> nlen = 1792
>>
>> r = reform(array, nlen, n_elements(array) / nlen)
>> array1 = reform(r[*, 0:*:4], n_elements(array) / 4)
>> array2 = reform(r[*, 0:*:4], n_elements(array) / 4)
>> array3 = reform(r[*, 0:*:4], n_elements(array) / 4)
>> array4 = reform(r[*, 0:*:4], n_elements(array) / 4)
>>
>> Mike
>> --
>> www.michaelgalloy.com
Re: Data elimination from array [message #51930 is a reply to message #51799] Fri, 08 December 2006 18:40 Go to previous message
Braedley is currently offline  Braedley
Messages: 57
Registered: September 2006
Member
Yeah, it just doesn't look as clear to me (plus, I think you still have
an error in there). Mine is also a fair amount faster on my machine
(AMD 64 X2 4800+, IDLv6.2). It does provide the correct result.

Braedley

mgalloy@gmail.com wrote:
> Bob Crawford wrote:
>> On Dec 8, 3:45 pm, "Braedley" <mike.braed...@gmail.com> wrote:
>>> Except that it doesn't work.
>>
>> What doesn't work? Wox's code? It worked when I tried it.
>
> Mine original code doesn't work (or it only works for the case the
> length of each "block" is 1).
>
> I think this should be more general:
>
> array = findgen(21446656)
> nlen = 1792
>
> r = reform(array, nlen, n_elements(array) / nlen)
> array1 = reform(r[*, 0:*:4], n_elements(array) / 4)
> array2 = reform(r[*, 0:*:4], n_elements(array) / 4)
> array3 = reform(r[*, 0:*:4], n_elements(array) / 4)
> array4 = reform(r[*, 0:*:4], n_elements(array) / 4)
>
> Mike
> --
> www.michaelgalloy.com
Re: Data elimination from array [message #51937 is a reply to message #51799] Fri, 08 December 2006 13:59 Go to previous message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
Bob Crawford wrote:
> On Dec 8, 3:45 pm, "Braedley" <mike.braed...@gmail.com> wrote:
>> Except that it doesn't work.
>
> What doesn't work? Wox's code? It worked when I tried it.

Mine original code doesn't work (or it only works for the case the
length of each "block" is 1).

I think this should be more general:

array = findgen(21446656)
nlen = 1792

r = reform(array, nlen, n_elements(array) / nlen)
array1 = reform(r[*, 0:*:4], n_elements(array) / 4)
array2 = reform(r[*, 0:*:4], n_elements(array) / 4)
array3 = reform(r[*, 0:*:4], n_elements(array) / 4)
array4 = reform(r[*, 0:*:4], n_elements(array) / 4)

Mike
--
www.michaelgalloy.com
Re: Data elimination from array [message #51938 is a reply to message #51799] Fri, 08 December 2006 13:51 Go to previous message
Bob[3] is currently offline  Bob[3]
Messages: 60
Registered: December 2006
Member
On Dec 8, 3:45 pm, "Braedley" <mike.braed...@gmail.com> wrote:
> Except that it doesn't work.

What doesn't work? Wox's code? It worked when I tried it.
Re: Data elimination from array [message #51939 is a reply to message #51799] Fri, 08 December 2006 13:25 Go to previous message
Bob[3] is currently offline  Bob[3]
Messages: 60
Registered: December 2006
Member
On Dec 8, 3:45 pm, "Braedley" <mike.braed...@gmail.com> wrote:
> Except that it doesn't work.

What doesn't work? Wox's code? It worked when I tried it.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: How to get a very large 2D projected surface image
Next Topic: IDL with command line like input, (in EFTS -EUMETSAT)

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

Current Time: Sat Oct 11 00:00:25 PDT 2025

Total time taken to generate the page: 0.80092 seconds