|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectspv.spectrum.SpectrumTools
public final class SpectrumTools
This class acts a library where several general-purpose spectrum processing algorithms are lumped together.
| Field Summary | |
|---|---|
static java.lang.String |
SPECTRUM_NAME_SEPARATOR
|
| Constructor Summary | |
|---|---|
SpectrumTools()
|
|
| Method Summary | |
|---|---|
private void |
addMetaParameters(Spectrum spi,
SingleSpectrum spo)
|
private void |
addRadialVelocities(Spectrum spi,
Spectrum spo)
|
void |
buildCombinedName(java.util.List spectra,
CompositeSpectrum outputSpectrum)
|
private CompositeSpectrum |
buildOutputSpectrum(java.util.ArrayList spectra)
|
SingleSpectrum |
buildSubSetSpectrum(Spectrum spi,
java.util.Enumeration list_int,
java.util.Enumeration list_dq)
Builds a spectrum object that contains only a subset of the arrays actually stored in the input spectrum. |
private boolean |
checkCrossNames(boolean match,
java.util.ArrayList names,
java.lang.String name)
|
private java.util.Vector |
checkIntensityUnits(java.util.Enumeration list,
java.util.List spectra)
|
private XUnits |
checkOriginalXUnits(java.util.ArrayList spectra)
|
private YUnits |
checkOriginalYUnits(java.util.ArrayList spectra)
|
java.util.Vector |
checkUnits(java.util.List spectra,
java.util.Enumeration list)
Checks for units mismatches. |
private void |
checkWavelengthUnits(java.util.List spectra)
|
Spectrum |
combine(java.util.List ispectra)
Combines several Spectrum instances into a
MultiSegmentSpectrum instance, or a
EchelleSpectrum instance. |
private DQBits |
combineDQBits(java.util.List spectra)
Combines the DQBits objects of all spectra into a single object. |
private int |
combineDQMasks(java.util.List spectra)
Combine the DQ masks of all spectra inot a single mask. |
private java.util.ArrayList[] |
compress(java.util.ArrayList[] array)
Compresses an array, removing empty elements. |
private java.util.Vector |
findCommonNames(java.util.ArrayList[] input_names)
Finds array names that are common to all input spectra. |
private java.util.Vector |
getCommonDQ(java.util.ArrayList spectra)
Builds an array that stores only the common DQ array names in all spectra in the input list. |
private java.util.Vector |
getCommonIntensities(java.util.ArrayList spectra)
Builds an array that stores only the common intensity array names in all spectra in the input list. |
Spectrum |
getSubRange(Spectrum sp,
double w1,
double w2)
Extracts spectrum in a wavelength subrange. |
private Units |
getUnits(java.util.List spectra,
int index,
java.lang.String id)
|
private boolean |
isComparison(java.util.List spectra)
|
private boolean |
isSED(java.util.List spectra)
|
private boolean |
isSingleInstrument(java.util.ArrayList spectra)
Finds if data comes from a single instrument. |
java.util.List |
openMultiSegment(java.util.List spectra)
Searches input array for instances of MultiSegmentSpectrum. |
private void |
propagateTarget(java.util.List spectra,
CompositeSpectrum spectrum)
|
double[] |
removeDatamarkers(double[] array)
Utility method to remove INDEFs (data markers) from arrays. |
private java.util.ArrayList |
removeDuplicates(java.util.ArrayList list)
|
Spectrum |
toVelocity(Spectrum sp,
double w0)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String SPECTRUM_NAME_SEPARATOR
| Constructor Detail |
|---|
public SpectrumTools()
| Method Detail |
|---|
public double[] removeDatamarkers(double[] array)
array - the array to be cleaned
public Spectrum getSubRange(Spectrum sp,
double w1,
double w2)
sp - the spectrum which to take a subrange fromw1 - the minimum wavelengthw2 - the maximum wavelength
SingleSpectrum
format. null is returned if the
intersection of the desired range and the range
spanned by the input spectrum is empty.
public Spectrum toVelocity(Spectrum sp,
double w0)
public Spectrum combine(java.util.List ispectra)
throws SpectrumException
Spectrum instances into a
MultiSegmentSpectrum instance, or a
EchelleSpectrum instance. This method assumes
that the factory creates arrays consistently named across
different instruments. If array names were arbitrary
instead, we would need specific rules to combine them.
The type of the resulting object depends on the origin
of the input spectra. If they all come from the same
instrument, the result will be an EchelleSpectrum
instance. Otherwise, it will be am instance of
MultiSegmentSpectrum. The instrument
identification is taken from the DQBits objects
associated with each input spectrum.
This method assumes that all spectra to be combined share the same physical units in arrays of same ID. Note however that no check is performed regarding the objects' ID or target name. Thus this method can be used to combine together data from different astronomical sources into a single entity. Altough questionable (to say the least) from a strict data analysis perspective, the ability to overplot data from different sources onto a single stretch of WCS real state may be useful in some circunstances.
Intensity arrays that appear only on a subset of the input spectra are not copied into the output product. DQ arrays are handled differently though. If DQ arrays with same name exist only in a subset of the input spectra, they are included in the output product, so they can be used to mask pixels locally in the output spectrum. This is relevant when data from different instruments is mixed together.
Due to lack of a better criterion, both the header and
the wavelength ID of the output spectrum are arbitrarily
taken from the first spectrum in the input vector. The
global DQ mask of all input spectra are ORed into a
single value. The DQBits object resulting
from the combination contains all bit flags stored in
the combined objects. The name of the combined spectrum
is built by stringing together all the component's names.
This is a shallow combine operation, meaning that, if any spectrum in the list to be combined has internal structure, that structure will disappear and the spectrum will be handled as a single flat unit.
If a single spectrum is input, this method returns a reference to the input, not a new object.
ispectra - the spectra to be combined
SingleSpectrum instance, or
null if the operation fails.
SpectrumException - if there is a units mismatch
public void buildCombinedName(java.util.List spectra,
CompositeSpectrum outputSpectrum)
private CompositeSpectrum buildOutputSpectrum(java.util.ArrayList spectra)
private boolean isSED(java.util.List spectra)
private void propagateTarget(java.util.List spectra,
CompositeSpectrum spectrum)
private boolean isComparison(java.util.List spectra)
public java.util.List openMultiSegment(java.util.List spectra)
MultiSegmentSpectrum.
For any such element, opens it and adds all elements of the internal
structure to the output array.
spectra - input array with instances of Spectrum
private java.util.ArrayList removeDuplicates(java.util.ArrayList list)
private boolean isSingleInstrument(java.util.ArrayList spectra)
DQBits object in each spectrum in input
list to get instrument name.
spectra - the list with input spectra
true if all spectra
in list come from single instrumentprivate DQBits combineDQBits(java.util.List spectra)
private int combineDQMasks(java.util.List spectra)
private java.util.Vector getCommonIntensities(java.util.ArrayList spectra)
spectra - the input lists
private java.util.Vector getCommonDQ(java.util.ArrayList spectra)
spectra - the input lists
private java.util.ArrayList[] compress(java.util.ArrayList[] array)
array - the array
private java.util.Vector findCommonNames(java.util.ArrayList[] input_names)
input_names - list of names
private boolean checkCrossNames(boolean match,
java.util.ArrayList names,
java.lang.String name)
public SingleSpectrum buildSubSetSpectrum(Spectrum spi,
java.util.Enumeration list_int,
java.util.Enumeration list_dq)
spi - input spectrumlist_int - list with array names to be included in outputlist_dq - list with DQ array names to be included in output
private void addMetaParameters(Spectrum spi,
SingleSpectrum spo)
private void addRadialVelocities(Spectrum spi,
Spectrum spo)
public java.util.Vector checkUnits(java.util.List spectra,
java.util.Enumeration list)
throws SpectrumException
The returned object is not an Enumeration because
enumerations can be scanned only once. This method returns
instead a parent Vector object from which the
required enumeration can be retrieved as many times as desired.
spectra - the spectra to be analysedlist - the list of array names to be analysed
SpectrumException
private java.util.Vector checkIntensityUnits(java.util.Enumeration list,
java.util.List spectra)
private Units getUnits(java.util.List spectra,
int index,
java.lang.String id)
private void checkWavelengthUnits(java.util.List spectra)
throws SpectrumException
SpectrumExceptionprivate XUnits checkOriginalXUnits(java.util.ArrayList spectra)
private YUnits checkOriginalYUnits(java.util.ArrayList spectra)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||