How to extract a scalar from a vector? [message #74163] |
Tue, 04 January 2011 15:13 |
Balt
Messages: 16 Registered: May 2010
|
Junior Member |
|
|
Hi,
I have an array with doubles (calibration factors for some data):
CAL_DATA DOUBLE = Array[24, 4]
I have a channel and unit number which is used to extract the proper
gain and offset from the cal_data array. So to obtain gain a and
offset b from this array, I extract it as follows:
For channel=1, unit=3:
sel_cal_data = WHERE(cal_data[*,0] EQ 3 AND cal_data[*,1] EQ 1, count)
Which works fine, as this illustrates:
IDL> PRINT, "A:", cal_data[sel_cal_data,2], "B:",
cal_data[sel_cal_data,3]
A: 96.859805
B:
-304.81185
IDL>
These are the values I want (verified manually).
Now for the problem: I now need to convert the voltages in the array
u3_C165 into temperatures, again, simple:
u3_T165 = cal_data[sel_cal_data,2] * u3_C165 - cal_data[sel_cal_data,
3]
So, u3_C165 contains 1570 measurements:
IDL> help,u3_C165
U3_C165 DOUBLE = Array[1570]
Now u3_T165 should contain 1570 datapoints of temperature. Except, it
doesn't! For some reason, this is what's in there now:
IDL> help,u3_T165
U3_T165 DOUBLE = Array[1]
IDL>
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.
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,2] and
cal_data[sel_cal_data,3] into a scalar? I tried this:
IDL> x = DOUBLE(cal_data[sel_cal_data,3])
IDL> help,x
X DOUBLE = Array[1]
obviously to no avail.
Any help greatly appreciated!
Thanks
- Balt
|
|
|