util
Class DataFileReader

java.lang.Object
  extended by util.CommandLineParser
      extended by util.PropertyParser
          extended by util.DataFileReader
Direct Known Subclasses:
DataFileAnalyser, DataFileModel, DataFileReader.Ascii, GeneralLinearRegression.Corot, JPhasePlot.Plot

public abstract class DataFileReader
extends PropertyParser

Convenience class for parsing command lines to read in from a data file.


Nested Class Summary
static class DataFileReader.Ascii
          Does spline/filtering etc.
 
Nested classes/interfaces inherited from class util.CommandLineParser
CommandLineParser.Test
 
Field Summary
static double DEFSPLITSIGMA
          Default split sigma.
protected static String FOOT
          A footer message.
private static String FOURSWITCHES
          The switches for adding properties.
protected static Map<String,String> MAP
           
protected  NumberFormat[] nf
          The number formatters.
private static String ONESWITCHES
          The switches for adding properties.
protected  PrintWriter out
          The print-stream.
private  Map<String,String> props
          The properties parsed.
private  VectorG[] set
          The data.
private static String THREESWITCHES
          The switches for adding properties.
private static String TWOSWITCHES
          The switches for adding properties.
protected static Map<String,String> USE
          Detailed use of switches.
private static String ZEROSWITCHES
          The switches for adding properties.
 
Constructor Summary
protected DataFileReader(Map<String,String> shortcuts)
          Constructs the parser to the sensor tester.
 
Method Summary
protected  VectorG[] getData()
          Returns the input data.
protected  VectorG[] getLinearFit(VectorG[] data, int column, int mesh)
          Replaces a single data column with a spline fit of specified mesh-length.
protected  VectorG[] getLinearFit(VectorG[] data, List<Integer> cols, int len)
          Returns a new data array, where the specified columns are replaced with a linear fit of the original data.
protected  Map<String,String> getParsedProperties()
          Returns parsed properties, if there are any.
protected  VectorG[] getPiecewisePolynomialFit(VectorG[] data, int column, int poly, double tl, double tr, int deriv)
           
protected  VectorG[] getPiecewisePolynomialFit(VectorG[] data, List<Integer> columns, int poly, double tl, double tr, int deriv)
           
protected  VectorG[] getSplineFit(VectorG[] data, int column, int mesh)
          Replaces a single data column with a spline fit of specified mesh-length.
protected  VectorG[] getSplineFit(VectorG[] data, List<Integer> cols, int len)
          Returns a new data array, where the specified columns are replaced with a natural cubic spline fit of the original data.
protected  VectorG[] getWhiteNoise(VectorG[] data, int cc)
          Replaces a single data column with white noise.
protected  VectorG[] getWhiteNoise(VectorG[] data, List<Integer> columns)
          Returns a new data array, where the specified columns are replaced with white noise of the same average and sigma as the original data.
protected  void print(VectorG[] v, String head, int[] complex)
          Prints a data set using the parsed settings.
private static void printModel(VectorG x, VectorG y, VectorG fit)
           
static void printOut(NumberFormat[] nf, PrintWriter out, VectorG[] v, String head, int[] comp)
          Prints an array of a multidimensional vector to the given print stream.
static void printOut(PrintWriter out, VectorG[] v, String head, int[] comp)
          Prints an array of a multidimensional vector to the given print stream.
 boolean process(String[] arg)
          Process the switches.
protected  boolean processData(VectorG[] data)
          Processes a single junk of data, provided as an array of VectorG If parsed with process(java.lang.String[]), 2dim and 3-dim data are arrays of Vector2D and Vector3D, respectively.
protected abstract  boolean processSingleData(VectorG[] workon)
          After filtering/splining/splitting or smoothing of the data, this is the method that processes the single data.
protected  boolean processSingleData(VectorG[] workon, VectorG[] data)
          After the base class supported so many filtering options, this method was additionally introduced as a escape-pod for data processors that need the original data along with the pre-processed, i.e.
private  VectorG[] rejectData(VectorG[] org, VectorG[] workon, double losig, double hisig, double loabs, double hiabs, int yc)
          If workon and org are of same size, we reject from the original set the data that is too far off
private  boolean splitDataSet(int ilo, int ihi, int splitnr, VectorG[] data)
          Splite a data set and processes the splitted set.
 
Methods inherited from class util.PropertyParser
parseMap, parseMap, parseProperties, parseProperties, parseProperties
 
Methods inherited from class util.CommandLineParser
getArguments, getCommandLine, getCommands, getRegisteredSwitches, hasAnySwitch, hasSwitch, hasSwitch, haveAllSwitches, parse, printCommandLine, registerLine, registerSwitches, setCommands, staticUsage, usage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFSPLITSIGMA

public static final double DEFSPLITSIGMA
Default split sigma.

See Also:
Constant Field Values

ZEROSWITCHES

private static final String ZEROSWITCHES
The switches for adding properties.

See Also:
Constant Field Values

ONESWITCHES

private static final String ONESWITCHES
The switches for adding properties.

See Also:
Constant Field Values

TWOSWITCHES

private static final String TWOSWITCHES
The switches for adding properties.

See Also:
Constant Field Values

THREESWITCHES

private static final String THREESWITCHES
The switches for adding properties.

See Also:
Constant Field Values

FOURSWITCHES

private static final String FOURSWITCHES
The switches for adding properties.

See Also:
Constant Field Values

USE

protected static final Map<String,String> USE
Detailed use of switches.


MAP

protected static final Map<String,String> MAP

FOOT

protected static final String FOOT
A footer message.

See Also:
Constant Field Values

set

private VectorG[] set
The data. If parsed with xy or xyz, an array of Vector2D.


props

private Map<String,String> props
The properties parsed.


out

protected PrintWriter out
The print-stream. Either System.out or the file named.


nf

protected NumberFormat[] nf
The number formatters.

Constructor Detail

DataFileReader

protected DataFileReader(Map<String,String> shortcuts)
Constructs the parser to the sensor tester. All known switches are registered.

Method Detail

process

public boolean process(String[] arg)
                throws ParseException
Process the switches. After processing, data can be accessed.

Returns:
True, if processing was successful.
Throws:
ParseException

splitDataSet

private boolean splitDataSet(int ilo,
                             int ihi,
                             int splitnr,
                             VectorG[] data)
                      throws ParseException
Splite a data set and processes the splitted set.

Throws:
ParseException

getParsedProperties

protected Map<String,String> getParsedProperties()
Returns parsed properties, if there are any.


processData

protected boolean processData(VectorG[] data)
                       throws ParseException
Processes a single junk of data, provided as an array of VectorG If parsed with process(java.lang.String[]), 2dim and 3-dim data are arrays of Vector2D and Vector3D, respectively. The data, spline and linear interpolation fits and even white noise data can be retrieved using the appropriate methods. Only after this method is called, the principal data and the processed and visualized data can be retrieved.
If the split-number of the data set is negativ it is ignored, otherwise a possible output stream is augmented with the split number.

Throws:
ParseException

processSingleData

protected abstract boolean processSingleData(VectorG[] workon)
                                      throws ParseException
After filtering/splining/splitting or smoothing of the data, this is the method that processes the single data. Without any of the filtering switches, this is the data read in from the data file. If one also needs the original data, not only the filtered one, override processSingleData(VectorG[], VectorG[]).

Parameters:
workon -
Returns:
True if processing was successful.
Throws:
ParseException

processSingleData

protected boolean processSingleData(VectorG[] workon,
                                    VectorG[] data)
                             throws ParseException
After the base class supported so many filtering options, this method was additionally introduced as a escape-pod for data processors that need the original data along with the pre-processed, i.e. filtered one. The default implementation points to processSingleData(VectorG[]), suppressing simply the raw data.

Parameters:
workon - The pre-processed, i.e. filtered data
data - The original data.
Returns:
True if processing was successful.
Throws:
ParseException

print

protected void print(VectorG[] v,
                     String head,
                     int[] complex)
Prints a data set using the parsed settings.


getWhiteNoise

protected VectorG[] getWhiteNoise(VectorG[] data,
                                  int cc)
Replaces a single data column with white noise. This method is not recommended, if you want to exchange several columns at once, use getWhiteNoise(VectorG[], List) instead.


getWhiteNoise

protected VectorG[] getWhiteNoise(VectorG[] data,
                                  List<Integer> columns)
Returns a new data array, where the specified columns are replaced with white noise of the same average and sigma as the original data. Does not destroy the old data.


getPiecewisePolynomialFit

protected VectorG[] getPiecewisePolynomialFit(VectorG[] data,
                                              int column,
                                              int poly,
                                              double tl,
                                              double tr,
                                              int deriv)

getPiecewisePolynomialFit

protected VectorG[] getPiecewisePolynomialFit(VectorG[] data,
                                              List<Integer> columns,
                                              int poly,
                                              double tl,
                                              double tr,
                                              int deriv)

rejectData

private VectorG[] rejectData(VectorG[] org,
                             VectorG[] workon,
                             double losig,
                             double hisig,
                             double loabs,
                             double hiabs,
                             int yc)
If workon and org are of same size, we reject from the original set the data that is too far off


printModel

private static final void printModel(VectorG x,
                                     VectorG y,
                                     VectorG fit)

getSplineFit

protected VectorG[] getSplineFit(VectorG[] data,
                                 int column,
                                 int mesh)
Replaces a single data column with a spline fit of specified mesh-length. This method is not recommended, if you want to exchange several columns at once, use getSplineFit(VectorG[], List, int) instead.


getSplineFit

protected VectorG[] getSplineFit(VectorG[] data,
                                 List<Integer> cols,
                                 int len)
Returns a new data array, where the specified columns are replaced with a natural cubic spline fit of the original data. Does not destroy the old data.


getLinearFit

protected VectorG[] getLinearFit(VectorG[] data,
                                 int column,
                                 int mesh)
Replaces a single data column with a spline fit of specified mesh-length. This method is not recommended, if you want to exchange several columns at once, use getSplineFit(VectorG[], List, int) instead.


getLinearFit

protected VectorG[] getLinearFit(VectorG[] data,
                                 List<Integer> cols,
                                 int len)
Returns a new data array, where the specified columns are replaced with a linear fit of the original data. Does not destroy the old data.


printOut

public static void printOut(PrintWriter out,
                            VectorG[] v,
                            String head,
                            int[] comp)
Prints an array of a multidimensional vector to the given print stream.


printOut

public static void printOut(NumberFormat[] nf,
                            PrintWriter out,
                            VectorG[] v,
                            String head,
                            int[] comp)
Prints an array of a multidimensional vector to the given print stream.


getData

protected VectorG[] getData()
Returns the input data. Only availabel after a call to process(java.lang.String[]).