conbining arrays [message #93316] |
Wed, 15 June 2016 07:22  |
Sharad C Tripathi
Messages: 4 Registered: June 2016
|
Junior Member |
|
|
How to combine following arrays in a single file?
A FLOAT = Array[195]
B FLOAT = Array[1440, 195]
C FLOAT = Array[195]
D LONG = Array[1440]
|
|
|
|
Re: conbining arrays [message #93323 is a reply to message #93317] |
Thu, 16 June 2016 03:25   |
Sharad C Tripathi
Messages: 4 Registered: June 2016
|
Junior Member |
|
|
On Wednesday, 15 June 2016 20:00:32 UTC+3, wlandsman wrote:
> One of many ways to do this:
>
> IDL> save,a,b,c,d
>
> to place the variables into an IDL save set idlsave.dat that can be RESTOREd
>
> On Wednesday, June 15, 2016 at 10:22:02 AM UTC-4, Sharad wrote:
>> How to combine following arrays in a single file?
>>
>> A FLOAT = Array[195]
>>
>> B FLOAT = Array[1440, 195]
>>
>> C FLOAT = Array[195]
>>
>> D LONG = Array[1440]
I didn't mean this. What i wanted to do is to make an array [195,1440] after combining these variables.
|
|
|
Re: conbining arrays [message #93324 is a reply to message #93323] |
Thu, 16 June 2016 03:53   |
Sharad C Tripathi
Messages: 4 Registered: June 2016
|
Junior Member |
|
|
On Thursday, 16 June 2016 13:25:51 UTC+3, Sharad wrote:
> On Wednesday, 15 June 2016 20:00:32 UTC+3, wlandsman wrote:
>> One of many ways to do this:
>>
>> IDL> save,a,b,c,d
>>
>> to place the variables into an IDL save set idlsave.dat that can be RESTOREd
>>
>> On Wednesday, June 15, 2016 at 10:22:02 AM UTC-4, Sharad wrote:
>>> How to combine following arrays in a single file?
>>>
>>> A FLOAT = Array[195]
>>>
>>> B FLOAT = Array[1440, 195]
>>>
>>> C FLOAT = Array[195]
>>>
>>> D LONG = Array[1440]
>
> I didn't mean this. What i wanted to do is to make an array [195,1440] after combining these variables.
as array [196,1441]
|
|
|
Re: conbining arrays [message #93325 is a reply to message #93324] |
Thu, 16 June 2016 05:45   |
Heinz Stege
Messages: 189 Registered: January 2003
|
Senior Member |
|
|
On Thu, 16 Jun 2016 03:53:41 -0700 (PDT), Sharad wrote:
> On Thursday, 16 June 2016 13:25:51 UTC+3, Sharad wrote:
>> On Wednesday, 15 June 2016 20:00:32 UTC+3, wlandsman wrote:
>>> One of many ways to do this:
>>>
>>> IDL> save,a,b,c,d
>>>
>>> to place the variables into an IDL save set idlsave.dat that can be RESTOREd
>>>
>>> On Wednesday, June 15, 2016 at 10:22:02 AM UTC-4, Sharad wrote:
>>>> How to combine following arrays in a single file?
>>>>
>>>> A FLOAT = Array[195]
>>>>
>>>> B FLOAT = Array[1440, 195]
>>>>
>>>> C FLOAT = Array[195]
>>>>
>>>> D LONG = Array[1440]
>>
>> I didn't mean this. What i wanted to do is to make an array [195,1440] after combining these variables.
>
> as array [196,1441]
Impossible.
IDL> print,195+1440*195+195+1440
282630
IDL> print,196*1441
282436
Cheers, Heinz
|
|
|
Re: conbining arrays [message #93335 is a reply to message #93317] |
Thu, 16 June 2016 11:39   |
wlandsman
Messages: 743 Registered: June 2000
|
Senior Member |
|
|
The easiest way is to first make the output array
outarr = fltarr(1441,196)
and then add subarrays where you need them
outarr[0:1439,0:194] = findgen(1440,195)
outarr[1440,0:194] = findgen(195)
outarr[0:1439,195] = findgen(1440)
making the sure that the sizes of the arrays on the left and right hand side are the same. One of your subbarrays was integer while others were floating point. If you really want ot maintain this distinction when combining them then I suggest using the LIST() function.
--Wayne
On Wednesday, June 15, 2016 at 1:00:32 PM UTC-4, wlandsman wrote:
> One of many ways to do this:
>
> IDL> save,a,b,c,d
>
> to place the variables into an IDL save set idlsave.dat that can be RESTOREd
>
> On Wednesday, June 15, 2016 at 10:22:02 AM UTC-4, Sharad wrote:
>> How to combine following arrays in a single file?
>>
>> A FLOAT = Array[195]
>>
>> B FLOAT = Array[1440, 195]
>>
>> C FLOAT = Array[195]
>>
>> D LONG = Array[1440]
|
|
|
Re: conbining arrays [message #93338 is a reply to message #93325] |
Thu, 16 June 2016 15:23   |
Sharad C Tripathi
Messages: 4 Registered: June 2016
|
Junior Member |
|
|
On Thursday, 16 June 2016 15:45:04 UTC+3, Heinz Stege wrote:
> On Thu, 16 Jun 2016 03:53:41 -0700 (PDT), Sharad wrote:
>
>> On Thursday, 16 June 2016 13:25:51 UTC+3, Sharad wrote:
>>> On Wednesday, 15 June 2016 20:00:32 UTC+3, wlandsman wrote:
>>>> One of many ways to do this:
>>>>
>>>> IDL> save,a,b,c,d
>>>>
>>>> to place the variables into an IDL save set idlsave.dat that can be RESTOREd
>>>>
>>>> On Wednesday, June 15, 2016 at 10:22:02 AM UTC-4, Sharad wrote:
>>>> > How to combine following arrays in a single file?
>>>> >
>>>> > A FLOAT = Array[195]
>>>> >
>>>> > B FLOAT = Array[1440, 195]
>>>> >
>>>> > C FLOAT = Array[195]
>>>> >
>>>> > D LONG = Array[1440]
>>>
>>> I didn't mean this. What i wanted to do is to make an array [195,1440] after combining these variables.
>>
>> as array [196,1441]
>
> Impossible.
>
> IDL> print,195+1440*195+195+1440
> 282630
> IDL> print,196*1441
> 282436
>
> Cheers, Heinz
Heinz,
it will be [1442,196]
|
|
|
Re: conbining arrays [message #93339 is a reply to message #93338] |
Fri, 17 June 2016 02:06  |
Markus Schmassmann
Messages: 129 Registered: April 2016
|
Senior Member |
|
|
On 06/17/2016 12:23 AM, Sharad wrote:> On Wednesday, June 15, 2016 at
10:22:02 AM UTC-4, Sharad wrote:
>> How to combine following arrays in a single file?
>>
>> A FLOAT = Array[195]
>> B FLOAT = Array[1440, 195]
>> C FLOAT = Array[195]
>> D LONG = Array[1440]
> it will be [1442,196]
if i understand correctly what you want, i see 2 possibilities:
outarr=[[[reform(A,[1,195]),B,reform(C,[1,195])]],[0,D,0]]
or using Wayne's approach
outarr = fltarr(1442,196)
outarr[0 ,0:194]=reform(A,[1,195])
outarr[1:1440,0:194]=B
outarr[1441 ,0:194]=reform(C,[1,195])
outarr[1:1440,195 ]=D
You could also use transpose instead of reform, but reform should be
faster. However reform only gives the same result as transpose if A and
C are vectors, i.e. if 2 dimensions have size >1 you have to use transpose.
|
|
|