|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.ArrayList<DataCoordinate>
ui.model.Spectra
public class Spectra
A Spectra is a kind of data model which contains a list of DataCoordinates which could represent intensity versus wavelength. This list can represents a continuous spectrum or a discrete line list such as atomic transitions. A spectra can be contrusted from a pre-existing list of datacoordinates or from a file. There are several methods which can return the minimum and maximum values of wavelength and intensity. The wavelength unit is a number by which the DataCoordinate wavelength value is multiplied; it can be chosen among a small list of predifined units or can be chosen by the user.
Field Summary | |
---|---|
static String |
ATTRIBUTE_NAME
The spectra attribute for the object's name (should use FITS header conventions for these) |
static String |
ATTRIBUTE_WAVELENGTH_UNIT
The spectra attribute for the object's name (should use FITS header conventions for these) |
protected HashMap |
attributes
|
protected Calibration |
calibration
|
protected char |
commentChar
|
protected double[] |
continuum
The polynomial fit coefficients to the continuum |
protected boolean |
continuumFitted
An internal flag which indicates that the coefficients to continuum polynomial need to be computed. |
protected double |
maxX
|
protected double |
maxY
|
protected double |
minX
|
protected double |
minY
|
protected char |
separator
|
protected boolean |
uniformSampling
|
protected double |
wavelengthUnit
|
Fields inherited from class java.util.AbstractList |
---|
modCount |
Constructor Summary | |
---|---|
Spectra(DataCoordinate[] aData,
double aWavelengthUnit)
Create a spectra using an array of DataCoordinate instances of the specified wavelength unit. |
|
Spectra(double aWavelengthUnit)
Create a blank spectra with the specified wavelength unit. |
|
Spectra(File aFile)
Create a spectra by loading a file. |
|
Spectra(File aFile,
double aWavelengthUnit)
Create a spectra by loading file with the specified wavelength unit. |
|
Spectra(List<DataCoordinate> aData,
double aWavelengthUnit)
Create a spectra using a list of DataCoordinate instances with the specified wavelength unit. |
|
Spectra(Spectra aSpectra)
Create a spectra using another spectra (copy constructor). |
|
Spectra(String aFileName)
Create a spectra by loading file with the specified file name. |
Method Summary | |
---|---|
void |
append(Spectra aSpectra)
Append the contents of given spectra to this spectra. |
void |
append(Spectra aSpectra,
double aScale)
Append the contents of given spectra to this spectra. |
protected double[] |
fitPolynomial()
|
Object |
getAttribute(Object aKey)
Get a spectra attribute using a key. |
Object[] |
getAttributeKeys()
Get all the attribute keys. |
Calibration |
getCalibration()
Get the calibration for this spectra, required when wavelength to pixel/point conversion is required |
char |
getCommentChar()
Get the comment character which indicates a comment line to be ignored. |
double |
getContinuum(double aWavelength)
Get the continuum of the spectra, obtained by fitting a polynomial to the regions of the spectra without emission lines. |
DataCoordinate |
getDataCoordinate(int anIndex)
Get the data coordinate for a given index in the spectra array. |
double |
getIntensity(double aWavelength)
Get the spectra intensity given an arbitrary wavelength, interpolate if necessary. |
double |
getIntensity(int position)
Get the spectra intensity at the given integer position. |
double |
getIntensityMinusContinuum(double aWavelength)
Get the intensity minus the continuum. |
DataCoordinate |
getScaledDataCoordinate(int anIndex)
Get the data coordinate scaled to unit intensity for a given index in the spectra array and with the wavelength in meters. |
char |
getSeparator()
Get the separator character used between the wavelength and the intensity in the the spectra file. |
double |
getWavelength(int position)
Get the spectra wavelength at the given integer position. |
protected double |
interpolate(int point1,
int point2,
double aWavelength)
Interpolate linearly the intensity at a specified wavelength position between two data points. |
boolean |
isUniformSampling()
Is the wavelength sampling interval uniform. |
void |
load(File aFile)
Load the spectra from a file and interpret the wavelength using the wavelengthUnit. |
void |
save(File aFile)
Save the spectra as a file with properties encoded as comments. |
void |
scale(double wavelengthScale,
double intensityScale)
Scale the spectra wavelength and intensity by the given factors. |
void |
scaleIntensity(double aScale)
Scale the spectra intensity by the given factor. |
void |
scaleWavelength(double aScale)
Scale the spectra wavelength by the given factor. |
void |
setAttribute(Object aKey,
Object aValue)
Set an attribute using a key and its corresponding value. |
void |
setCalibration(Calibration aCalibration)
Set the calibration for this spectra, required when wavelength to pixel/point conversion is required |
void |
setCommentChar(char aCommentChar)
Set the comment character which indicates a comment line to be ignored. |
void |
setSeparator(char aSeparator)
Set the separator character used between the wavelength and the intensity in the the spectra file. |
void |
setUniformSampling(boolean aUniformSampling)
|
Methods inherited from class java.util.ArrayList |
---|
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize |
Methods inherited from class java.util.AbstractList |
---|
equals, hashCode, iterator, listIterator, listIterator, subList |
Methods inherited from class java.util.AbstractCollection |
---|
containsAll, removeAll, retainAll, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.List |
---|
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList |
Field Detail |
---|
public static final String ATTRIBUTE_NAME
public static final String ATTRIBUTE_WAVELENGTH_UNIT
protected char separator
protected char commentChar
protected double minX
protected double maxX
protected double minY
protected double maxY
protected Calibration calibration
protected double wavelengthUnit
protected boolean uniformSampling
protected HashMap attributes
protected boolean continuumFitted
protected double[] continuum
Constructor Detail |
---|
public Spectra(String aFileName)
aFileName
- a file name pointing to file containing the spectra datapublic Spectra(File aFile)
aFile
- a file containing the spectra datapublic Spectra(File aFile, double aWavelengthUnit)
aFile
- a file containing the spectra dataaWavelengthUnit
- the wavelength unit, all x coordinates in the data will be multipled by this number.public Spectra(DataCoordinate[] aData, double aWavelengthUnit)
aData
- an array of data coordinates representing spectra pointsaWavelengthUnit
- the wavelength unit, all x coordinates in the data will be multipled by this number.public Spectra(List<DataCoordinate> aData, double aWavelengthUnit)
aData
- an ordered collection of data coordinates representing spectra pointsaWavelengthUnit
- the wavelength unit, all x coordinates in the data will be multipled by this number.public Spectra(double aWavelengthUnit)
aWavelengthUnit
- the wavelength unit, all x coordinates in the data will be multipled by this number.public Spectra(Spectra aSpectra)
aSpectra
- a spectra to be clonedMethod Detail |
---|
public void load(File aFile)
aFile
- a file containing xy pairs, one per line, x and y separatated by a spacepublic void save(File aFile)
aFile
- a file in which xy pairs will be added, one per line, x and y separatated by a spacepublic void append(Spectra aSpectra)
aSpectra
- a spectra which will be appended to this spectrapublic void append(Spectra aSpectra, double aScale)
aSpectra
- a spectra which will be appended to this spectraaScale
- a scaling value to be used if the other spectra differs in vertical scale.public void scaleIntensity(double aScale)
aScale
- a scale factor to multiply the spectra intensity values.public void scaleWavelength(double aScale)
aScale
- a scale factor to multiply the spectra wavelength values.public void scale(double wavelengthScale, double intensityScale)
wavelengthScale
- a scale factor to multiply the spectra wavelength values.intensityScale
- a scale factor to multiply the spectra intensity values.public double getWavelength(int position)
position
- the integer position at which to obtain the wavelengthpublic double getIntensity(int position)
position
- the integer position at which to obtain the intensitypublic double getIntensity(double aWavelength)
aWavelength
- the wavelength position at which the intensity is obtainedprotected double interpolate(int point1, int point2, double aWavelength)
point1
- integer representing the first pointpoint2
- integer representing the second pointaWavelength
- public double getIntensityMinusContinuum(double aWavelength)
aWavelength
- public double getContinuum(double aWavelength)
aWavelength
- protected double[] fitPolynomial()
public DataCoordinate getDataCoordinate(int anIndex)
anIndex
- the position in the spectral point arraypublic DataCoordinate getScaledDataCoordinate(int anIndex)
anIndex
- the position in the spectral point arraypublic Calibration getCalibration()
public void setCalibration(Calibration aCalibration)
aCalibration
- a calibration objectpublic char getSeparator()
public void setSeparator(char aSeparator)
aSeparator
- a character used to separate the wavelength and intensitypublic char getCommentChar()
public void setCommentChar(char aCommentChar)
aCommentChar
- a character used to mark a comment linepublic Object[] getAttributeKeys()
public Object getAttribute(Object aKey)
aKey
- an object representing a key
public void setAttribute(Object aKey, Object aValue)
aKey
- an object representing a keyaValue
- an object which represents the value corresponding to the keypublic boolean isUniformSampling()
public void setUniformSampling(boolean aUniformSampling)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |