uk.ac.starlink.splat.data
Class MEMSpecDataImpl

java.lang.Object
  extended by uk.ac.starlink.splat.data.AbstractSpecDataImpl
      extended by uk.ac.starlink.splat.data.AbstractEditableSpecDataImpl
          extended by uk.ac.starlink.splat.data.MEMSpecDataImpl
All Implemented Interfaces:
Serializable, EditableSpecDataImpl, FITSHeaderSource, SpecDataImpl
Direct Known Subclasses:
CollapsedSpecDataImpl, ExtractedSpecDataImpl, LineIDMEMSpecDataImpl, TableSpecDataImpl, TXTSpecDataImpl

public class MEMSpecDataImpl
extends AbstractEditableSpecDataImpl
implements FITSHeaderSource

This class provides an implementation of SpecDataImpl to access spectra stored in existing memory. All values are copied into arrays stored in memory.

The main use of this class is for temporary, generated and copied spectra. It also provides the main facilities for spectra that can be modified.

See Also:
SpecDataImpl, EditableSpecData, "The Bridge Design Pattern", Serialized Form

Field Summary
protected  uk.ac.starlink.ast.FrameSet astref
          Reference to AST frameset.
protected  double[] coords
          Reference to coordinates.
protected  double[] data
          Reference to data values.
protected  double[] errors
          Reference to data errors.
protected  String fullName
          Reference to the full name of spectrum.
protected  nom.tam.fits.Header headers
          Any headers that we're carrying around.
protected  String shortName
          Reference to the symbolic name of spectrum.
 
Fields inherited from class uk.ac.starlink.splat.data.AbstractSpecDataImpl
dataLabel, dataUnits, parentImpl
 
Constructor Summary
MEMSpecDataImpl(String name)
          Constructor - just take a symbolic name for the spectrum, no other significance.
MEMSpecDataImpl(String name, SpecData spectrum)
          Constructor, clone from another spectrum.
 
Method Summary
protected  void clone(SpecData spectrum)
          Clone this spectrum from another spectrum.
protected  void copyData(double[] coords, double[] data, double[] errors)
          Make local copies of any given coordinates, data and errors.
protected  void createAst()
          Create an default AST FrameSet when we have no information about the coordinate system or data units.
protected  void createAst(uk.ac.starlink.ast.Frame baseframe, uk.ac.starlink.ast.Frame currentframe)
          Create an AST FrameSet that relates the spectrum coordinate to data values positions.
protected  void createAst(uk.ac.starlink.ast.FrameSet sourceSet)
          Create an AST FrameSet that relates the spectrum coordinate to data values positions.
protected  void createCoords()
          Create a set of coordinates that match the current FrameSet.
protected  void finalize()
          Finalise object.
 uk.ac.starlink.ast.FrameSet getAst()
          Return reference to AST frameset that defines the coordinate relations used by this spectrum.
 double[] getData()
          Return a copy of the spectrum data values.
 double[] getDataErrors()
          Return a copy of the spectrum data errors.
 String getDataFormat()
          Return the data format.
 int[] getDims()
          Return the data array dimensionality (always length of spectrum).
 nom.tam.fits.Header getFitsHeaders()
          Return any FITS headers we have accumulated.
 String getFullName()
          Return the full name of spectrum.
 String getProperty(String prop)
          Return a known descriptive label.
 String getShortName()
          Return a symbolic name.
 void save()
          Save is just a copy for this class.
 void setAst(uk.ac.starlink.ast.FrameSet frameSet)
          Set the FrameSet used for the coordinate system.
 void setAstCopy(uk.ac.starlink.ast.FrameSet frameSet)
          Accept a new FrameSet making a copy of it.
 void setFullData(uk.ac.starlink.ast.FrameSet frameSet, String dataUnits, double[] data)
          Change the spectrum data and WCS.
 void setFullData(uk.ac.starlink.ast.FrameSet frameSet, String dataUnits, double[] data, double[] errors)
          Change the spectrum data and WCS.
 void setFullDataQuick(uk.ac.starlink.ast.FrameSet frameSet, String dataUnits, double[] data)
          Change the spectrum data and WCS.
 void setFullDataQuick(uk.ac.starlink.ast.FrameSet frameSet, String dataUnits, double[] data, double[] errors)
          Change the complete spectrum data.
 void setSimpleData(double[] coords, String dataUnits, double[] data)
          Change the complete spectrum data.
 void setSimpleData(double[] coords, String dataUnits, double[] data, double[] errors)
          Change the complete spectrum data.
 void setSimpleDataQuick(double[] coords, String dataUnits, double[] data)
          Change the complete spectrum data.
 void setSimpleDataQuick(double[] coords, String dataUnits, double[] data, double[] errors)
          Change the complete spectrum data.
 void setSimpleUnitData(uk.ac.starlink.ast.FrameSet sourceSet, double[] coords, String dataUnits, double[] data)
          Change the complete spectrum data, but preserving the properties of an existing FrameSet as part of a new FrameSet.
 void setSimpleUnitData(uk.ac.starlink.ast.FrameSet sourceSet, double[] coords, String dataUnits, double[] data, double[] errors)
          Change the complete spectrum data, but preserving the properties of an existing FrameSet as part of a new FrameSet.
 void setSimpleUnitDataQuick(uk.ac.starlink.ast.FrameSet sourceSet, double[] coords, String dataUnits, double[] data)
          Change the complete spectrum data, but preserving the properties of an existing FrameSet as part of a new FrameSet.
 void setSimpleUnitDataQuick(uk.ac.starlink.ast.FrameSet sourceSet, double[] coords, String dataUnits, double[] data, double[] errors)
          Change the complete spectrum data, but preserving the properties of an existing FrameSet as part of a new FrameSet.
 void setXDataValue(int index, double value)
          Change a coordinate value.
 void setYDataErrorValue(int index, double value)
          Change a data error value.
 void setYDataValue(int index, double value)
          Change a data value.
 
Methods inherited from class uk.ac.starlink.splat.data.AbstractSpecDataImpl
getColumnNames, getCoordinateColumnName, getDataColumnName, getDataErrorColumnName, getDataLabel, getDataUnits, getParentImpl, isFITSHeaderSource, setCoordinateColumnName, setDataColumnName, setDataErrorColumnName, setDataLabel, setDataUnits, setParentImpl
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface uk.ac.starlink.splat.data.SpecDataImpl
getColumnNames, getCoordinateColumnName, getDataColumnName, getDataErrorColumnName, getDataLabel, getDataUnits, getParentImpl, isFITSHeaderSource, setCoordinateColumnName, setDataColumnName, setDataErrorColumnName, setDataLabel, setDataUnits, setParentImpl
 

Field Detail

coords

protected double[] coords
Reference to coordinates.


data

protected double[] data
Reference to data values.


errors

protected double[] errors
Reference to data errors.


shortName

protected String shortName
Reference to the symbolic name of spectrum.


fullName

protected String fullName
Reference to the full name of spectrum.


astref

protected uk.ac.starlink.ast.FrameSet astref
Reference to AST frameset.


headers

protected nom.tam.fits.Header headers
Any headers that we're carrying around.

Constructor Detail

MEMSpecDataImpl

public MEMSpecDataImpl(String name)
                throws SplatException
Constructor - just take a symbolic name for the spectrum, no other significance.

Parameters:
name - a symbolic name for the spectrum.
Throws:
SplatException

MEMSpecDataImpl

public MEMSpecDataImpl(String name,
                       SpecData spectrum)
                throws SplatException
Constructor, clone from another spectrum.

Parameters:
name - a symbolic name for the spectrum.
spectrum - a SpecData object to copy.
Throws:
SplatException
Method Detail

clone

protected void clone(SpecData spectrum)
              throws SplatException
Clone this spectrum from another spectrum.

Throws:
SplatException

getData

public double[] getData()
Return a copy of the spectrum data values.

Specified by:
getData in interface SpecDataImpl
Specified by:
getData in class AbstractSpecDataImpl
Returns:
reference to the spectrum data values.

getDataErrors

public double[] getDataErrors()
Return a copy of the spectrum data errors.

Specified by:
getDataErrors in interface SpecDataImpl
Specified by:
getDataErrors in class AbstractSpecDataImpl
Returns:
reference to the spectrum data values.

getShortName

public String getShortName()
Return a symbolic name.

Specified by:
getShortName in interface SpecDataImpl
Specified by:
getShortName in class AbstractSpecDataImpl
Returns:
a symbolic name for the spectrum. Based on the filename.

getFullName

public String getFullName()
Return the full name of spectrum. For memory spectra this has no real meaning (i.e. no disk file or URL) so always returns a string reminding users that they need to save it.

Specified by:
getFullName in interface SpecDataImpl
Specified by:
getFullName in class AbstractSpecDataImpl
Returns:
the String "Memory spectrum".

getDims

public int[] getDims()
Return the data array dimensionality (always length of spectrum).

Specified by:
getDims in interface SpecDataImpl
Specified by:
getDims in class AbstractSpecDataImpl
Returns:
integer array of size 1 returning the number of data values available.

getAst

public uk.ac.starlink.ast.FrameSet getAst()
Return reference to AST frameset that defines the coordinate relations used by this spectrum.

Specified by:
getAst in interface SpecDataImpl
Specified by:
getAst in class AbstractSpecDataImpl
Returns:
reference to a raw AST frameset.

getDataFormat

public String getDataFormat()
Return the data format.

Specified by:
getDataFormat in interface SpecDataImpl
Specified by:
getDataFormat in class AbstractSpecDataImpl
Returns:
the String "MEMORY".

getProperty

public String getProperty(String prop)
Return a known descriptive label. The only fully supported values are "title" (shortname), "label" and "units". These may be retained from a spectrum used to initialise this one. Other values may be queried from any attached FITS headers.

Specified by:
getProperty in interface SpecDataImpl
Overrides:
getProperty in class AbstractSpecDataImpl

finalize

protected void finalize()
                 throws Throwable
Finalise object. Free any resources associated with member variables.

Overrides:
finalize in class Object
Throws:
Throwable

createAst

protected void createAst(uk.ac.starlink.ast.FrameSet sourceSet)
Create an AST FrameSet that relates the spectrum coordinate to data values positions. Using the given FrameSet to define the coordinate systems of the coordinates and data (the coordinate system is the current Frame and the data the base Frame). The FrameSet should be 1D and if null then default systems will be created.


createAst

protected void createAst()
Create an default AST FrameSet when we have no information about the coordinate system or data units.


createAst

protected void createAst(uk.ac.starlink.ast.Frame baseframe,
                         uk.ac.starlink.ast.Frame currentframe)
Create an AST FrameSet that relates the spectrum coordinate to data values positions. Using the given Frame's to define the coordinate systems of the coordinates and data (the coordinate system is the current and base the data). The Frames should be 1D and if null then default systems will be created.


save

public void save()
          throws SplatException
Save is just a copy for this class.

Specified by:
save in interface SpecDataImpl
Specified by:
save in class AbstractSpecDataImpl
Throws:
SplatException - never thrown for this implementation.

copyData

protected void copyData(double[] coords,
                        double[] data,
                        double[] errors)
                 throws SplatException
Make local copies of any given coordinates, data and errors. Caller is responsible for post-initialisation (i.e. calling createAst, if no FrameSet is available) and ensuring that the post-setup is valid (i.e. if coords and data lengths match, and that data and coords or a WCS are present). Errors are reset if none are given.

Throws:
SplatException

getFitsHeaders

public nom.tam.fits.Header getFitsHeaders()
Return any FITS headers we have accumulated.

Specified by:
getFitsHeaders in interface FITSHeaderSource

setSimpleData

public void setSimpleData(double[] coords,
                          String dataUnits,
                          double[] data)
                   throws SplatException
Description copied from interface: EditableSpecDataImpl
Change the complete spectrum data. Takes a copy of all data.

Specified by:
setSimpleData in interface EditableSpecDataImpl
Specified by:
setSimpleData in class AbstractEditableSpecDataImpl
Parameters:
coords - the spectrum coordinates, one per data value.
dataUnits - the data units, if known.
data - the spectrum data values.
Throws:
SplatException

setSimpleUnitData

public void setSimpleUnitData(uk.ac.starlink.ast.FrameSet sourceSet,
                              double[] coords,
                              String dataUnits,
                              double[] data)
                       throws SplatException
Description copied from interface: EditableSpecDataImpl
Change the complete spectrum data, but preserving the properties of an existing FrameSet as part of a new FrameSet. Takes a copy of all data.

Specified by:
setSimpleUnitData in interface EditableSpecDataImpl
Specified by:
setSimpleUnitData in class AbstractEditableSpecDataImpl
Parameters:
sourceSet - the 1D FrameSet to be used for properties. The current Frame defines the spectrum coordinate system.
coords - the spectrum coordinates, one per data value.
dataUnits - the data units, if known.
data - the spectrum data values.
Throws:
SplatException

setFullData

public void setFullData(uk.ac.starlink.ast.FrameSet frameSet,
                        String dataUnits,
                        double[] data)
                 throws SplatException
Description copied from interface: EditableSpecDataImpl
Change the spectrum data and WCS. Takes a copy of all data.

Specified by:
setFullData in interface EditableSpecDataImpl
Specified by:
setFullData in class AbstractEditableSpecDataImpl
Parameters:
frameSet - the FrameSet to be used for generating coordinates.
dataUnits - the data units, if known.
data - the spectrum data values.
Throws:
SplatException

setSimpleDataQuick

public void setSimpleDataQuick(double[] coords,
                               String dataUnits,
                               double[] data)
Description copied from interface: EditableSpecDataImpl
Change the complete spectrum data. Original data is not copied.

Specified by:
setSimpleDataQuick in interface EditableSpecDataImpl
Specified by:
setSimpleDataQuick in class AbstractEditableSpecDataImpl
Parameters:
coords - the spectrum coordinates, one per data value.
dataUnits - the data units, if known.
data - the spectrum data values.

setSimpleUnitDataQuick

public void setSimpleUnitDataQuick(uk.ac.starlink.ast.FrameSet sourceSet,
                                   double[] coords,
                                   String dataUnits,
                                   double[] data)
Description copied from interface: EditableSpecDataImpl
Change the complete spectrum data, but preserving the properties of an existing FrameSet as part of a new FrameSet. Original data is not copied.

Specified by:
setSimpleUnitDataQuick in interface EditableSpecDataImpl
Specified by:
setSimpleUnitDataQuick in class AbstractEditableSpecDataImpl
Parameters:
sourceSet - the 1D FrameSet to be used for properties. The current Frame defines the spectrum coordinate system.
coords - the spectrum coordinates, one per data value.
dataUnits - the data units, if known.
data - the spectrum data values.

setFullDataQuick

public void setFullDataQuick(uk.ac.starlink.ast.FrameSet frameSet,
                             String dataUnits,
                             double[] data)
Description copied from interface: EditableSpecDataImpl
Change the spectrum data and WCS. Original data is not copied.

Specified by:
setFullDataQuick in interface EditableSpecDataImpl
Specified by:
setFullDataQuick in class AbstractEditableSpecDataImpl
Parameters:
frameSet - the FrameSet to be used for generating coordinates.
dataUnits - the data units, if known.
data - the spectrum data values.

setSimpleData

public void setSimpleData(double[] coords,
                          String dataUnits,
                          double[] data,
                          double[] errors)
                   throws SplatException
Description copied from interface: EditableSpecDataImpl
Change the complete spectrum data. Takes a copy of all data.

Specified by:
setSimpleData in interface EditableSpecDataImpl
Specified by:
setSimpleData in class AbstractEditableSpecDataImpl
Parameters:
coords - the spectrum coordinates, one per data value.
dataUnits - the data units, if known.
data - the spectrum data values.
errors - the errors of the spectrum data values.
Throws:
SplatException

setSimpleUnitData

public void setSimpleUnitData(uk.ac.starlink.ast.FrameSet sourceSet,
                              double[] coords,
                              String dataUnits,
                              double[] data,
                              double[] errors)
                       throws SplatException
Description copied from interface: EditableSpecDataImpl
Change the complete spectrum data, but preserving the properties of an existing FrameSet as part of a new FrameSet. Takes a copy of all data.

Specified by:
setSimpleUnitData in interface EditableSpecDataImpl
Specified by:
setSimpleUnitData in class AbstractEditableSpecDataImpl
Parameters:
sourceSet - the 1D FrameSet to be used for properties. The current Frame defines the spectrum coordinate system.
coords - the spectrum coordinates, one per data value.
dataUnits - the data units, if known.
data - the spectrum data values.
errors - the errors of the spectrum data values.
Throws:
SplatException

setFullData

public void setFullData(uk.ac.starlink.ast.FrameSet frameSet,
                        String dataUnits,
                        double[] data,
                        double[] errors)
                 throws SplatException
Description copied from interface: EditableSpecDataImpl
Change the spectrum data and WCS. Takes a copy of all data.

Specified by:
setFullData in interface EditableSpecDataImpl
Specified by:
setFullData in class AbstractEditableSpecDataImpl
Parameters:
frameSet - the FrameSet to be used for generating coordinates.
dataUnits - the data units, if known.
data - the spectrum data values.
errors - the errors of the spectrum data values.
Throws:
SplatException

setSimpleDataQuick

public void setSimpleDataQuick(double[] coords,
                               String dataUnits,
                               double[] data,
                               double[] errors)
Description copied from interface: EditableSpecDataImpl
Change the complete spectrum data. Original data is not copied.

Specified by:
setSimpleDataQuick in interface EditableSpecDataImpl
Specified by:
setSimpleDataQuick in class AbstractEditableSpecDataImpl
Parameters:
coords - the spectrum coordinates, one per data value.
dataUnits - the data units, if known.
data - the spectrum data values.
errors - the errors of the spectrum data values.

setSimpleUnitDataQuick

public void setSimpleUnitDataQuick(uk.ac.starlink.ast.FrameSet sourceSet,
                                   double[] coords,
                                   String dataUnits,
                                   double[] data,
                                   double[] errors)
Description copied from interface: EditableSpecDataImpl
Change the complete spectrum data, but preserving the properties of an existing FrameSet as part of a new FrameSet. Original data is not copied.

Specified by:
setSimpleUnitDataQuick in interface EditableSpecDataImpl
Specified by:
setSimpleUnitDataQuick in class AbstractEditableSpecDataImpl
Parameters:
sourceSet - the 1D FrameSet to be used for properties. The current Frame defines the spectrum coordinate system.
coords - the spectrum coordinates, one per data value.
dataUnits - the data units, if known.
data - the spectrum data values.
errors - the errors of the spectrum data values.

setFullDataQuick

public void setFullDataQuick(uk.ac.starlink.ast.FrameSet frameSet,
                             String dataUnits,
                             double[] data,
                             double[] errors)
Description copied from interface: EditableSpecDataImpl
Change the complete spectrum data. Original data is not copied.

Specified by:
setFullDataQuick in interface EditableSpecDataImpl
Specified by:
setFullDataQuick in class AbstractEditableSpecDataImpl
Parameters:
frameSet - the FrameSet to be used for generating coordinates.
dataUnits - the data units, if known.
data - the spectrum data values.
errors - the errors of the spectrum data values.

setXDataValue

public void setXDataValue(int index,
                          double value)
                   throws SplatException
Description copied from interface: EditableSpecDataImpl
Change a coordinate value.

Specified by:
setXDataValue in interface EditableSpecDataImpl
Specified by:
setXDataValue in class AbstractEditableSpecDataImpl
Throws:
SplatException

setYDataValue

public void setYDataValue(int index,
                          double value)
                   throws SplatException
Description copied from interface: EditableSpecDataImpl
Change a data value.

Specified by:
setYDataValue in interface EditableSpecDataImpl
Specified by:
setYDataValue in class AbstractEditableSpecDataImpl
Throws:
SplatException

setYDataErrorValue

public void setYDataErrorValue(int index,
                               double value)
                        throws SplatException
Description copied from interface: EditableSpecDataImpl
Change a data error value.

Specified by:
setYDataErrorValue in interface EditableSpecDataImpl
Specified by:
setYDataErrorValue in class AbstractEditableSpecDataImpl
Throws:
SplatException

setAst

public void setAst(uk.ac.starlink.ast.FrameSet frameSet)
            throws SplatException
Description copied from interface: EditableSpecDataImpl
Set the FrameSet used for the coordinate system. This should be one-dimensional (at the base and current frames at least) and map the base coordinates to some wavelength-related coordinate.

Specified by:
setAst in interface EditableSpecDataImpl
Specified by:
setAst in class AbstractEditableSpecDataImpl
Throws:
SplatException

setAstCopy

public void setAstCopy(uk.ac.starlink.ast.FrameSet frameSet)
Accept a new FrameSet making a copy of it. If the copy fails then a default FrameSet is created.


createCoords

protected void createCoords()
Create a set of coordinates that match the current FrameSet. This is necessary so that "createAst" can always succeed and is necessary for single editable coordinates. This may fail if the WCS isn't 1D, so we need to work around that possibility.



Copyright © 2018 Central Laboratory of the Research Councils. All Rights Reserved.