CLsqFit:GetObs
The GetObs method returns a table containing the observe value for every point in the data sample. If multichannel data is used, the function returns 1 table for each data channel. The returned table contains CLsqFit:GetNumPts() values. To get the observed value of a single point, use GetPtObs.
tblObs = CLsqFit:GetObs() tblObs = CLsqFit:GetObs( nChannel ) tblObs1, tblObs2, tblObs3, tblObs4 = CLsqFit:GetObs() |
nChannel is the optional channel to select for multi-channel data.
tblObs is a 1-dimensional array containing the observed values.
tblObs1, tblObs2, tblObs3, tblObs4 are tables of observe valus assigned to points that have multi-channel (e.g., RGB) values. The number of tables returned equals the number of channels.
Two forms are provided with a different number of return values. If the point uses single-channel data (i.e., typical numeric data) or you specify the channel, then a single table is returned. If the point involves multi-channel data, up to 4 tables will be returned. The number of tables returned is determined by the SetNumChannels method which was used before data were added to the fit.
The following script creates a table containing the index of every point having an observed value < -2.5. Observations metting this condition will be stored into an a 1-dimensional array containing their index and value, which will then be printed at the end of the script.
Note that the first for loop uses ipairs() to access the integer index of each point, starting at index 1. However, ipairs expects a continuous integer sequence with no "holes", and it stops iterating when the first nil index is found. This owrks since all points are stored in sequential integer array indices. Each point discovered with the value below -2.5 is entered into a storage table with its index and its value, hence that table will have "holes" (nils) in the continuous sequence of indices. Therefore, the second loop iterates using pairs, rather than ipairs, since pairs finds everything in the table and ignores the holes in the integral index values. The result should find points at indices 1 and 4.
|
-- create a CLsqFit object |
|
-- set 2 coefs to fit a line to single channel data |
|
-- add points |
|
|
|
|
|
|
|
-- Fit the line |
|
-- create a table for the high obs values |
|
-- loop over all points k having observed value obs |
|
-- tObsLow hld the next point fond |
|
|
|
-- use pairs to catch every non-nil index k |
|
-- list the point |
|
|
Mira Pro x64 Script User's Guide, v.8.73 Copyright Ⓒ 2024
Mirametrics, Inc. All Rights Reserved.