public class Wavelength1DArray extends AbstractWavelength1D
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).
AbstractScienceObject.EventMonitor
Modifier and Type | Field and Description |
---|---|
static String |
DATA_PROPERTY |
fFluxUnits, MAXWAVELENGTH_PROPERTY, MINWAVELENGTH_PROPERTY, NUMPOINTS_PROPERTY
cloneIndent
DATA_SOURCE_PROPERTY, MORE_DATA_PROPERTY
NAME_PROPERTY, PENDING_PROPERTY, VALID_PROPERTY
Modifier | Constructor and Description |
---|---|
|
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(String inName)
Creates a new Wavelength1DArray with the specified Name, 100 data points, and
100-1100 Nanometers range.
|
protected |
Wavelength1DArray(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(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.
|
Modifier and Type | Method and Description |
---|---|
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
|
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(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
|
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(InputStream istr)
Deprecated.
use Wavelength1DArrayParser.parse instead
|
void |
parse(InputStream istr,
String wlUnits)
Deprecated.
use Wavelength1DArrayParser.parse instead
|
void |
parse(Reader rdr)
Deprecated.
use Wavelength1DArrayParser.parse instead
|
void |
parseAscii(Reader rdr,
String wlUnits)
Deprecated.
use Wavelength1DArrayParser.parse instead
|
void |
parseFits(InputStream istr,
String wlColName,
String wlUnits,
String dataColName,
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(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,
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
|
calcArea, calculateArea, getArea, getArea, getArea, getFluxUnits, getIndexOf, getIndexOf, getIndexOf, getIndexOf, isEditable, toArrayWavelengths
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
addEventMonitor, addPropertyChangeListener, areNamesEqual, clearAllListeners, compareTo, createDefaultName, firePropertyChange, firePropertyChange, fireReplaceObject, fireReplaceObject, fireReplaceObject, fireVetoableChange, fireVetoableChange, getException, getLabel, getName, getObjectIdString, getObjectIdString, getParent, isTracing, notifyEventMonitors, propertyChange, removeEventMonitor, removePropertyChangeListener, replaceObjectNYI, setException, setName, setParent, setTraceAll, toString, writeDebug, writeError
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addPropertyChangeListener, removePropertyChangeListener
addChild, getChildren, getDataSource, isMoreDataAvailable, isPending, removeAllChildren, removeChild, replaceChild, requestMoreData, retrieveMoreData, setDataSource, setMoreDataAvailable
clearAllListeners, firePropertyChange, getException, getLabel, getName, getParent, isHolding, isTracing, isValid, setException, setHolding, setName, setParent, setTracing
replaceObject
propertyChange
public static final String DATA_PROPERTY
public Wavelength1DArray()
public Wavelength1DArray(int inVal)
inVal
- integer of number of desired points in datasetpublic Wavelength1DArray(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(String inProp, Wavelength inMin, Wavelength inMax, int inPts)
inName,
- name for the arrayinMin
- Minimum Wavelength for the datasetinMax
- Maximum Wavelength for the datasetinPts
- number of points in the datasetprotected Wavelength1DArray(String inProp, double wLo, double wHi, int inPts)
inName,
- name for the arrayinMin
- Minimum wavelength value in default units for the datasetinMax
- Maximum wavelength value in default units for the datasetinPts
- number of points in the datasetpublic boolean equals(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 pointvalue
- for the wavelength as a Wavelengthpublic void setWavelengthAtIndex(int index, double inWL)
index
- index in the array for the new wavelength pointvalue
- 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, 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 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 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(InputStream istr) throws WavelengthArrayParseException
istr
- an InputStream to the data to be parsed, this may includes binary FITS files
or text-based dataWavelengthArrayParseException
public void parse(Reader rdr) throws WavelengthArrayParseException
reader
- a Reader to the data to be parsed, ASSUME only text-based inputsWavelengthArrayParseException
public void parse(InputStream istr, 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
reader
- a Reader to the data to be parsedwlUnits
- the input units for an ascii data string, ignore if reader
contains binary FITS dataWavelengthArrayParseException
public void parseFits(InputStream istr, String wlColName, String wlUnits, String dataColName, String dataUnits) throws WavelengthArrayParseException
WavelengthArrayParseException
public void parseAscii(Reader rdr, String wlUnits) throws WavelengthArrayParseException
WavelengthArrayParseException
public void setFluxUnits(String units) throws UnitsNotSupportedException
AbstractWavelength1D
setFluxUnits
in interface Wavelength1DModel
setFluxUnits
in class AbstractWavelength1D
UnitsNotSupportedException
Copyright © 2023 Central Laboratory of the Research Councils. All Rights Reserved.