saaps.util
Class TimeSeries

java.lang.Object
  |
  +--saaps.util.TimeSeries

public class TimeSeries
extends java.lang.Object
implements java.io.Serializable

See Also:
Serialized Form

Field Summary
static int aveArrDptOffset
           
static int aveArrStdvOffset
           
static int aveArrTypes
          Describes how many different types of data is in the average array.
 
Constructor Summary
TimeSeries(java.util.Date[] d, double[] m)
          Create a TimeSeries object from a Date vector and a double vector.
TimeSeries(java.util.Date[] d, double[][] m, java.lang.String[] fn, java.lang.String[] fu)
          Create the object from date array and the 2-D array.
TimeSeries(java.util.Date[] d, double[] m, java.lang.String fn, java.lang.String fu)
          Create a TimeSeries object from a Date vector and a double vector, and specify the data field names and units.
TimeSeries(java.util.Date[] d, Jama.Matrix m)
          Create a TimeSeries object from an array of Date objects and a Matrix.
TimeSeries(long st, long et, long si, int nodf)
          Create an empty time series object.
TimeSeries(java.util.Vector dbov)
          Create a TimeSeries object from a Vector of DatabaseObject:s
TimeSeries(java.util.Vector dbov, int fieldIndex)
          Create a TimeSeries object from a Vector of DatabaseObjects Use only the indicated data field.
TimeSeries(java.util.Vector dbov, java.lang.String[] fn, java.lang.String[] fu)
          Create a TimeSeries object from a Vector of DatabaseObject:s
 
Method Summary
 double[] average(boolean ignoreNaN)
          Get the average of a time series object.
 double[] average(java.util.Calendar date, boolean ignoreNaN)
          Gets the average of a time series object.
 TimeSeries averageFields()
          Average over the data fields.
 TimeSeries dailySum()
          Get the daily sum for each parameter for each day.
 TimeSeries extract(long st, long et)
          Extract a time period.
 Jama.Matrix getData()
          Get the data as a Matrix object.
 double[] getData(int i)
          Get the data for one row.
 double getData(int i, int j)
          Get one data element.
 java.util.Date getDate(int i)
          Get one Date object.
 java.util.Date[] getDates()
          Get the Date objects.
 java.lang.String[] getFieldNames()
          Gets the field names array.
 java.lang.String[] getFieldUnits()
          Gets the field units array.
 java.util.Date getLastDate()
          Get the last date in the time series.
 int getLength()
          Get the length of the TimeSeries object.
 java.lang.String getLongDescription()
          Get the long description of the data.
 int getNumOfDataFields()
          Get the number of data fields.
 long getSampleInterval()
          Get the sample interval.
 java.lang.String getShortDescription()
          Get the short description of the data.
 TimeSeries normalize(NormParam np)
          Method to normalize the data according to a NormParam object.
 void setData(int i, double[] x)
          Set one row of data.
 void setData(int i, int j, double x)
          Set data for observation i and data field j.
 void setFieldNames(java.lang.String[] fn)
          Sets the field names array.
 void setFieldUnits(java.lang.String[] fu)
          Sets the field units array.
 void setLongDescription(java.lang.String ld)
          Set the long description of the data.
 void setShortDescription(java.lang.String sd)
          Set the short description of the data.
 TimeSeries sumFields()
          Sum over the data fields.
 Jama.Matrix timeDelay(NormParam np)
          Method to create a time delay line.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

aveArrDptOffset

public static final int aveArrDptOffset

aveArrStdvOffset

public static final int aveArrStdvOffset

aveArrTypes

public static final int aveArrTypes
Describes how many different types of data is in the average array. ex. data,number of data points, standard deviation
Constructor Detail

TimeSeries

public TimeSeries(java.util.Date[] d,
                  double[] m)
Create a TimeSeries object from a Date vector and a double vector.
Parameters:
d - The dates.
m - The data.

TimeSeries

public TimeSeries(java.util.Date[] d,
                  double[] m,
                  java.lang.String fn,
                  java.lang.String fu)
Create a TimeSeries object from a Date vector and a double vector, and specify the data field names and units.
Parameters:
d - The dates.
m - The data.
fn - The field name.
fu - The field unit.

TimeSeries

public TimeSeries(java.util.Date[] d,
                  double[][] m,
                  java.lang.String[] fn,
                  java.lang.String[] fu)
Create the object from date array and the 2-D array. Set also the field names.

Note: All 2-D array rows must have the same length.

Parameters:
d - date array
m - 2-D array of double data (all rows same length)
fn - field names
fu - field units

TimeSeries

public TimeSeries(java.util.Vector dbov)
Create a TimeSeries object from a Vector of DatabaseObject:s
Parameters:
dbov - The DatabaseObject vector

TimeSeries

public TimeSeries(java.util.Vector dbov,
                  java.lang.String[] fn,
                  java.lang.String[] fu)
Create a TimeSeries object from a Vector of DatabaseObject:s
Parameters:
dbov - The DatabaseObject vector
fn - Field names
fu - Field units

TimeSeries

public TimeSeries(java.util.Vector dbov,
                  int fieldIndex)
           throws TimeSeriesIndexException
Create a TimeSeries object from a Vector of DatabaseObjects Use only the indicated data field.
Parameters:
dbov - The DatabaseObject vector
fieldIndex - field number in DatabaseObject data

TimeSeries

public TimeSeries(java.util.Date[] d,
                  Jama.Matrix m)
Create a TimeSeries object from an array of Date objects and a Matrix. The number of elements in the Date array must equal the number of rows in the Matrix object.
Parameters:
d - Array of Date object
m - Matrix of data.

TimeSeries

public TimeSeries(long st,
                  long et,
                  long si,
                  int nodf)
Create an empty time series object.
Method Detail

setFieldNames

public void setFieldNames(java.lang.String[] fn)
Sets the field names array.
Parameters:
field - names

setFieldUnits

public void setFieldUnits(java.lang.String[] fu)
Sets the field units array.
Parameters:
field - units

dailySum

public TimeSeries dailySum()
Get the daily sum for each parameter for each day.

Future version should include a check that all days contain the same number of data.


normalize

public TimeSeries normalize(NormParam np)
Method to normalize the data according to a NormParam object.
Parameters:
np - A NormParam object.

timeDelay

public Jama.Matrix timeDelay(NormParam np)
Method to create a time delay line. The resulting Matrix object has m rows and n columns, where m equals the length of the delay line and n equals the length of the TimeSeries object. The first m-1 columns will contain NaNs.
Parameters:
np - A NormParam object.

getLength

public int getLength()
Get the length of the TimeSeries object.

getDates

public java.util.Date[] getDates()
Get the Date objects.

getDate

public java.util.Date getDate(int i)
Get one Date object.

getData

public Jama.Matrix getData()
Get the data as a Matrix object.

getData

public double getData(int i,
                      int j)
Get one data element.

getData

public double[] getData(int i)
Get the data for one row.

getNumOfDataFields

public int getNumOfDataFields()
Get the number of data fields.

getShortDescription

public java.lang.String getShortDescription()
Get the short description of the data.
Returns:
The short description

getLongDescription

public java.lang.String getLongDescription()
Get the long description of the data.
Returns:
The long description

getFieldNames

public java.lang.String[] getFieldNames()
Gets the field names array.
Returns:
field names

getFieldUnits

public java.lang.String[] getFieldUnits()
Gets the field units array.
Returns:
field units

setShortDescription

public void setShortDescription(java.lang.String sd)
Set the short description of the data.
Parameters:
sd - The short description

setLongDescription

public void setLongDescription(java.lang.String ld)
Set the long description of the data.
Parameters:
ld - The short description

setData

public void setData(int i,
                    double[] x)
Set one row of data.

setData

public void setData(int i,
                    int j,
                    double x)
Set data for observation i and data field j.
Parameters:
i - The index for one observation
j - The index of the data field
x - The value to be set

average

public double[] average(boolean ignoreNaN)
Get the average of a time series object.

average

public double[] average(java.util.Calendar date,
                        boolean ignoreNaN)
Gets the average of a time series object. The returned array contains the averaged data, then the number of datapoints used in the average for every datapoint, then the standard deviation for every data point.
Parameters:
date - centre time of data interval is returned here
ignoreNaN - if true ignore NaN data
Returns:
averaged data and additional information about the average

extract

public TimeSeries extract(long st,
                          long et)
Extract a time period.

sumFields

public TimeSeries sumFields()
Sum over the data fields.

averageFields

public TimeSeries averageFields()
Average over the data fields.

getLastDate

public java.util.Date getLastDate()
Get the last date in the time series.
Returns:
The last date.

getSampleInterval

public long getSampleInterval()
Get the sample interval.
Returns:
The sample interval.