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

Home » Public Forums » archive » Re: Want to get Array(48) instead of Array(1,48)
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: Want to get Array(48) instead of Array(1,48) [message #29871] Mon, 25 March 2002 23:38 Go to next message
Dominik[1] is currently offline  Dominik[1]
Messages: 46
Registered: April 2001
Member
I know the problem and the only solution I found till yet is, that I change
the order of the dimensions from [1,48] to [48,1] and then IDL will "loose"
the last dimension, changing it into [48]. This can be done wich test_array=
transpose(test_array, [1,0]).

Dom

"chi-kuei" <twcollie@hotmail.com> schrieb im Newsbeitrag
news:a7om25$8jn$1@news01.cit.cornell.edu...
> Hi,
>
> It occurs to me that when I do the following:
>
> IDL> test_array = fltarr(48)
> test_array is Array[48]
>
> but when I assign the value from a 2-D array
> IDL> test_array = data_array(0, 0:47)
> test_array becomes Array[1,48]
>
> I notice they are different because when I use curvefit, the Array[1,48]
> will give me error message, the Array[48] will not.
>
> I can make the Array[1,48] become Array[48] without changing the value by
> doing this:
> IDL> test_array = test_array(*)
>
> This means extra steps. Am I doing this in the longer way? Is there any
> shortcut of doing this.
>
> Thanks,
> Chi-Kuei
>
>
Re: Want to get Array(48) instead of Array(1,48) [message #29872 is a reply to message #29871] Mon, 25 March 2002 18:42 Go to previous messageGo to next message
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
"chi-kuei" <twcollie@hotmail.com> wrote in message
news:a7om25$8jn$1@news01.cit.cornell.edu...

> ...I notice they are different because when I use curvefit, the
> Array[1,48] will give me error message, the Array[48] will not.
>
> I can make the Array[1,48] become Array[48] without changing the
> value by doing this:
>
> IDL> test_array = test_array(*)
>
> This means extra steps. Am I doing this in the longer way? Is there
> any shortcut of doing this.

No, there is no real shortcut. It is common when using IDL to find
that you have the data you want but the array is not shaped exactly
how you need it. The most versatile and efficient solution is to use
the REFORM function. If it is called with a single argument (the array
to be reshaped) then it will strip out all unit dimensions. Since the
number of elements in the array is not being changed you can use the
OVERWRITE keyword for greater efficiency, thus:

IDL> test_array = reform(test_array, /OVERWRITE)

--

Mark Hadfield
m.hadfield@niwa.co.nz Ka puwaha et tai nei
http://katipo.niwa.co.nz/~hadfield Hoea tatou
National Institute for Water and Atmospheric Research (NIWA)
Re: Want to get Array(48) instead of Array(1,48) [message #29970 is a reply to message #29871] Mon, 25 March 2002 23:50 Go to previous messageGo to next message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
Dominik Paul wrote:
>
> I know the problem and the only solution I found till yet is, that I change
> the order of the dimensions from [1,48] to [48,1] and then IDL will "loose"
> the last dimension, changing it into [48]. This can be done wich test_array=
> transpose(test_array, [1,0]).
>
> Dom
>

Dear Domink

this works but if RSI will sometime in the future change the dropping
of last dimension one (I hope soon) this goes wrong.
Mark shows the better usage of reform.


regards

Reimar


> "chi-kuei" <twcollie@hotmail.com> schrieb im Newsbeitrag
> news:a7om25$8jn$1@news01.cit.cornell.edu...
>> Hi,
>>
>> It occurs to me that when I do the following:
>>
>> IDL> test_array = fltarr(48)
>> test_array is Array[48]
>>
>> but when I assign the value from a 2-D array
>> IDL> test_array = data_array(0, 0:47)
>> test_array becomes Array[1,48]
>>
>> I notice they are different because when I use curvefit, the Array[1,48]
>> will give me error message, the Array[48] will not.
>>
>> I can make the Array[1,48] become Array[48] without changing the value by
>> doing this:
>> IDL> test_array = test_array(*)
>>
>> This means extra steps. Am I doing this in the longer way? Is there any
>> shortcut of doing this.
>>
>> Thanks,
>> Chi-Kuei
>>
>>

--
Reimar Bauer

Institut fuer Stratosphaerische Chemie (ICG-I)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
------------------------------------------------------------ -------
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml
============================================================ =======
Re: Want to get Array(48) instead of Array(1,48) [message #29983 is a reply to message #29872] Tue, 02 April 2002 08:24 Go to previous message
chi-kuei is currently offline  chi-kuei
Messages: 5
Registered: March 2002
Junior Member
Thansk,
This one works well for me.

Chi-Kuei

"Mark Hadfield" <m.hadfield@niwa.co.nz> wrote in message
news:a7on9c$nj3$1@newsreader.mailgate.org...
> "chi-kuei" <twcollie@hotmail.com> wrote in message
> news:a7om25$8jn$1@news01.cit.cornell.edu...
>
>> ...I notice they are different because when I use curvefit, the
>> Array[1,48] will give me error message, the Array[48] will not.
>>
>> I can make the Array[1,48] become Array[48] without changing the
>> value by doing this:
>>
>> IDL> test_array = test_array(*)
>>
>> This means extra steps. Am I doing this in the longer way? Is there
>> any shortcut of doing this.
>
> No, there is no real shortcut. It is common when using IDL to find
> that you have the data you want but the array is not shaped exactly
> how you need it. The most versatile and efficient solution is to use
> the REFORM function. If it is called with a single argument (the array
> to be reshaped) then it will strip out all unit dimensions. Since the
> number of elements in the array is not being changed you can use the
> OVERWRITE keyword for greater efficiency, thus:
>
> IDL> test_array = reform(test_array, /OVERWRITE)
>
> --
>
> Mark Hadfield
> m.hadfield@niwa.co.nz Ka puwaha et tai nei
> http://katipo.niwa.co.nz/~hadfield Hoea tatou
> National Institute for Water and Atmospheric Research (NIWA)
>
>
>
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: FIND the indexes of a value in a matrix
Next Topic: Transparent texture mapped polygons

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

Current Time: Wed Oct 08 15:50:27 PDT 2025

Total time taken to generate the page: 0.00522 seconds