|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjsky.science.AbstractScienceObject
jsky.science.AbstractScienceObjectNode
jsky.science.AbstractWavelength1D
jsky.science.Wavelength1DArray
public class Wavelength1DArray
Implements the Wavelength1DModel as a pair of arrays one containing wavelength points and the other containing data values at each of those wavelengths. This model uses the Wavelength class for management of Wavelength units, but makes no assumptions about the units of the data values.
It anticipates (but does not currently require) that the wavelength data is monotonically increasing. It does NOT assume that the wavelength points are equi-distant.
This class also works with the FITS routines to read from a FITS formatted file.
This code was developed by NASA, Goddard Space Flight Center, Code 588 for the Scientist's Expert Assistant (SEA) project for Next Generation Space Telescope (NGST).
Nested Class Summary |
---|
Nested classes/interfaces inherited from class jsky.science.AbstractScienceObject |
---|
AbstractScienceObject.EventMonitor |
Field Summary | |
---|---|
static java.lang.String |
DATA_PROPERTY
|
Fields inherited from class jsky.science.AbstractWavelength1D |
---|
fFluxUnits, MAXWAVELENGTH_PROPERTY, MINWAVELENGTH_PROPERTY, NUMPOINTS_PROPERTY |
Fields inherited from class jsky.science.AbstractScienceObjectNode |
---|
cloneIndent |
Fields inherited from interface jsky.science.ScienceObjectNodeModel |
---|
DATA_SOURCE_PROPERTY, MORE_DATA_PROPERTY |
Fields inherited from interface jsky.science.ScienceObjectModel |
---|
NAME_PROPERTY, PENDING_PROPERTY, VALID_PROPERTY |
Constructor Summary | |
---|---|
|
Wavelength1DArray()
Creates a new Wavelength1DArray with no Name, 100 data points, and 100-1100 Nanometers range. |
|
Wavelength1DArray(int inVal)
Creates new Wavelenth1DArray of specified number of points and default range (100-1100 Nanometers). |
|
Wavelength1DArray(java.lang.String inName)
Creates a new Wavelength1DArray with the specified Name, 100 data points, and 100-1100 Nanometers range. |
protected |
Wavelength1DArray(java.lang.String inProp,
double wLo,
double wHi,
int inPts)
Creates a new Wavelength1DArray with no name, specified number of points, and specified minimum and maximum wavelength values in the curent default Wavelength units. |
|
Wavelength1DArray(java.lang.String inProp,
Wavelength inMin,
Wavelength inMax,
int inPts)
Creates a new Wavelength1DArray with no name, specified number of points, and specified minimum and maximum Wavelength range. |
|
Wavelength1DArray(Wavelength1DModel baseModel)
Creates a new Wavelength1DArray from an existing Wavelength1DModel. |
|
Wavelength1DArray(Wavelength inMin,
Wavelength inMax,
int inPts)
Creates a new Wavelength1DArray with no name, specified number of points, and specified minimum and maximum wavelength range. |
Method Summary | |
---|---|
void |
add(Wavelength1DModel that)
Adds the specified dataset to this dataset, converting the specified dataset to use existing wavelength points, then adds them to current data. |
void |
alignData(Wavelength1DModel baseDs)
Resets the length and wavelength elements to match the input Wavelength1DArray uses the getData() method to interpolate between old wavelength values and new wavelength values |
java.lang.Object |
clone()
Clones this object, and does a DEEP clone on the fChildren. |
void |
combineData(Wavelength1DModel baseDs,
int nPts)
Used to reduce the number of data points. |
boolean |
equals(java.lang.Object obj)
Adds equals() checks on the object's DataSources and Children |
double |
getArea(Wavelength minWl,
Wavelength maxWl,
boolean interpolate)
Returns the area "under the curve" of the model from the specified minimum to maximum wavelengths. |
int |
getIndexOf(double targetWL)
Returns the 1st index in the dataset to have a wavelength greater/equal to specified wavelength. |
int |
getIndexOf(Wavelength targetWL)
Returns the 1st index in the dataset to have a wavelength greater/equal to specified wavelength. |
int |
getNumPoints()
Returns the number of points in the array |
protected double |
getValue(double targetWl)
Returns the data value at a wavelength specified as a double. |
double |
getValue(Wavelength inWl)
Returns the data value at the specified Wavelength. |
double |
getValueAtIndex(int index)
Returns the data value at the specified index |
Wavelength |
getWavelengthAtIndex(int index)
Returns the wavelength data value for specified index as a Wavelength |
double |
getWavelengthAtIndexAsDouble(int index)
Returns the wavelength data value for specified index as a double value in the current default wavelength units |
java.lang.String |
getWavelengthUnits()
Returns the units at which the wavelength double values are currently stored |
void |
mergeData(Wavelength1DModel inDS)
Folds all inDS point values into this dataset, checking each wavelength in inDS and add the data value to the appropriate location in this dataset. |
void |
multiply(double m)
Multiplies every element in the array by the parameter |
void |
parse(java.io.InputStream istr)
Deprecated. use Wavelength1DArrayParser.parse instead |
void |
parse(java.io.InputStream istr,
java.lang.String wlUnits)
Deprecated. use Wavelength1DArrayParser.parse instead |
void |
parse(java.io.Reader rdr)
Deprecated. use Wavelength1DArrayParser.parse instead |
void |
parseAscii(java.io.Reader rdr,
java.lang.String wlUnits)
Deprecated. use Wavelength1DArrayParser.parse instead |
void |
parseFits(java.io.InputStream istr,
java.lang.String wlColName,
java.lang.String wlUnits,
java.lang.String dataColName,
java.lang.String dataUnits)
Deprecated. use Wavelength1DArrayParser.parse instead |
void |
replaceDataSet(Wavelength1DArray newData)
Replaces the data arrays with the inbound dataset protected so that only descendents can do this, no checking for units or other protections exist |
void |
setAllNaN()
Sets all datapoints data and wavelength to Double.NaN . |
void |
setAllNaN(boolean dataOnly)
Sets all datapoints to Double.NaN . |
void |
setFluxUnits(java.lang.String units)
a DUMMY implementation: Saves the string but does NOTHING with it. |
void |
setNumPoints(int newP)
Changes the length of the dataset, with a new total length, preserves the old data truncate the end if new number of points is less than current or filling with zeros if the new number is more than the current. |
void |
setPending(boolean b)
Overriding to public access |
void |
setValue(Wavelength wavelength,
double value)
Sets the data value at the specified Wavelength in the array. |
void |
setValueAtIndex(int index,
double inVal)
Changes the stored data value at the specified index |
void |
setWavelengthAtIndex(int index,
double inWL)
Sets the wavelength value for specified index as a double in the current default Wavelength units. |
void |
setWavelengthAtIndex(int index,
Wavelength inWL)
Sets the Wavelength value for specified index. |
double[] |
toArrayData()
Returns the current data points array |
double[] |
toArrayData(double[] wllist)
Returns an array of data points for the specifed set of wavelengths |
protected double[] |
toArrayData(double minwl,
double maxwl,
int nPts)
Returns a set of data values to match the requested range of wavelengths in doubles. |
double[] |
toArrayData(Wavelength minW,
Wavelength maxW,
int nPts)
Returns a set of data values to match the requested range of wavelengths in Wavelengths |
double[] |
toArrayWavelengths()
Returns the entire array of wavelength data points |
protected double[] |
toArrayWavelengths(double minwl,
double maxwl,
int nPts)
Returns an array of wavelength datapoints. |
double[] |
toArrayWavelengths(Wavelength minW,
Wavelength maxW,
int nPts,
java.lang.String units)
Returns a subset of the array wavelengths with parameters specified as Wavelengths |
void |
trim()
Trims off zero value datapoints and the beginning or end of the wavelength |
Methods inherited from class jsky.science.AbstractWavelength1D |
---|
calcArea, calculateArea, getArea, getArea, getArea, getFluxUnits, getIndexOf, getIndexOf, getIndexOf, getIndexOf, isEditable, toArrayWavelengths |
Methods inherited from class jsky.science.AbstractScienceObjectNode |
---|
addChild, getChildren, getDataSource, indexOfChild, initializeTransients, isHolding, isMoreDataAvailable, isPending, isUpToDate, isValid, namedClone, processUpdates, removeAllChildren, removeChild, repeat, replaceChild, replaceObject, requestMoreData, retrieveMoreData, saveAsText, saveAsText, setDataSource, setHolding, setMoreDataAvailable, setTracing, setUpdatesPending, update |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface jsky.science.Wavelength1DModel |
---|
addPropertyChangeListener, removePropertyChangeListener |
Methods inherited from interface jsky.science.ScienceObjectNodeModel |
---|
addChild, getChildren, getDataSource, isMoreDataAvailable, isPending, removeAllChildren, removeChild, replaceChild, requestMoreData, retrieveMoreData, setDataSource, setMoreDataAvailable |
Methods inherited from interface jsky.science.ScienceObjectModel |
---|
clearAllListeners, firePropertyChange, getException, getLabel, getName, getParent, isHolding, isTracing, isValid, setException, setHolding, setName, setParent, setTracing |
Methods inherited from interface jsky.util.ReplaceablePropertyChangeListener |
---|
replaceObject |
Methods inherited from interface java.beans.PropertyChangeListener |
---|
propertyChange |
Field Detail |
---|
public static final java.lang.String DATA_PROPERTY
Constructor Detail |
---|
public Wavelength1DArray()
public Wavelength1DArray(int inVal)
inVal
- integer of number of desired points in datasetpublic Wavelength1DArray(java.lang.String inName)
public Wavelength1DArray(Wavelength inMin, Wavelength inMax, int inPts)
inMin
- Minimum Wavelength for the datasetinMax
- Maximum Wavelength for the datasetinPts
- number of points in the datasetpublic Wavelength1DArray(Wavelength1DModel baseModel)
public Wavelength1DArray(java.lang.String inProp, Wavelength inMin, Wavelength inMax, int inPts)
inProp
- name for the arrayinMin
- Minimum Wavelength for the datasetinMax
- Maximum Wavelength for the datasetinPts
- number of points in the datasetprotected Wavelength1DArray(java.lang.String inProp, double wLo, double wHi, int inPts)
inProp
- name for the arraywLo
- Minimum wavelength value in default units for the datasetwHi
- Maximum wavelength value in default units for the datasetinPts
- number of points in the datasetMethod Detail |
---|
public boolean equals(java.lang.Object obj)
AbstractScienceObjectNode
equals
in class AbstractScienceObjectNode
public void setPending(boolean b)
setPending
in class AbstractScienceObjectNode
public void setWavelengthAtIndex(int index, Wavelength inWL)
index
- index in the array for the new wavelength pointinWL
- for the wavelength as a Wavelengthpublic void setWavelengthAtIndex(int index, double inWL)
index
- index in the array for the new wavelength pointinWL
- for the wavelength as a double in the current
default Wavelength unitspublic double getArea(Wavelength minWl, Wavelength maxWl, boolean interpolate)
getArea
in interface Wavelength1DModel
getArea
in class AbstractWavelength1D
minWl
- the starting wavelength for areamaxWl
- the maximum wavelength for calculations.interpolate
- When true, the data points are treated as points
on a curve and the area calculation uses linear interpolation between
points. When false, the data points are treated as "bins" with no
interpolation between points.
This method may be overridden by subclasses (such as Wavelength1DArray) to create a more efficient array of wavelengths and data values to pass to the main calculateArea() method
public double[] toArrayWavelengths()
public double[] toArrayWavelengths(Wavelength minW, Wavelength maxW, int nPts, java.lang.String units)
protected double[] toArrayWavelengths(double minwl, double maxwl, int nPts)
To return a subset, the min and max wavelength must match existing data points and the number of requested points must either be 0 or match the number of points in the existing wavelength subset.
If the min and max wavelengths do not match existing points or the number of points does not match, then a new array of wavelengths is return from min to max specified wavelengths and equal increments to provide for the specified number of points
public double[] toArrayData(double[] wllist)
toArrayData
in interface Wavelength1DModel
toArrayData
in class AbstractWavelength1D
public double[] toArrayData()
public double[] toArrayData(Wavelength minW, Wavelength maxW, int nPts)
protected double[] toArrayData(double minwl, double maxwl, int nPts)
public void replaceDataSet(Wavelength1DArray newData)
public Wavelength getWavelengthAtIndex(int index)
public double getWavelengthAtIndexAsDouble(int index)
public java.lang.String getWavelengthUnits()
public int getIndexOf(double targetWL)
targetWL
- is a double of the wavelength in the default units of the dataset
search is done on a binary basis for efficiencypublic int getIndexOf(Wavelength targetWL)
targetWL
- is a double of the wavelength in the default units of the dataset
search is done on a binary basis for efficiencypublic void setValue(Wavelength wavelength, double value)
setValue
in interface Wavelength1DModel
setValue
in class AbstractWavelength1D
public void setValueAtIndex(int index, double inVal)
public double getValueAtIndex(int index)
public java.lang.Object clone()
AbstractScienceObjectNode
NOTE: for subclasses! If a subclass has a separate variable or list that points at fChildren, remember that after this clone() method is completed all fChildren will have also been cloned.
So subclasses may need to "repoint" variables or elemenets of lists that reference child objects, but should NOT re-clone those children.
See ExposureGroup.clone() and Exposure.clone() as examples of classes that need to re-proint existing pointers to correctly point at the correct elements.
clone
in interface ScienceObjectModel
clone
in class AbstractScienceObjectNode
public double getValue(Wavelength inWl)
protected double getValue(double targetWl)
public void setAllNaN(boolean dataOnly)
Double.NaN
.
dataOnly
- boolean, if true the wavelengths will be left untouched
only the data will be made Double.NaNpublic void setAllNaN()
Double.NaN
.
public void add(Wavelength1DModel that)
also ASSUMES that wavelength and data units are the same, no checking is done Note: Use the mergeData() method instead if the specified dataset has different wavelengths and you want use the specified dataset's wavelength to determine where to add the corresponding data value.
public void mergeData(Wavelength1DModel inDS)
ASSUMES that the data units are the same -- no checking is done. Note: Use the add() method if you're adding a dataset that has same wavelengths as this dataset or if you just want to add each data value directly to this dataset's data value without checking for the wavelengths.
public void combineData(Wavelength1DModel baseDs, int nPts)
public void alignData(Wavelength1DModel baseDs)
public void trim()
public void setNumPoints(int newP)
newP
- the new number of pointspublic int getNumPoints()
public void multiply(double m)
public void parse(java.io.InputStream istr) throws WavelengthArrayParseException
istr
- an InputStream to the data to be parsed, this may includes binary FITS files
or text-based data
WavelengthArrayParseException
public void parse(java.io.Reader rdr) throws WavelengthArrayParseException
rdr
- a Reader to the data to be parsed, ASSUME only text-based inputs
WavelengthArrayParseException
public void parse(java.io.InputStream istr, java.lang.String wlUnits) throws WavelengthArrayParseException
No conversion of the data value is performed For FITS binary data the wavelength units are converted from their source units. And ASCII wavelengths are assumed to be in wlUnits
istr
- an InputStream to the data to be parsedwlUnits
- the input units for an ascii data string, ignore if reader
contains binary FITS data
WavelengthArrayParseException
public void parseFits(java.io.InputStream istr, java.lang.String wlColName, java.lang.String wlUnits, java.lang.String dataColName, java.lang.String dataUnits) throws WavelengthArrayParseException
WavelengthArrayParseException
public void parseAscii(java.io.Reader rdr, java.lang.String wlUnits) throws WavelengthArrayParseException
WavelengthArrayParseException
public void setFluxUnits(java.lang.String units) throws UnitsNotSupportedException
AbstractWavelength1D
setFluxUnits
in interface Wavelength1DModel
setFluxUnits
in class AbstractWavelength1D
UnitsNotSupportedException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |