public class TimeFrequency extends MatrixType implements AsciiComm, Spectral, Signal
TimeFrequency assumes the variables are uniformly sampled in both directions. It introduces new parameters resolution, twoSided, highestFrequency, narrow, and nFull, as in ComplexSpectrum. It further introduces parameters samplingRate and acquisitionTime, as in SampleSet. Finally it introduces interval, the time-interval between successive time-sets along the time axis.
MatrixType
,
TrianaType
,
GraphType
,
SampleSet
,
ComplexSpectrum
,
Spectral
,
Signal
,
Serialized FormNOT_CONNECTED, NOT_READY, OUT_OF_RANGE
Constructor and Description |
---|
TimeFrequency()
Creates a new empty TimeFrequency, with no parameters set
|
TimeFrequency(boolean complex,
boolean ts,
boolean nrw,
int lenf,
int nOrig,
double df,
double hf,
double iv,
int lent,
double acTime)
Creates a new TimeFrequency with arguments giving whether the data are to be complex, the sidedness, whether it
is narrow-band or broad-band, the data length, the number of points in the original broad-band spectrum, the
frequency resolution, the highest frequency in the current spectrum, the interval between data sets along the
time-axis, the number of data sets, and the acquisition time of the first data point.
|
TimeFrequency(boolean complex,
boolean ts,
int nOrig,
double df,
double iv,
int lent,
double acTime)
Creates a new TimeFrequency with a given complexity, sidedness, number of points that there would be in a single
two-sided spectrum, frequency resolution, interval between time-sets, number of time-sets, and acquisition tim
eof the first sample.
|
TimeFrequency(double[][] zr,
double[][] zi,
boolean ts,
boolean nrw,
int nOrig,
double df,
double hf,
double iv,
double acTime)
Creates a new TimeFrequency with arguments giving the 2D data matrix, or two matrices if the data is complex, the
sidedness, whether it is narrow-band or broad-band, the number of points in the original broad-band spectrum, the
frequency resolution, the highest frequency in the current spectrum, the interval between data sets along the
time-axis, and the acquisition time of the first data point.
|
Modifier and Type | Method and Description |
---|---|
TrianaType |
copyMe()
This is one of the most important methods of Triana data.
|
protected void |
copyParameters(TrianaType source)
Copies modifiable parameters from the argument object to the current object.
|
boolean |
equals(TrianaType obj)
Determines whether the argument TrianaType is equal to the current TimeFrequency.
|
double |
getAcquisitionTime()
Returns the acquisition time as a double giving the number of seconds since the reference time, which should be
the same reference time as for the method setAcquisitionTime.
|
double[] |
getFrequencyArray(int dim)
Returns the frequency values of the independent data points for the given dimension, in the order of lowest
frequency to highest, regardless of how the data are stored internally.
|
double |
getFrequencyResolution()
Returns the frequency resolution of the data along the frequency axis.
|
double |
getFrequencyResolution(int dim)
Returns the frequency resolution of the data for the given dimension (independent variable).
|
java.lang.Object |
getGraphArrayImag(int dv)
Returns the imaginary part of the dependent variable ordered so that the frequency values all run monotonically
upwards.
|
java.lang.Object |
getGraphArrayReal(int dv)
Returns the real part of the dependent variable ordered so that the frequency values all run monotonically
upwards.
|
double[] |
getIndependentScaleImag(int dim)
Returns null because the independent data on both axes are real.
|
double[] |
getIndependentScaleReal(int dim)
Returns the independent data scaled the way they should be graphed.
|
double |
getInterval()
Gets the interval between data sets, in seconds.
|
double |
getLowerFrequencyBound()
Returns the (non-negative) value of the lowest frequency in the frequency band held in the object.
|
double |
getLowerFrequencyBound(int dim)
Returns the (non-negative) value of the lowest frequency in the frequency band held in the object, for the given
dimension dim.
|
double |
getNyquist()
Returns the Nyquist frequency, defined to be the highest frequency that this data set could contain if it were
not narrow-banded.
|
java.lang.Object |
getOrderedSpectrumImag()
Returns the imaginary parts of the values of the spectrum (data points) in a multidimensional array, ordered so
that in the frequency dimension (index 1, the vertical dimension of the matrix) the values correspond to
frequencies running from the lowest to the highest.
|
java.lang.Object |
getOrderedSpectrumReal()
Returns the real parts of the values of the spectrum (data points) in a two-dimensional array, ordered so that in
the frequency dimension (which is the vertical dimension, index 1) the values correspond to frequencies running
from the lowest to the highest.
|
int |
getOriginalN()
Returns the number of points in the data set associated with each time (each column of the matrix) whose
transform could have led to the present data, or equivalently the number of points in the two-sided
full-bandwidth spectrum from which the present spectrum could have been derived.
|
int |
getOriginalN(int dim)
Returns the number of points in the data set in the frequency dimension whose transform could have led to the
present data, or equivalently the number of points in the two-sided full-bandwidth spectrum from which the
present spectrum could have been derived.
|
double |
getSamplingRate()
Returns the sampling frequency of the data.
|
double |
getUpperFrequencyBound()
Returns the (non-negative) value of the highest frequency in the frequency band held in the object.
|
double |
getUpperFrequencyBound(int dim)
Returns the (non-negative) value of the highest frequency in the frequency band held in the object, for the given
dimension dim.
|
void |
inputFromStream(java.io.BufferedReader dis)
Used when Triana types want to be able to receive ASCII data from the output of other programs.
|
boolean |
isCompatible(TrianaType obj)
Tests the argument object to determine if it makes sense to perform arithmetic operations between it and the
current object.
|
boolean |
isNarrow()
Returns true if the data represent a narrow bandwidth derived from a full-band spectrum.
|
boolean |
isNarrow(int dim)
Returns true if the data for the given dimension represent a narrow bandwidth derived from a full-band spectrum.
|
boolean |
isTwoSided()
Returns true if the frequency data are stored as a two-sided transform, i.e.
|
void |
outputToStream(java.io.PrintWriter dos)
Used when Triana types want to be able to send ASCII data to other programs using strings.
|
static TimeFrequency |
reduceNyquist(TimeFrequency inputNarrow,
boolean allocMem)
Class method that takes an input narrow-band TimeFrequency and reduces nFull to be compatible with the
upper frequency bound, so that the set is no longer narrow-band at the top.
|
void |
setAcquisitionTime(double t)
Sets the acquisition time.
|
void |
setFrequencyResolution(double df)
Sets the frequency resolution of the data along the frequency axis to the given value.
|
void |
setFrequencyResolution(double f,
int dim)
Sets the frequency resolution of the data for the given dimension to the given value.
|
void |
setInterval(double iv)
Sets the interval between data sets, in seconds.
|
void |
setNarrow(boolean n)
Sets the narrow-bandedness flag to the value of the argument.
|
void |
setNarrow(boolean n,
int dim)
Sets the narrow-bandedness flag associated with the given dimension to the value of the argument.
|
void |
setOriginalN(int nOrig)
Sets to the given argument the number of points in the data set associated with each time (each column of the
matrix) whose transform could have led to the present data, or equivalently the number of points in the two-sided
full-bandwidth spectrum from which the present spectrum could have been derived.
|
void |
setOriginalN(int nOrig,
int dim)
Sets to the given first argument nOrig the number of points in the data set associated with each time
(each column of the matrix) in the dimension given by the second argument dim whose transform could have
led to the present data, or equivalently the number of points in the two-sided full-bandwidth spectrum from which
the present spectrum could have been derived.
|
void |
setSamplingRate(double r)
Sets the sampling rate of the signal and adjusts the data for the independent variable accordingly.
|
void |
setTwoSided(boolean s)
Sets the two-sidedness flag to the value of the argument.
|
void |
setUpperFrequencyBound(double hf)
Sets the (non-negative) value of the highest frequency in the frequency band held in the object to the given
value.
|
void |
setUpperFrequencyBound(double hf,
int dim)
Sets or resets the (non-negative) value of the highest frequency in the frequency band held in the object for the
given direction dim to the value of the given argument hf.
|
getData, getDataImag, getDataReal, getXorYArray, getXorYImag, getXorYReal, getXorYTriplet, initialiseData, initialiseDataComplex, initialiseDataReal, length, setData, setData, setXorY, setXorY, size, testDataModel
add, addToTitle, convertDependentDataArraysToBytes, convertDependentDataArraysToDoubles, convertDependentDataArraysToFloats, convertDependentDataArraysToInts, convertDependentDataArraysToLongs, convertDependentDataArraysToShorts, copyData, copyLabels, divide, equals, getDataArrayClass, getDataArrayImag, getDataArrayImag, getDataArrayImagAsBytes, getDataArrayImagAsDoubles, getDataArrayImagAsFloats, getDataArrayImagAsInts, getDataArrayImagAsLongs, getDataArrayImagAsShorts, getDataArrayReal, getDataArrayReal, getDataArrayRealAsBytes, getDataArrayRealAsDoubles, getDataArrayRealAsFloats, getDataArrayRealAsInts, getDataArrayRealAsLongs, getDataArrayRealAsShorts, getDataArrayTypeNames, getDependentLabels, getDependentVariableDimensions, getDependentVariables, getDimensionLengths, getDimensionLengths, getGraphArrayImagLog10, getGraphArrayRealLog10, getIndependentArrayImag, getIndependentArrayReal, getIndependentLabels, getIndependentScaleImagLog10, getIndependentScaleRealLog10, getIndependentTriplet, getIndependentVariables, getLabels, getLabelsColumn, getTitle, isArithmeticArray, isArithmeticData, isCompatible, isDependentComplex, isIndependentComplex, isPrimitiveArray, isPrimitiveData, isTriplet, isUniform, maxDependentGraphingValuesImag, maxDependentGraphingValuesReal, maxDependentVariablesImag, maxDependentVariablesReal, maxIndependentScalesImag, maxIndependentScalesReal, maxIndependentVariablesImag, maxIndependentVariablesReal, minDependentGraphingValuesImag, minDependentGraphingValuesReal, minDependentVariablesImag, minDependentVariablesReal, minIndependentScalesImag, minIndependentScalesReal, minIndependentVariablesImag, minIndependentVariablesReal, multiply, resetDependent, resetIndependent, restrictToSubdomain, restrictToSubdomain, setDataArrayImag, setDataArrayReal, setDefaultAxisLabelling, setDependentLabels, setDependentVariableDimensions, setDimensionLengths, setDimensionLengths, setDimensions, setIndependentArrayImag, setIndependentArrayReal, setIndependentLabels, setIndependentTriplet, setIndependentTriplet, setLabels, setTitle, subtract
containerSize, dataExists, deleteFromContainer, getDataContainer, getFromContainer, getSequenceNumber, insertIntoContainer, inspectDataContainer, setDataContainer, setSequenceNumber, updateObsoletePointers
public TimeFrequency()
public TimeFrequency(boolean complex, boolean ts, boolean nrw, int lenf, int nOrig, double df, double hf, double iv, int lent, double acTime)
complex
- True if the data is to be complexts
- True if the new TimeFrequency is to be two-sidednrw
- True if the new TimeFrequency is to be narrow-bandlenf
- Number of frequency points in the current data setnOrig
- Number of points in the original two-sided full spectrumdf
- Frequency resolutionhf
- Highest frequency in the current data setiv
- The time-interval between sets along the time-axislent
- The number of time-setsacTime
- The time of acquisition of the first sample of the first setpublic TimeFrequency(double[][] zr, double[][] zi, boolean ts, boolean nrw, int nOrig, double df, double hf, double iv, double acTime)
zr
- the real part of the datazi
- the imaginary part of the datats
- True if the new TimeFrequency is to be two-sidednrw
- True if the new TimeFrequency is to be narrow-bandnOrig
- Number of points in the original two-sided full spectrumdf
- Frequency resolutionhf
- Highest frequency in the current data setiv
- The time-interval between sets along the time-axisacTime
- The time of acquisition of the first sample of the first setpublic TimeFrequency(boolean complex, boolean ts, int nOrig, double df, double iv, int lent, double acTime)
complex
- True if the data is to be complexts
- True if the new TimeFrequency is to be two-sidednOrig
- Number of points in the original two-sided full spectrumdf
- Frequency resolutioniv
- The time-interval between sets along the time-axislent
- The number of time-setsacTime
- The time of acquisition of the first sample of the first setpublic double getFrequencyResolution(int dim)
getFrequencyResolution
in interface Spectral
dim
- The index of the independent variable being queriedpublic double getFrequencyResolution()
public void setFrequencyResolution(double f, int dim)
setFrequencyResolution
in interface Spectral
dim
- The index of the independent variable being queriedf
- The frequency resolutionpublic void setFrequencyResolution(double df)
df
- The frequency resolutionpublic boolean isTwoSided()
isTwoSided
in interface Spectral
public void setTwoSided(boolean s)
setTwoSided
in interface Spectral
s
- True if the data will be two-sidedpublic int getOriginalN(int dim)
getOriginalN
in interface Spectral
dim
- The index of the independent variable being queriedpublic int getOriginalN()
public void setOriginalN(int nOrig, int dim)
setOriginalN
in interface Spectral
dim
- The index of the independent variable being queriednOrig
- The new number of points in the original data setpublic void setOriginalN(int nOrig)
nOrig
- The new number of points in the original data setpublic boolean isNarrow(int dim)
public boolean isNarrow()
public void setNarrow(boolean n, int dim)
public void setNarrow(boolean n)
n
- True if the data held are narrow-bandpublic double getLowerFrequencyBound(int dim)
getLowerFrequencyBound
in interface Spectral
dim
- The index of the independent variable being queriedpublic double getLowerFrequencyBound()
public double getUpperFrequencyBound(int dim)
getUpperFrequencyBound
in interface Spectral
dim
- The index of the independent variable being queriedpublic double getUpperFrequencyBound()
public void setUpperFrequencyBound(double hf, int dim)
setUpperFrequencyBound
in interface Spectral
dim
- The index of the independent variable being queriedhf
- The new highest frequency represented in the given directionpublic void setUpperFrequencyBound(double hf)
hf
- The new highest frequencypublic double[] getFrequencyArray(int dim)
getFrequencyArray
in interface Spectral
dim
- The dimension of the independent variablepublic java.lang.Object getOrderedSpectrumReal()
getOrderedSpectrumReal
in interface Spectral
public java.lang.Object getOrderedSpectrumImag()
getOrderedSpectrumImag
in interface Spectral
public double getNyquist()
The general formula is that if the original number of data points (given by nFull = getOriginalN()) is even, then the Nyquist frequency is nFull * resolution / 2. If the original number of data points is odd, then the Nyquist frequency is (nFull -1 ) * resolution / 2.
public double getSamplingRate()
getSamplingRate
in interface Signal
public void setSamplingRate(double r)
setSamplingRate
in interface Signal
r
- The sampling ratepublic double getAcquisitionTime()
getAcquisitionTime
in interface Signal
public void setAcquisitionTime(double t)
setAcquisitionTime
in interface Signal
t
- The acquisition time in secondspublic double getInterval()
public void setInterval(double iv)
iv
- The new interval between data sets, in secondspublic double[] getIndependentScaleReal(int dim)
getIndependentScaleReal
in class GraphType
dim
- The independent dimension under considerationpublic double[] getIndependentScaleImag(int dim)
getIndependentScaleImag
in class GraphType
dim
- The independent dimension under considerationpublic java.lang.Object getGraphArrayReal(int dv)
getGraphArrayReal
in class GraphType
dv
- The dependent variable dimensionpublic java.lang.Object getGraphArrayImag(int dv)
getGraphArrayImag
in class GraphType
dv
- The dependent variable dimensionpublic TrianaType copyMe()
To override, the programmer should not invoke the super.copyMe method. Instead, create an object of the current type and call methods copyData and copyParameters. If these have been written correctly, then they will do the copying. The code should createTool, for type YourType:
YourType y = null; try { y = (YourType)getClass().newInstance(); y.copyData( this ); y.copyParameters( this ); y.setLegend( this.getLegend() ); } catch (IllegalAccessException ee) { System.out.println("Illegal Access: " + ee.getMessage()); } catch (InstantiationException ee) { System.out.println("Couldn't be instantiated: " + ee.getMessage()); } return y;
The copied object's data should be identical to the original. The method here modifies only one item: a String indicating that the object was created as a copy is added to the description StringVector.
copyMe
in class MatrixType
protected void copyParameters(TrianaType source)
This must be overridden by any subclass that defines new parameters. The overriding method should invoke its super method. It should use the set... and get... methods for the parameters in question. This method is protected so that it cannot be called except by objects that inherit from this one. It is called by copyMe.
copyParameters
in class GraphType
source
- Data object that contains the data to be copied.public void outputToStream(java.io.PrintWriter dos) throws java.io.IOException
This method must be overridden in every subclass that defines new data or parameters. The overriding method should first call<
super.outputToStream(dos)to get output from superior classes, and then new parameters defined for the current subclass must be output. Moreover, subclasses that first dimension their data arrays must explicitly transfer these data arrays.
outputToStream
in interface AsciiComm
outputToStream
in class GraphType
dos
- The data output streamjava.io.IOException
public void inputFromStream(java.io.BufferedReader dis) throws java.io.IOException
This method must be overridden in every subclass that defines new data or parameters. The overriding method should first call
super.inputFromStream(dis)to get input from superior classes, and then new parameters defined for the current subclass must be input. Moreover, subclasses that first dimension their data arrays must explicitly transfer these data arrays.
inputFromStream
in interface AsciiComm
inputFromStream
in class GraphType
dis
- The data input streamjava.io.IOException
public boolean isCompatible(TrianaType obj)
In TimeFrequency, this method tests for compatibility with superior classes, to see that the input object is a TimeFrequency, and to see if the relevant parameters are equal. It does not enforce equality of acquisitionTime because it may be desirable to compare two data sets acquired at different times.
Classes derived from this should over-ride this method with further tests as appropriate. The over-riding method should normally have the first lines
boolean test = super.isCompatible( obj );followed by other tests. If other types not subclassed from GraphType or Const should be allowed to be compatible then other tests must be implemented.
isCompatible
in class MatrixType
obj
- The data object to be compared with the current onepublic boolean equals(TrianaType obj)
This method must be over-ridden in derived types. In a derived type called xxx the method should begin
if ( !( obj instanceof xxx ) ) return false; if ( !isCompatible( obj ) ) return false;followed by tests that are specific to type xxx (testing its own parameters) and then as a last line
return super.equals( obj );This line invokes the other equals methods up the chain to GraphType. Each superior object tests its own parameters.
obj
- The object being testedpublic static TimeFrequency reduceNyquist(TimeFrequency inputNarrow, boolean allocMem)
inputNarrow
- The input narrow-band spectrumallocMem
- True if the output is a modified copy of input