public class Spectrum2D extends MatrixType implements AsciiComm, Spectral
Spectrum2D assumes the variables are uniformly sampled in both directions. It introduces new parameter arrays resolution, twoSided (set to true, highestFrequency, narrow (set to false), and nFull. These parameters have the same meaning as in ComplexSpectrum, but are 2-dimensional arrays for the 2 spectral dims.
MatrixType
,
TrianaType
,
GraphType
,
Spectrum
,
ComplexSpectrum
,
Spectral
,
Serialized FormNOT_CONNECTED, NOT_READY, OUT_OF_RANGE
Constructor and Description |
---|
Spectrum2D()
Creates a new empty Spectrum2D, with no parameters set
|
Spectrum2D(boolean complex,
int[] lengths,
double[] df)
Creates a new Spectrum2D with arguments giving whether the data are to be complex.
|
Spectrum2D(double[][] zr,
double[][] zi,
double[] df)
Creates a new Spectrum2D with argument arrays giving the 2D data matrix, or two matrices if the data is complex,
and the frequency resolution in each dimension.
|
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 Spectrum2D.
|
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(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 data is real.
|
double[] |
getIndependentScaleReal(int dim)
Returns the independent data scaled the way they should be graphed.
|
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.
|
java.lang.Object |
getOrderedSpectrumImag()
Returns the imaginary parts of the values of the spectrum (data points) in a multidimensional array, ordered so
that in each dimension the values correspond to frequencies running from the lowest to the highest, regardless of
the internal data model.
|
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
both dimensions the values correspond to frequencies running from the lowest to the highest, regardless of the
internal data model.
|
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 |
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(int dim)
Returns false.
|
boolean |
isTwoSided()
Returns true.
|
void |
outputToStream(java.io.PrintWriter dos)
Used when Triana types want to be able to send ASCII data to other programs using strings.
|
void |
setFrequencyResolution(double df,
int dim)
Sets the frequency resolution of the data for the given dimension to the given value.
|
void |
setNarrow(boolean n,
int dim)
Does nothing.
|
void |
setOriginalN(int nOrig,
int dim)
Sets to the given first argument nOrig the number of points in the data set 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 |
setTwoSided(boolean s)
Does nothing.
|
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 Spectrum2D()
public Spectrum2D(boolean complex, int[] lengths, double[] df)
complex
- True if the data is to be complexlengths
- Number of frequency points in the current data setdf
- Frequency resolution in each dimensionpublic Spectrum2D(double[][] zr, double[][] zi, double[] df)
zr
- the real part of the datazi
- the imaginary part of the data, null if absentdf
- Frequency resolutionpublic double getFrequencyResolution(int dim)
getFrequencyResolution
in interface Spectral
dim
- The index of the independent variable being queriedpublic void setFrequencyResolution(double df, int dim)
setFrequencyResolution
in interface Spectral
dim
- The index of the independent variable being querieddf
- 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 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 boolean isNarrow(int dim)
public void setNarrow(boolean n, int dim)
public double getLowerFrequencyBound(int dim)
getLowerFrequencyBound
in interface Spectral
dim
- The index of the independent variable being queriedpublic double getUpperFrequencyBound(int dim)
getUpperFrequencyBound
in interface Spectral
dim
- The index of the independent variable being queriedpublic 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 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[] 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 Spectrum2D, this method tests for compatibility with superior classes, to see that the input object is a Spectrum2D, 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 tested