|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectuk.ac.ed.ph.signal.Signal
public abstract class Signal
Abstract class to represent a Signal where the signal in held as a one-dimensional DataArray from the jfftw package.
Use of this class should be via RealSignal
and ComplexSignal
the two extending
classes.
Field Summary | |
---|---|
protected DataArray |
data
The DataArray to hold the data |
protected static String |
fmt
Format string for output |
protected ptolemy.plot.Plot |
plot
Plot holding graphical information. |
Constructor Summary | |
---|---|
Signal()
|
Method Summary | |
---|---|
void |
add(int i,
Complex c)
Method to add a Complex to an element. |
void |
add(int i,
double a)
Method to add a scalar to an element. |
void |
add(int i,
double a,
double b)
Method to add a complex to an element. |
void |
add(Signal s)
Method to add a specified Signal to the current Signal, both must be the same size. |
void |
centreFourier()
Method to form centred Fourier using applying checker pattern to shift DC the centre of the array. |
void |
conjugate()
Method to take conjugate of the whole Signal. |
void |
conjugate(int i)
Method to form the Complex conjugate of an element. |
void |
fillSine(double amp,
double freq,
double phase,
double offset)
Method to fill the signal with a sin() function using the sample time. |
void |
fourier()
Method to take the unshifted Fourier transform. |
Complex |
getComplex(double x)
Method to get the Complex closest to the analogue value |
Complex |
getComplex(int i)
Method to get a Complex data point |
int |
getConversion()
Get the Complex to real conversion flag |
int |
getCurrentWidth()
Get the current width of the sample |
double[] |
getDataBuffer()
Method to get the underlying double[] databuffer |
double |
getDouble(double x)
Method to get the Double closest to the analogue value |
double |
getDouble(int i)
Method to get a double data point. |
ptolemy.plot.Plot |
getPlot()
Method to get the internal plot (if there is one) |
RealSignal |
getRealSignal()
Get the current Signal as a RealSignal using the internal conversion flag |
RealSignal |
getRealSignal(int conversion)
Get the current Signal as a RealSignal array using the specified conversion flag. |
int |
getSample(double t)
Method to get the index of the samples closest t the speciied time, will be -1 of outside the Signal |
double |
getSampleInterval()
Method to get the sample interval |
int |
getSpace()
Method to get the space flag |
double |
getStart()
Get the signal start time |
double |
getTime(int n)
Get the time of the nth sample point, this will be a frequency if the data is in Fourier space. |
String |
getTitle()
Method Get the title |
String |
getType()
Method to get the type |
int |
getWidth()
Get the width of the sample |
void |
mult(Complex c)
Method to multiply the whole Signal by a Complex. |
void |
mult(double a)
Method to muliply the whole Signal by a scalar |
void |
mult(double a,
double b)
Method to multiply the whole Signal by a complex specifed as two doubles. |
void |
mult(int i,
Complex c)
Method to multiply an element by a Complex . |
void |
mult(int i,
double a)
Method to multiply an element by a scalar |
void |
mult(int i,
double a,
double b)
Method to multiply an element by a Complex |
void |
mult(Signal s)
Method to multiply the current Signal by a specified Signal which must be of the same size, the result overwriting the contents of the current Signal. |
void |
multConjugate(Signal s)
Method to multiply the current Signal by the Complex Conjugate of specified Signal which must be of the same size the result overwriting the contents of the current Signal. |
RealSignal |
powerSpectrum(boolean logPower)
Method to get the PowerSpectrum as a RealDataArray In data is in real space, then it is automatically Fourier transformed using centreFourier . |
void |
setComplex(int i,
Complex c)
Method to set element with a Complex |
void |
setComplex(int i,
double a,
double b)
Method to set element with a Complex |
void |
setConversion(int flag)
Method to set the Complex to real conversion flag. |
void |
setDouble(int i,
double v)
Method to set and element with a double |
void |
setSampleFrequency(double freq)
Method to set the sample interval by frequency. |
void |
setSampleInterval(double delta)
Method to set the sample interval |
void |
setStart(double t)
Method to set the signal start time |
void |
setTitle(String t)
Method to set the title |
void |
toGraph(int ds,
boolean line)
Display the signal as a default PtPlot graph |
void |
toPlot(int ds,
boolean line)
Plot the signal to an interal plot. |
void |
toPlot(ptolemy.plot.Plot p,
int ds,
boolean line)
Method to plot signal to a specifed plot. |
boolean |
toPrintWriter(PrintWriter out)
Output the signal to a PrintWriter in a format acceptable to gnuplot |
boolean |
toTextFile(File file)
Output signal to a text file |
boolean |
toTextFile(String fileName)
Output signal to a text file. |
void |
weight(Window w)
Method to apply a Window function to the Signal,. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected DataArray data
protected static String fmt
protected ptolemy.plot.Plot plot
Constructor Detail |
---|
public Signal()
Method Detail |
---|
public void setTitle(String t)
t
- the titlepublic String getTitle()
public String getType()
String
the typepublic void setStart(double t)
t
- the start timepublic double getStart()
double
the signal start timepublic void setSampleInterval(double delta)
delta
- the sampling internalpublic void setSampleFrequency(double freq)
freq
- public double getSampleInterval()
double
the sample intervalpublic double getTime(int n)
double
the time or frequencypublic int getSample(double t)
public int getSpace()
public ptolemy.plot.Plot getPlot()
public double[] getDataBuffer()
double[]
databuffer
double[]
the databufferpublic int getWidth()
int
width of the signalpublic int getCurrentWidth()
int
current width.public int getConversion()
int
the conversion flagpublic void setConversion(int flag)
Complex.MODULUS
.
flag
- the convesion flagpublic Complex getComplex(int i)
i
- the elemntpublic Complex getComplex(double x)
x
- the continious variablepublic double getDouble(int i)
i
- the elementpublic double getDouble(double x)
x
- the continious variablepublic void setComplex(int i, Complex c)
i
- the elementc
- the Complexpublic void setComplex(int i, double a, double b)
i
- the elementa
- the real partb
- the imaginary partpublic void setDouble(int i, double v)
i
- the elementv
- the valuepublic void add(int i, double a)
i
- the elementa
- the scalarpublic void mult(int i, double a)
i
- the elementa
- the scalarpublic void add(int i, double a, double b)
i
- the element indexa
- the real partb
- the imaginary partspublic void mult(int i, double a, double b)
i
- the element indexa
- the real partb
- the imaginary partspublic void add(int i, Complex c)
Complex
to an element.
i
- the element indexc
- to be addedpublic void mult(int i, Complex c)
Complex
.
i
- the element indexc
- the multiplierpublic void mult(double a)
a
- the scalarpublic void mult(double a, double b)
a
- the real partb
- the imaginary.public void mult(Complex c)
c
- the Complex multiplier.public void conjugate(int i)
i
- the element indexpublic void conjugate()
public void weight(Window w)
w
- the Window fucntionpublic void add(Signal s)
This will work for all conbinations expect for current Signal being Real and specifed Signal being Complex.
Internally this uses direct array access so it much more efficient than loops with setter/getters.
s
- the Signal to be added.public void mult(Signal s)
This will work for all conbinations expect for current Signal being Real and specifed Signal being Complex.
Internal this uses uses direct array access so it much more efficient than loops with setter/getters.
s
- the specified Signalpublic void multConjugate(Signal s)
If the current or specifed DataArray(s) are real, then this method is identical
to mult(Signal)
s
- the Signalmult(Signal)
public void fourier()
public void centreFourier()
This will only work for even dimensions, if called with data
of odd size, an error message will be printed and the
normal fourier()
will be taken.
public boolean toPrintWriter(PrintWriter out)
public boolean toTextFile(File file)
file
- the File to output topublic boolean toTextFile(String fileName)
fileName
- the File to output topublic void toPlot(ptolemy.plot.Plot p, int ds, boolean line)
public void toPlot(int ds, boolean line)
ds
- the data setline
- draw with linepublic void toGraph(int ds, boolean line)
ds
- the datasetline
- draw a linepublic void fillSine(double amp, double freq, double phase, double offset)
amp
- amplitude of the sinfreq
- frequency of the sinphase
- starting phaseoffset
- constant offsetgetTime(int)
public RealSignal getRealSignal(int conversion)
If the current DataArray is RealDataArray
in real space
then the current DataArray is returned, else a new ReadDataArray
of the correct dimensions is returned.
conversion
- the conversion flag
RealSignal
the converted Real arraypublic RealSignal getRealSignal()
RealSignal
the converted RealSignalpublic RealSignal powerSpectrum(boolean logPower)
centreFourier
.
After this call the current DataArray
will be in Fourie space.
logPower
- if true the log power formed, else modulus squared used.
RealSignal
the power spectrum.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |