util
Class DataFileParser

java.lang.Object
  extended by util.CommandLineParser
      extended by util.PropertyParser
          extended by util.DataFileParser
Direct Known Subclasses:
Fourier.AbstractFile, LeastFourier.File, MinimumStringLength.File, MultipleFrequencyFit.File, OrbitFit.File, PhaseDispersionMinimization.File

public class DataFileParser
extends PropertyParser

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


Nested Class Summary
 
Nested classes/interfaces inherited from class util.CommandLineParser
CommandLineParser.Test
 
Field Summary
private  Analyser anal
          The analyser constructed from the properties.
static double DEFSPLITSIGMA
          Default split sigma.
protected static String FOOT
          A footer message.
protected static Map<String,String> MAP
           
private  ModelFitting mf
          The model fitter constructed from the properties.
private  NumberFormat[] nf
          The number formatters.
private static String ONESWITCHES
          The switches for adding properties.
private  PrintWriter out
          The print-stream.
private  NVector[] post
          The data post-processed.
private  NVector[] pre
          The data as precessed by the analyser.
private  Map<String,String> props
          The properties parsed.
private  NVector[] 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 DataFileParser(Map<String,String> shortcuts)
          Constructs the parser to the sensor tester.
 
Method Summary
protected  Analyser createAnalyser(Map<String,String> prop)
          Creates the analyser to use out of parsed properties.
protected  double extremalValue(double ev)
          Reformat the extremal Value to a different meaning?
protected  Analyser getAnalyser()
          Returns the data analyser.
protected  NVector[] getData()
          Returns the input data.
protected  int[] getForwardComplex()
          If the analysier's processed data is complex and we want to see that in the printout, return the indices as an integer array here.
protected  String getForwardHead()
          Returns a description of the analysers processed data.
protected  NVector[] getLinearFit(NVector[] data, int column, int mesh)
          Replaces a single data column with a spline fit of specified mesh-length.
protected  NVector[] getLinearFit(NVector[] data, int x, 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  int[] getPostComplex()
          If the analysier's visualized data is complex and we want to see that in the printout, return the indices as an integer array here.
protected  String getPostHead()
          Returns a description of the analysers processed data.
protected  String getProcessable()
          Returns the switches that should trigger a data processing.
protected  NVector[] getProcessedData()
          Returns the processed data.
protected  NVector[] getSplineFit(NVector[] data, int column, int mesh)
          Replaces a single data column with a spline fit of specified mesh-length.
protected  NVector[] getSplineFit(NVector[] data, int x, 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  NVector[] getVisualizedData()
          Returns the visualizable data.
protected  NVector[] getWhiteNoise(NVector[] data, int cc)
          Replaces a single data column with white noise.
protected  NVector[] getWhiteNoise(NVector[] 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.
static void main(String[] arg)
          Parses the command line and prints output to standard out.
protected  void print(NVector[] v, String head, int[] complex)
          Prints a data set using the parsed settings.
static void printOut(NumberFormat[] nf, PrintWriter out, NVector[] v, String head, int[] comp)
          Prints an array of a multidimensional vector to the given print stream.
static void printOut(PrintWriter out, NVector[] v, String head, int[] comp)
          Prints an array of a multidimensional vector to the given print stream.
protected  boolean process(String[] arg)
          Process the switches.
protected  boolean processData(NVector[] data)
          Processes a single junk of data, provided as an array of NVector If parsed with process(java.lang.String[]), 2dim and 3-dim data are arrays of Vector2D and Vector3D, respectively.
protected  boolean processSingleData(NVector[] workon)
           
private  boolean splitDataSet(int ilo, int ihi, int splitnr, NVector[] 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, 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

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 NVector[] set
The data. If parsed with xy or xyz, an array of Vector2D.


pre

private NVector[] pre
The data as precessed by the analyser.


post

private NVector[] post
The data post-processed.


props

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


anal

private Analyser anal
The analyser constructed from the properties.


mf

private ModelFitting mf
The model fitter constructed from the properties.


out

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


nf

private NumberFormat[] nf
The number formatters.

Constructor Detail

DataFileParser

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

Method Detail

createAnalyser

protected Analyser createAnalyser(Map<String,String> prop)
Creates the analyser to use out of parsed properties. The default application creates a fit analyser.


process

protected 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,
                             NVector[] data)
                      throws ParseException
Splite a data set and processes the splitted set.

Throws:
ParseException

processData

protected boolean processData(NVector[] data)
                       throws ParseException
Processes a single junk of data, provided as an array of NVector 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 principial 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 boolean processSingleData(NVector[] workon)
                             throws ParseException
Throws:
ParseException

getProcessable

protected String getProcessable()
Returns the switches that should trigger a data processing.


print

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


getWhiteNoise

protected NVector[] getWhiteNoise(NVector[] 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(NVector[], List) instead.


getWhiteNoise

protected NVector[] getWhiteNoise(NVector[] 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.


getSplineFit

protected NVector[] getSplineFit(NVector[] 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(NVector[], List, int) instead.


getSplineFit

protected NVector[] getSplineFit(NVector[] data,
                                 int x,
                                 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 NVector[] getLinearFit(NVector[] 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(NVector[], List, int) instead.


getLinearFit

protected NVector[] getLinearFit(NVector[] data,
                                 int x,
                                 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.


printOut

public static void printOut(PrintWriter out,
                            NVector[] 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,
                            NVector[] v,
                            String head,
                            int[] comp)
Prints an array of a multidimensional vector to the given print stream.


getAnalyser

protected Analyser getAnalyser()
Returns the data analyser.


getForwardComplex

protected int[] getForwardComplex()
If the analysier's processed data is complex and we want to see that in the printout, return the indices as an integer array here.


getForwardHead

protected String getForwardHead()
Returns a description of the analysers processed data.


getPostComplex

protected int[] getPostComplex()
If the analysier's visualized data is complex and we want to see that in the printout, return the indices as an integer array here.


getPostHead

protected String getPostHead()
Returns a description of the analysers processed data.


extremalValue

protected double extremalValue(double ev)
Reformat the extremal Value to a different meaning?


getData

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


getProcessedData

protected NVector[] getProcessedData()
Returns the processed data. Only availabel after a call to process(java.lang.String[]).


getVisualizedData

protected NVector[] getVisualizedData()
Returns the visualizable data. Only availabel after a call to process(java.lang.String[]).


main

public static void main(String[] arg)
                 throws ParseException,
                        IOException
Parses the command line and prints output to standard out.

Throws:
ParseException
IOException