|
Re: How to extract a scalar from a vector? [message #74161 is a reply to message #74160] |
Tue, 04 January 2011 15:43   |
penteado
Messages: 866 Registered: February 2018
|
Senior Member Administrator |
|
|
> I think the problem is that IDL thinks that cal_data[sel_cal_data,2]
> and cal_data[sel_cal_data,3] are vectors of dimension 1, when they
> should be scalars.
I do not know what you mean by "thinks they are" 1-element arrays.
They *are* 1-element arrays. Any time an array indexed by an array (in
this case, the result of where), the result is an array, even if it
only has 1 element.
> See this:
> IDL> help,cal_data[sel_cal_data,
> 3]
> <Expression> DOUBLE = Array[1]
You are right that this is the problem, since the product of arrays of
different sizes has the size of the smaller of the two, in this case,
1.
> How on earth can I make cal_data[sel_cal_data,2] and
> cal_data[sel_cal_data,3] into a scalar? I tried this:
Use just one element of sel_cal_data (the one element is a scalar),
instead of the whole sel_cal_data array:
cal_data[sel_cal_data[0],3]
|
|
|
|
|
Re: How to extract a scalar from a vector? [message #74493 is a reply to message #74162] |
Tue, 18 January 2011 23:07   |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
Am 05.01.2011 00:37, schrieb David Fanning:
> Balt writes:
>
>> See this:
>> IDL> help,cal_data[sel_cal_data,3]
>> <Expression> DOUBLE = Array[1]
>>
>> How on earth can I make cal_data[sel_cal_data,3] into
>> a scalar?
>
> IDL> Help, (cat_data[sel_cal_data,3])[0]
>
> Cheers,
>
> David
>
>
>
Sometimes a scalar function
http://www.fz-juelich.de/icg/icg-1/idl_icglib/idl_source/idl _work/rb_lib/scalar.pro
makes it easier to initialize data e.g.
scalar(MAKE_ARRAY(1,val=1,type=m_type))
cheers
Reimar
|
|
|
Re: How to extract a scalar from a vector? [message #94779 is a reply to message #74162] |
Wed, 11 October 2017 03:10  |
chrisbuc
Messages: 1 Registered: October 2017
|
Junior Member |
|
|
On Tuesday, 4 January 2011 23:37:35 UTC, David Fanning wrote:
> Balt writes:
>
>> See this:
>> IDL> help,cal_data[sel_cal_data,3]
>> <Expression> DOUBLE = Array[1]
>>
>> How on earth can I make cal_data[sel_cal_data,3] into
>> a scalar?
>
> IDL> Help, (cat_data[sel_cal_data,3])[0]
>
> Cheers,
>
> David
>
>
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming: http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Thanks Dave,
I would never have thought of (arr[0])[0] to get a scaler from a 1 element array. Cheers :-)
Chris Buckley
|
|
|