As in FITS the scale and offset values are used as:
True_value = Stored_value * scale + offset;
An engine object should be used for one column only, because the target column name is part of the engine. If it would be used for more than one column, they would all share the same target column. When the engine is bound to a column, it is checked if the name of that column matches the given source column name.
The engine can be used for a column containing any kind of array (thus direct or indirect, fixed or variable shaped)) as long as the source array can be stored in the target array. Thus a fixed shaped source can use a variable shaped target, but not vice versa. A fixed shape indirect source can use a target with direct arrays.
This class can also serve as an example of how to implement a virtual column engine.
Because the engine can serve only one column, it was possible to combine the engine and the column functionality in one class.
// Create the table description and 2 columns with indirect arrays in it.
// The Int column will be stored, while the double will be
// used as virtual.
TableDesc tableDesc ("", TableDesc::Scratch);
tableDesc.addColumn (ArrayColumnDesc<Short> ("storedArray"));
tableDesc.addColumn (ArrayColumnDesc<Float> ("virtualArray"));
tableDesc.addColumn (ScalarColumnDesc<Float> ("scale"));
tableDesc.addColumn (ScalarColumnDesc<Float> ("offset"));
// Create a new table using the table description.
SetupNewTable newtab (tableDesc, "tab.data", Table::New);
// Create the array scaling engine (with auto-scale)
// and bind it to the float column.
CompressFloat scalingEngine("virtualArray", "storedArray",
"scale", "offset");
newtab.bindColumn ("virtualArray", scalingEngine);
// Create the table.
Table table (newtab);
// Store a 3-D array (with dim. 2,3,4) into each row of the column.
// The shape of each array in the column is implicitly set by the put
// function. This will also set the shape of the underlying Int array.
ArrayColumn data (table, "virtualArray");
Array<double> someArray(IPosition(4,2,3,4));
someArray = 0;
for (uInt i=0, i<10; i++) { // table will have 10 rows
table.addRow();
data.put (i, someArray)
}
Construct an engine to scale the arrays in a column. The scale and offset values are taken from a column with the given names. In that way each array has its own scale factor and offset value. An exception is thrown if these columns do not exist. SourceColumnName is the name of the source column and is used to check if the engine gets bound to the correct column. TargetColumnName is the name of the column where the scaled data will be put and must have data type Short. The source column using this engine must have data type Float.
Construct from a record specification as created by getmanagerSpec().
Destructor is mandatory.
Return the type name of the engine (i.e. its class name).
Get the name given to the engine (is the source column name).
Record a record containing data manager specifications.
Return the name of the class. This includes the names of the template arguments.
Register the class name and the static makeObject "constructor". This will make the engine known to the table system.
Assignment is not needed and therefore forbidden (so it is made private and not implemented).
Clone the engine object.
Initialize the object for a new table. It defines the keywords containing the engine parameters.
Preparing consists of setting the writable switch and adding the initial number of rows in case of create. Furthermore it reads the keywords containing the engine parameters.
Reopen the engine for read/write access. It makes the column writable if the underlying column is writable.
Add rows to the table. If auto-scaling, it initializes the scale column with 0 to indicate that no data has been processed yet.
Get an array in the given row. This will scale and offset from the underlying array.
Put an array in the given row. This will scale and offset to the underlying array.
Get a section of the array in the given row. This will scale and offset from the underlying array.
Put into a section of the array in the given row. This will scale and offset to the underlying array.
Get an entire column. This will scale and offset from the underlying array.
Put an entire column. This will scale and offset to the underlying array.
Get a section of all arrays in the column. This will scale and offset from the underlying array.
Put a section of all arrays in the column. This will scale and offset to the underlying array.
Scale and/or offset target to array. This is meant when reading an array from the target column. It optimizes for scale=1 and/or offset=0.
Scale and/or offset array to target. This is meant when writing an array into the target column. It optimizes for scale=1 and/or offset=0.
Scale and/or offset target to array for the entire column. When the scale and offset are fixed, it will do the entire array. Otherwise it iterates through the array and applies the scale and offset per row.
Scale and/or offset array to target for the entire column. When the scale and offset are fixed, it will do the entire array. Otherwise it iterates through the array and applies the scale and offset per row.
Get the offset value for this row.
Find minimum and maximum from the array data. NaN and infinite values are ignored. If no values are finite, minimum and maximum are set to NaN.
Make scale and offset from the minimum and maximum of the array data. If minVal is NaN, scale is set to 0.
Put a part of an array in a row using given scale/offset values.
Fill the array part into the full array and put it using the given min/max values.