public class SensorTest extends PropertyResources
KEY_DERIVE property, and linear prediction
according to the KEY_DATABASE, KEY_PREDICT, and
KEY_FUTURE properties. The output data are writtn
together with the input data to a column-ascii file.
The aim of this test is to find the most reliable derivators and linear predictors, possibly together with read-out times, for all sensors. Prediction should only be accurate for the next two minutes (closure time of the roof).
| Modifier and Type | Class and Description |
|---|---|
private static class |
SensorTest.Parser
A command line parser class to allow direct parameter hand-over.
|
PropertyResources.Load, PropertyResources.URLResource| Modifier and Type | Field and Description |
|---|---|
private static boolean |
DEFBIAS
The default bias removal.
|
private static int |
DEFCOLUMN
The default column to read on input.
|
private static String |
DEFFORMAT
The default data output format.
|
private static int |
DEFFUTURE
The default number of predicted values.
|
private static String |
DEFOUTFILE
The default output file name.
|
private List |
derivatives
The list to the data derived from applying the derivators.
|
private NumberFormat |
df
The data formatter used.
|
private List |
extrapolations
The list to the data derived from applying extrapolation.
|
private double[] |
input
The input data of the sensor raw readings.
|
static String |
KEY_BIAS
The key pointing to bias removal at predicition.
|
static String |
KEY_COLUMN
The key to the column number to read in the input file.
|
static String |
KEY_DATABASE
The key pointing the number of input data used for prediction.
|
static String |
KEY_DERIVE
The key pointing to a list of derivator files.
|
static String |
KEY_EXTRAPOLATE
The key pointing to a list of data points used for extrapolation.
|
static String |
KEY_FORMAT
The key to the output data formatter.
|
static String |
KEY_FUTURE
The key pointing to the number of points to predict/extrapolate.
|
static String |
KEY_INFILE
The key to the input file.
|
static String |
KEY_LINEAR
If present, only linear extrapolation is done.
|
static String |
KEY_OUTFILE
The key to the output file.
|
static String |
KEY_PREDICT
The key pointing to a list of linear prediction coefficient-counts.
|
static String |
KEY_RESIDUAL
If present, only residuals of the extrapolation are loaded.
|
static String |
KEY_SMOOTH
The key pointing to a list of smoother files.
|
private List |
predictions
The list to the data derived from applying linear prediction.
|
private List |
smoothers
The list to the data derived from applying the smoothers.
|
KEY_NOINITONCREATE, POSTFIX_ALPHABET, POSTFIX_BYTES, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_MODTIME, POSTFIX_URLKEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATORKEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOMECONFIG, KEY_CLASS| Constructor and Description |
|---|
SensorTest(Map<String,String> prop)
Constructs a new censor tester.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
applyDerivator()
Applies the numerical derivators stated in the
KEY_DERIVE
property. |
boolean |
applyExtrapolation()
Applies extrapolation as stated in the
KEY_EXTRAPOLATE
property. |
boolean |
applyPrediction()
Applies linear predictions as stated in the
KEY_PREDICT
property. |
boolean |
applySmoothing()
Applies the savitzky-goolay filters stated in the
KEY_SMOOTH
property. |
private double[] |
deriveOne(double[] indata,
SavitzkyGolaySmoothing sgs)
Numerically derives an entire data set using a savitzky-golay
filter.
|
private double[] |
extrapolateOne(double[] indata,
int base,
Extrapolation ext,
int fut)
Applies extrapolation to the entire data set.
|
static void |
main(String[] arg)
The main method.
|
private double[] |
predictOne(double[] indata,
int base,
int back,
int fut)
Applies linear prediction to the entire data set.
|
boolean |
readInput()
Reads the input data.
|
private double[] |
readInputFile(File infile)
Reads the input data from the given file.
|
private double[] |
smoothOne(double[] indata,
SavitzkyGolaySmoothing sgs)
Numerically derives an entire data set using a savitzky-golay
filter.
|
private void |
writeData(BufferedWriter out)
Writes the data sets.
|
private void |
writeHead(BufferedWriter out)
Writes a header to the output stream.
|
void |
writeOutput()
Writes the output data.
|
clone, createFrom, createFrom, createFrom, createInstance, getApplet, getAsResources, getLocate, getPropertiesToKey, getPropertiesToKey, getResource, getResourceAsStream, getResourceFromKey, getResources, hasLocalURLs, initProperties, keyCreate, keyCreate, reload, setAppletaugment, augment, augment, augment, augment, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, isNew, parseObject, parseObject, reload, removeProperty, requires, rescanned, setObject, setProperties, setProperty, stringProperties, toStringequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitdefaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, parseObject, removeProperty, setObject, setProperty, stringPropertiespublic static final String KEY_SMOOTH
public static final String KEY_DERIVE
public static final String KEY_BIAS
public static final String KEY_DATABASE
public static final String KEY_PREDICT
public static final String KEY_LINEAR
public static final String KEY_RESIDUAL
public static final String KEY_EXTRAPOLATE
public static final String KEY_FUTURE
public static final String KEY_INFILE
public static final String KEY_OUTFILE
public static final String KEY_COLUMN
public static final String KEY_FORMAT
private static final boolean DEFBIAS
private static final int DEFFUTURE
private static final String DEFOUTFILE
private static final int DEFCOLUMN
private static final String DEFFORMAT
private double[] input
private List smoothers
private List derivatives
private List predictions
private List extrapolations
private final NumberFormat df
public SensorTest(Map<String,String> prop)
KEY_FUTURE, KEY_COLUMN, KEY_FORMAT,
and KEY_OUTFILE.public boolean readInput()
KEY_COLUMN. At least
this column must be parsable as a double.private double[] readInputFile(File infile)
KEY_COLUMN. At least
this column must be parsable as a double.public boolean applySmoothing()
KEY_SMOOTH
property. This property is a comma-separated list of
smoother-definition files. Each valid entry (i.e. entries that can
be used to construct a savitsky-golay smoother) produces a data set
that is the smoothened of the input data. The data missing due to
the necessary pre-current data points is zero.private double[] smoothOne(double[] indata,
SavitzkyGolaySmoothing sgs)
public boolean applyDerivator()
KEY_DERIVE
property. This property is a comma-separated list of
derivator-definition files. Each valid entry (i.e. entries that can
be used to construct a savitsky-golay derivator) produces a data set
that is the first derivative of the input data. The data missing due to
the necessary pre-current data points is zero.private double[] deriveOne(double[] indata,
SavitzkyGolaySmoothing sgs)
public boolean applyPrediction()
KEY_PREDICT
property. This property is a comma-separated list of integers. Each
integer corresponds to the number of linear-prediction coefficients used
for the particular prediction. The input data base is constructed
from the sensor readings and narrowed down to the KEY_DATABASE
data-points back from the current sensor reading. Then, the linear
prediction coefficients according to the KEY_PREDICT numbers
are calculated. The linear prediction is then carried out for
KEY_FUTURE data points starting from the current data point.
This yields a single predicted value, stored in the output file.
The data (sum of KEY_DATABASE and KEY_FUTURE)
missing due to the necessary pre-current data points are zero.private double[] predictOne(double[] indata,
int base,
int back,
int fut)
public boolean applyExtrapolation()
KEY_EXTRAPOLATE
property. This property is a comma-separated list of integers. Each
integer corresponds to the number of measurements used
for the particular prediction. The input data base is constructed
from the sensor readings and narrowed down. Then, the extrapolating
polynom is calculated. If the KEY_LINEAR switch is present,
linear extrapolation is used, otherwise fitting to a parabolic is done.
The extrapolation is then carried out for the single
KEY_FUTURE data point, starting from the current data point.
This yields a single predicted value, stored in the output file.
The data (sum of KEY_EXTRAPOLATE and KEY_FUTURE)
missing due to the necessary pre-current data points are zero.private double[] extrapolateOne(double[] indata,
int base,
Extrapolation ext,
int fut)
public void writeOutput()
KEY_DERIVE property. After all derivative data, the linear
predicted data is added. Each predicted column corresponds to a number
of prediction coefficients, as stated in the KEY_PREDICT
property.private void writeHead(BufferedWriter out) throws IOException
derivatives list adds a ' D#' entry, where '#'
indicates the index of the derivator used. Using the predicted data sets
in the predictions list, similar ' P#' character
sequences are added.out - The stream to write toIOExceptionprivate void writeData(BufferedWriter out) throws IOException
IOExceptionpublic static void main(String[] arg) throws ParseException
SensorTest.Parser. Note that the input file may only be
specified with a switch, a command line argument is always a properties
file.ParseException