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

Home » Public Forums » archive » Re: Split an int array into different arrays
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
Re: Split an int array into different arrays [message #83398] Mon, 04 March 2013 06:04
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Krishnakumar M.A writes:

> Thanks for the sudden reply. I tried that but what it is not "splitting" the dataset into different arrays, instead giving the same data set in each new array, which is not I wanted. I made some confusion in the question, i think. What i require is to split a large array, say array(1000) to arrays(100), in which i will be getting first 100 points in the first column then the next 100 in the 2nd column and so on. but that is not happening with the reform command?
> Did I do anything wrong?

Probably you just forgot to mention "columns". We all think "rows"
around here. Try this:

array = Indgen(100)
foldedArray = Transpose(Reform(array, 10, 10))

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.")
Re: Split an int array into different arrays [message #83399 is a reply to message #83398] Mon, 04 March 2013 06:00 Go to previous message
Krishnakumar M.A is currently offline  Krishnakumar M.A
Messages: 19
Registered: March 2013
Junior Member
On Monday, March 4, 2013 5:59:42 PM UTC+5:30, Mats Löfdahl wrote:
> Den måndagen den 4:e mars 2013 kl. 13:11:57 UTC+1 skrev Krishnakumar M.A:
>
>> Dear All,
>
>>
>
>> I am writing a simulation in which I have to deal with a large 1D integer array and want to split it into different arrays of same length and add them one over the other, like folding. Are there any function of idl which will do it? It will be very helpful to me, if anyone can solve this.
>
>
>
> Sounds like you could do it by first REFORMing the large 1D array to a 2D array (the "folding") and then use TOTAL to sum over one of the dimensions.

Thanks for the sudden reply. I tried that but what it is not "splitting" the dataset into different arrays, instead giving the same data set in each new array, which is not I wanted. I made some confusion in the question, i think. What i require is to split a large array, say array(1000) to arrays(100), in which i will be getting first 100 points in the first column then the next 100 in the 2nd column and so on. but that is not happening with the reform command?
Did I do anything wrong?
Re: Split an int array into different arrays [message #83400 is a reply to message #83399] Mon, 04 March 2013 04:44 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> array = RandomU(seed, 100000)
> foldedArray = Rebin(array, 100, 100)

Duh! I seem to always type "Rebin" when I mean "Reform". Sorry. :-(

array = RandomU(seed, 100000)
foldedArray = Reform(array, 100, 100)

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.")
Re: Split an int array into different arrays [message #83401 is a reply to message #83400] Mon, 04 March 2013 04:29 Go to previous message
Mats Löfdahl is currently offline  Mats Löfdahl
Messages: 263
Registered: January 2012
Senior Member
Den måndagen den 4:e mars 2013 kl. 13:11:57 UTC+1 skrev Krishnakumar M.A:
> Dear All,
>
> I am writing a simulation in which I have to deal with a large 1D integer array and want to split it into different arrays of same length and add them one over the other, like folding. Are there any function of idl which will do it? It will be very helpful to me, if anyone can solve this.

Sounds like you could do it by first REFORMing the large 1D array to a 2D array (the "folding") and then use TOTAL to sum over one of the dimensions.
Re: Split an int array into different arrays [message #83402 is a reply to message #83401] Mon, 04 March 2013 04:26 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Krishnakumar M.A writes:

> I am writing a simulation in which I have to deal with a large 1D integer array and want to split it into different arrays of same length and add them one over the other, like folding. Are there any function of idl which will do it? It will be very helpful to me, if anyone can solve this.

array = RandomU(seed, 100000)
foldedArray = Rebin(array, 100, 100)

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.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Split an int array into different arrays
Next Topic: bug? or how to distinguish between a Hash and an array of Hashes ?

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

Current Time: Wed Oct 08 15:16:56 PDT 2025

Total time taken to generate the page: 0.00466 seconds