jsky.science
Class AbstractWavelength1D

java.lang.Object
  extended by jsky.science.AbstractScienceObject
      extended by jsky.science.AbstractScienceObjectNode
          extended by jsky.science.AbstractWavelength1D
All Implemented Interfaces:
java.beans.PropertyChangeListener, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable, java.util.EventListener, ScienceObjectModel, ScienceObjectNodeModel, Wavelength1DModel, ReplaceablePropertyChangeListener
Direct Known Subclasses:
Wavelength1DArray, Wavelength1DFormula

public abstract class AbstractWavelength1D
extends AbstractScienceObjectNode
implements Wavelength1DModel

Abstract class that provides initial functionality for Wavelength1DModel without committing to the underlying storage structure of the dataset.

This code was originally developed by NASA, Goddard Space Flight Center, Code 588 for the Scientist's Expert Assistant (SEA) project for Next Generation Space Telescope (NGST).

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class jsky.science.AbstractScienceObject
AbstractScienceObject.EventMonitor
 
Field Summary
protected  java.lang.String fFluxUnits
           
static java.lang.String MAXWAVELENGTH_PROPERTY
           
static java.lang.String MINWAVELENGTH_PROPERTY
           
static java.lang.String 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
AbstractWavelength1D()
           
AbstractWavelength1D(java.lang.String name)
           
 
Method Summary
protected  double calcArea(double xl, double xr, double yl, double yr, boolean interpolate)
          Calculates the area under a curve of rectangle define by lower left and upper right coordinates.
protected  double calculateArea(double[] wlArray, double[] dataArray, Wavelength minWl, Wavelength maxWl, boolean interpolate)
           
 double getArea()
          Calls getArea(true);
 double getArea(boolean interpolate)
          Returns the area "under the curve" of the model from the specified minimum to maximum wavelengths.
 double getArea(Wavelength minWl, Wavelength maxWl)
          use getArea( minwavelength, maxwavelength, interpolate) instead
 double getArea(Wavelength minWl, Wavelength maxWl, boolean interpolate)
          Returns the area "under the curve" of the model from the specified minimum to maximum wavelengths.
 java.lang.String getFluxUnits()
          returns the units string for the data values in the model.
protected  int getIndexOf(double wl, double[] wlArray)
          Looks up the index of a specified wavelength in the dataset to have a wavelength greater/equal to specified wavelength.
protected  int getIndexOf(double targetWl, double[] wlArray, boolean exactOnly)
          Looks up the index of a specified wavelength in the dataset to have a wavelength greater/equal to specified wavelength (as a double).
protected  int getIndexOf(Wavelength wl, double[] wlArray)
          Looks up the index of a specified wavelength in the dataset to have a wavelength greater/equal to specified wavelength.
protected  int getIndexOf(Wavelength wl, double[] wlArray, boolean exactOnly)
          Looks up the index of a specified wavelength in the dataset to have a wavelength greater/equal to specified wavelength.
 boolean isEditable()
          Default implementation: returns false
 void setFluxUnits(java.lang.String units)
          a DUMMY implementation: Saves the string but does NOTHING with it.
 void setValue(Wavelength inWl, double newVal)
          default implementation, does nothing
 double[] toArrayData(double[] wllist)
          Default implementation for returning an array of data values for a specified set of wavelength values.
 double[] toArrayWavelengths(Wavelength minWL, Wavelength maxWL, int nPts)
          passes current default wavelength units down into the real workhorse
 
Methods inherited from class jsky.science.AbstractScienceObjectNode
addChild, clone, equals, getChildren, getDataSource, indexOfChild, initializeTransients, isHolding, isMoreDataAvailable, isPending, isUpToDate, isValid, namedClone, processUpdates, removeAllChildren, removeChild, repeat, replaceChild, replaceObject, requestMoreData, retrieveMoreData, saveAsText, saveAsText, setDataSource, setHolding, setMoreDataAvailable, setPending, setTracing, setUpdatesPending, update
 
Methods inherited from class jsky.science.AbstractScienceObject
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
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jsky.science.Wavelength1DModel
addPropertyChangeListener, getNumPoints, getValue, removePropertyChangeListener, toArrayData, toArrayWavelengths
 
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, clone, 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

NUMPOINTS_PROPERTY

public static final java.lang.String NUMPOINTS_PROPERTY
See Also:
Constant Field Values

MINWAVELENGTH_PROPERTY

public static final java.lang.String MINWAVELENGTH_PROPERTY
See Also:
Constant Field Values

MAXWAVELENGTH_PROPERTY

public static final java.lang.String MAXWAVELENGTH_PROPERTY
See Also:
Constant Field Values

fFluxUnits

protected java.lang.String fFluxUnits
Constructor Detail

AbstractWavelength1D

public AbstractWavelength1D()

AbstractWavelength1D

public AbstractWavelength1D(java.lang.String name)
Method Detail

getArea

public double getArea()
Calls getArea(true);

Specified by:
getArea in interface Wavelength1DModel

getArea

public double getArea(Wavelength minWl,
                      Wavelength maxWl)
use getArea( minwavelength, maxwavelength, interpolate) instead

Specified by:
getArea in interface Wavelength1DModel

getArea

public double getArea(boolean interpolate)
Returns the area "under the curve" of the model from the specified minimum to maximum wavelengths.

Specified by:
getArea in interface Wavelength1DModel
Parameters:
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.

getArea

public double getArea(Wavelength minWl,
                      Wavelength maxWl,
                      boolean interpolate)
Returns the area "under the curve" of the model from the specified minimum to maximum wavelengths. If min or max is outside a defined wl area, then 0 values are assumed

Specified by:
getArea in interface Wavelength1DModel
Parameters:
minWl - the starting wavelength for area
maxWl - 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


calculateArea

protected double calculateArea(double[] wlArray,
                               double[] dataArray,
                               Wavelength minWl,
                               Wavelength maxWl,
                               boolean interpolate)
Parameters:
wlArray - array of doubles representing the wavelength values
dataArray -
minWl - the starting wavelength for area
maxWl - 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.

calcArea

protected double calcArea(double xl,
                          double xr,
                          double yl,
                          double yr,
                          boolean interpolate)
Calculates the area under a curve of rectangle define by lower left and upper right coordinates. xl and xr define left/right edges and yl and yr define the height of left/right edges respectivelly


getIndexOf

protected int getIndexOf(Wavelength wl,
                         double[] wlArray)
Looks up the index of a specified wavelength in the dataset to have a wavelength greater/equal to specified wavelength. Returns the index of first element >= requested wavelength

Note: this implementation assumes that the wavelength points are monotonically increasing.

Parameters:
wl - is a target Wavelength in the default units of the dataset
wlArray - is the array of wavelength in double units in which to lock

getIndexOf

protected int getIndexOf(double wl,
                         double[] wlArray)
Looks up the index of a specified wavelength in the dataset to have a wavelength greater/equal to specified wavelength. Returns the index of first element >= requested wavelength

Parameters:
wl - is a target Wavelength as a double value in the default units of the dataset
wlArray - is the array of wavelength in double units in which to lock

getIndexOf

protected int getIndexOf(Wavelength wl,
                         double[] wlArray,
                         boolean exactOnly)
Looks up the index of a specified wavelength in the dataset to have a wavelength greater/equal to specified wavelength. Can restrict implementation to an exact match, or return the index of first element >= requested wavelength

Parameters:
wl - is a target Wavelength in the default units of the dataset
wlArray - is the array of wavelength in double units in which to lock
exactOnly - when true only exact wavelength matches will be returned, when false the index of first wavelength >= target will be returned. search is done on a binary basis for efficiency

getIndexOf

protected int getIndexOf(double targetWl,
                         double[] wlArray,
                         boolean exactOnly)
Looks up the index of a specified wavelength in the dataset to have a wavelength greater/equal to specified wavelength (as a double). Can restrict implementation to an exact match, or return the index of first element >= requested wavelength

Parameters:
targetWl - is a double of the wavelength in the default units of the dataset
wlArray - is the array of wavelength in which to lock
exactOnly - when true only exact wavelength matches will be returned, when false the index of first wavelength >= target will be returned. search is done on a binary basis for efficiency

isEditable

public boolean isEditable()
Default implementation: returns false

Specified by:
isEditable in interface Wavelength1DModel

setValue

public void setValue(Wavelength inWl,
                     double newVal)
default implementation, does nothing

Specified by:
setValue in interface Wavelength1DModel

toArrayWavelengths

public double[] toArrayWavelengths(Wavelength minWL,
                                   Wavelength maxWL,
                                   int nPts)
passes current default wavelength units down into the real workhorse

Specified by:
toArrayWavelengths in interface Wavelength1DModel

toArrayData

public double[] toArrayData(double[] wllist)
Default implementation for returning an array of data values for a specified set of wavelength values.

Note: subclasses may be able to override this "brute force" implementation with less resource-intensive implementation

Specified by:
toArrayData in interface Wavelength1DModel

setFluxUnits

public void setFluxUnits(java.lang.String units)
                  throws UnitsNotSupportedException
a DUMMY implementation: Saves the string but does NOTHING with it.

Specified by:
setFluxUnits in interface Wavelength1DModel
Throws:
UnitsNotSupportedException

getFluxUnits

public java.lang.String getFluxUnits()
Description copied from interface: Wavelength1DModel
returns the units string for the data values in the model. May be null

Specified by:
getFluxUnits in interface Wavelength1DModel