public final class Suite extends java.lang.Object implements SampleGroup
Modifier and Type | Class and Description |
---|---|
class |
Suite.MissingSampleNameException
This exception indicates that a supplied argument did not contain
an expected sample name.
|
static interface |
Suite.SavedListener
A listener interface for modifications to the Suite's save state.
|
static interface |
Suite.SiteNamer
A SiteNamer turns a sample name into a site name.
|
Constructor and Description |
---|
Suite(java.lang.String creator)
Creates a new, empty suite.
|
Modifier and Type | Method and Description |
---|---|
void |
addSavedListener(Suite.SavedListener savedListener)
Add a listener for the Suite's save state
|
void |
addTreatmentStep(TreatmentStep step)
Adds a datum to the suite.
|
void |
alignSectionDeclinations(int margin,
double targetDeclination,
CoreSections.TargetDeclinationType targetType)
Align the declinations of core sections in this suite.It is assumed that
the suite is continuous; the discrete IDs of samples are interpreted as
core section identifiers.
|
boolean |
areSectionEndDirectionsDefined(int margin)
Report whether samples near the ends of core sections have an
associated direction, e.g. a sample direction calculated by PCA.
|
void |
calculateAmsStatistics(java.util.List<Sample> samples,
AmsCalculationType calcType,
java.lang.String scriptPath)
Calculates and stores AMS statistics using an external script.
|
static SuiteCalcs |
calculateMultiSuiteMeans(java.util.List<Suite> suites)
Calculates and returns Fisher statistics on all the calculated PCA
directions for samples within supplied suites.
|
void |
calculateSiteFishers(Correction correction)
For each site in this suite, calculates Fisher statistics on the sample
PCA directions.
|
void |
calculateSuiteMeans(java.util.List<Sample> selSamples,
java.util.List<Site> selSites)
Calculates Fisher statistics on all the calculated PCA directions for
samples within the suite.
|
void |
clearAmsCalculations()
Clears any AMS calculations on this suite
|
void |
clearSites(java.util.Collection<Sample> samples)
Clears sites for specified samples within this suite.
|
boolean |
containsSample(java.lang.String id)
Determine whether this suite contain a same with a specified identifier
(name).
|
void |
convertDiscreteToContinuous(java.io.File file)
Converts a discrete suite to a continuous suite, using a file to provide
the mapping from sample names to depths.
|
void |
convertDiscreteToContinuous(java.util.Map<java.lang.String,java.lang.String> nameToDepth)
Converts this suite from a discrete suite to a continuous suite
using a supplied mapping from sample names to depths.
|
void |
doAllCalculations(Correction correction,
java.lang.String greatCirclesValidityCondition)
Performs all possible sample and site calculations.
|
static java.util.List<FisherValues> |
doReversalTest(java.util.List<Suite> suites)
Performs a reversal test on a list of suites.
|
void |
doSampleCalculations(Correction correction)
Performs calculations for each sample in this suite.
|
void |
doSiteCalculations(Correction correction,
java.lang.String greatCirclesValidityCondition)
Calculates mean directions for all suitable sites in the suite.
|
void |
exportToFiles(java.io.File directory,
java.util.List<TreatmentParameter> fields)
Exports a subset of this suite's data to multiple files, one file per
sample.
|
void |
fromString(java.lang.String string)
Sets suite data from a string.
|
java.util.List<KentParams> |
getAmsBootstrapParams()
Returns the parameters of the last AMS bootstrap statistics (if any)
calculated on this suite's data.
|
java.util.List<KentParams> |
getAmsHextParams()
Returns the parameters of the last AMS Hext statistics (if any)
calculated on this suite's data.
|
java.lang.String |
getCreator()
Returns a string identifying the program and version which created this
suite.
|
Sample |
getCurrentSample()
Returns the current sample
|
int |
getCurrentSampleIndex()
Returns the index defining the current sample.
|
CustomFields<java.lang.String> |
getCustomFlagNames()
Returns the names (titles) of the custom flags for this suite.
|
CustomFields<java.lang.String> |
getCustomNoteNames()
Returns the names (titles) of the custom notes for this suite.
|
int |
getIndexBySample(Sample sample)
Returns the index of a specified sample within this suite.
|
double |
getMaxDepth()
For a continuous suite, returns the maximum depth of a sample within the
suite.
|
MeasurementType |
getMeasurementType()
Returns the measurement type of this suite (discrete or continuous)
|
double |
getMinDepth()
For a continuous suite, returns the minimum depth of a sample within the
suite.
|
java.lang.String |
getName()
Returns the name of this suite.
|
int |
getNumSamples()
Returns the number of samples in this suite.
|
java.io.File |
getPuffinFile()
Returns the name of the PuffinPlot file associated with this suite, if
any.
|
Sample |
getSampleByIndex(int i)
Returns the sample with the specified index.
|
Sample |
getSampleByName(java.lang.String name)
Returns a sample from this suite with the specified name, or
null
if no such sample exists. |
java.util.List<Sample> |
getSamples()
Returns all the samples in this suite.
|
java.util.List<Sample> |
getSamplesByDiscreteId(java.lang.String id)
Return the samples with a given discrete ID.
|
Site |
getSiteByName(java.lang.String siteName)
Returns a site with the given name, or
null if this suite
contains no such site. |
java.util.List<FisherValues> |
getSiteFishers()
Returns the results of the per-site Fisher statistics calculated by
calculateSiteFishers(net.talvi.puffinplot.data.Correction) . |
java.util.List<Site> |
getSites()
Returns the sites within this suite.
|
SuiteCalcs |
getSuiteMeans()
Returns the Fisher parameters calculated on the entire suite.
|
void |
importAmsFromAsc(java.util.List<java.io.File> files,
boolean magneticNorth,
boolean overwriteSampleCorrection,
boolean overwriteFormationCorrection)
Imports AMS data from ASC files in the format produced by Agico's SAFYR
and SUSAR programs.
|
void |
importAmsFromDelimitedFile(java.util.List<java.io.File> files,
boolean directions)
Imports AMS data from a whitespace-delimited file.
|
void |
importLocations(java.io.File file)
Imports site locations from a CSV file.
|
boolean |
isEmpty()
Determines whether this suite is empty.
|
boolean |
isFilenameSet()
Reports whether a default PuffinPlot file is set for this suite.
|
boolean |
isSaved() |
void |
mergeDuplicateSamples(java.util.Collection<Sample> samples)
Within the supplied collection of samples, any two or more samples which
have the same depth or discrete ID will be merged into a single sample.
|
void |
mergeDuplicateTreatmentSteps(java.util.Collection<Sample> samplesToMerge)
Within each of the supplied samples, merges any TreatmentStep objects
which have the same treatment type and treatment level.
|
java.util.List<java.lang.String> |
readDirectionalData(java.util.Collection<java.io.File> files)
Reads sample direction data from text files.Text files should have no
header lines.
|
java.util.List<java.lang.String> |
readFiles(java.util.List<java.io.File> files)
Convenience method for reading PuffinPlot files.This method is a wrapper
for the fully specified method
readFiles(List, FileType,
Map) which provides defaults for all the arguments
except for the list of file names. |
java.util.List<java.lang.String> |
readFiles(java.util.List<java.io.File> files,
FileType fileType,
java.util.Map<java.lang.String,java.lang.Object> importOptions)
Reads data into this suite from the specified files.
|
void |
removeSamples(java.util.Collection<Sample> samplesToRemove)
Removes the specified samples from this suite.
|
void |
removeSamplesByTreatmentType(java.util.Collection<Sample> removableSamples,
TreatmentType treatmentType)
For every sample in the supplied collection: remove the sample from
this suite if any of its treatment steps has the specified treatment
type.
|
void |
removeSamplesOutsideDepthRange(double minDepth,
double maxDepth)
Retains the samples between the specified depths in the suite,
and removes all samples outside this range.
|
void |
removeSavedListener(Suite.SavedListener savedListener)
Remove a listener for the Suite's save state
|
void |
rescaleMagSus(double factor)
Multiplies all magnetic susceptibility measurements in this suite by the
specified factor.
|
void |
rotateSamplesByDiscreteId(java.util.Map<java.lang.String,java.lang.Double> rotations)
Rotate the declination of magnetic moment data in this suite according to
the discrete ID of the sample.
|
void |
save()
If a default PuffinPlot file is set for this suite, saves the suite data
to that file.
|
void |
saveAs(java.io.File file)
Saves the data in this suite to a specified file.
|
void |
saveCalcsSample(java.io.File file)
Exports sample calculations to a specified file in CSV format.
|
void |
saveCalcsSite(java.io.File file)
Exports site calculations to a specified file in CSV format.
|
void |
saveCalcsSuite(java.io.File file)
Saves the Fisher mean direction for the whole suite to a file in CSV
format
|
void |
setCurrentSampleIndex(int value)
Sets the index defining the current sample.
|
void |
setNamedSiteForSamples(java.util.Collection<Sample> samples,
java.lang.String siteName)
Explicitly sets a site for the specified samples.
|
void |
setSaved(boolean saved)
Sets this suite's "saved" flag, which records whether the suite
has been saved since its last modification.
|
void |
setSiteNamesByDepth(java.util.Collection<Sample> samples,
double thickness)
Sets site names for a continuous suite according to the depth of the
samples.
|
void |
setSiteNamesBySubstring(java.util.Collection<Sample> samples,
java.util.BitSet charMask)
Sets site names for samples according to chosen characters from the
sample names.
|
void |
setSitesForSamples(java.util.Collection<Sample> samples,
Suite.SiteNamer siteNamer)
Sets sites for supplied samples according to a supplied site namer.
|
void |
sortSamplesByDepth()
Sorts this suite's samples in ascending order of depth
|
java.lang.String |
toString()
Returns the name of this suite.
|
java.util.List<java.lang.String> |
toStrings()
Returns strings representing data about this suite.
|
void |
updateReverseIndex()
Update this suit's internal index mapping samples to their indices
within the suite.
|
public Suite(java.lang.String creator)
creator
- a string identifying the program and version creating the
suitepublic void updateReverseIndex()
public void calculateSuiteMeans(java.util.List<Sample> selSamples, java.util.List<Site> selSites)
getSuiteMeans()
.selSamples
- samples for which to calculate meansselSites
- sites for which to calculate meanspublic static SuiteCalcs calculateMultiSuiteMeans(java.util.List<Suite> suites)
suites
- the suites on which to calculate statisticspublic static java.util.List<FisherValues> doReversalTest(java.util.List<Suite> suites)
suites
- the suites on which to perform the test.public SuiteCalcs getSuiteMeans()
public void calculateSiteFishers(Correction correction)
correction
- the correction to apply to the magnetic moment
measurements when performing the PCA calculationsgetSiteFishers()
,
Site.calculateFisherStats(net.talvi.puffinplot.data.Correction)
public java.util.List<FisherValues> getSiteFishers()
calculateSiteFishers(net.talvi.puffinplot.data.Correction)
.public boolean isFilenameSet()
true
if a default PuffinPlot file is set for this suitepublic void save() throws PuffinUserException
PuffinUserException
- if an error occurred while saving the datapublic void saveAs(java.io.File file) throws PuffinUserException
file
- the file to which to save the suite's dataPuffinUserException
- if an error occurred while saving datapublic void addTreatmentStep(TreatmentStep step)
UNSET
. In the latter case, the suite's measurement type will be
set to that of the supplied datum.step
- the datum to addjava.lang.IllegalArgumentException
- if d is null, or if the measurement type
of is invalid (i.e. it is null, UNSET, or incompatible with this suite's
measurement type)public void doSampleCalculations(Correction correction)
correction
- the correction to apply to the magnetic moment data
when performing the calculationspublic void doSiteCalculations(Correction correction, java.lang.String greatCirclesValidityCondition)
correction
- the correction to apply to the magnetic moment
data when performing the calculationsgreatCirclesValidityCondition
- an expression which is evaluated
to determine whether a great-circles direction is considered valid
(see GreatCircles.instance(java.util.List, java.util.List, java.lang.String)
).public java.util.List<java.lang.String> readFiles(java.util.List<java.io.File> files) throws java.io.IOException
readFiles(List, FileType,
Map)
which provides defaults for all the arguments
except for the list of file names.
The filetype is set to PUFFINPLOT_NEW.
files
- files to readjava.io.IOException
- if an exception occurs during file readingpublic java.util.List<java.lang.String> readFiles(java.util.List<java.io.File> files, FileType fileType, java.util.Map<java.lang.String,java.lang.Object> importOptions) throws java.io.IOException
files
- the files from which to read the data (non-null, non-empty)fileType
- type of the specified filesimportOptions
- extra options passed to file importersjava.io.IOException
- if an I/O error occurred while reading the filespublic boolean isEmpty()
true
iff this suite is emptypublic java.util.List<java.lang.String> readDirectionalData(java.util.Collection<java.io.File> files) throws java.io.IOException
files
- files from which to readjava.io.IOException
- if an error occurred while reading the filespublic void doAllCalculations(Correction correction, java.lang.String greatCirclesValidityCondition)
correction
- the correction to apply to the magnetic moment data
when performing the calculationsgreatCirclesValidityCondition
- an expression which is evaluated to
determine whether a great-circles direction is considered valid (see
GreatCircles.instance(java.util.List, java.util.List, java.lang.String)
).public void saveCalcsSample(java.io.File file) throws PuffinUserException
file
- the file to which to write the sample calculationsPuffinUserException
- if an error occurred while writing the filepublic void saveCalcsSite(java.io.File file) throws PuffinUserException
file
- the file to which to write the site calculationsPuffinUserException
- if an error occurred while writing the filepublic void saveCalcsSuite(java.io.File file) throws PuffinUserException
file
- the file to which to write the mean directionPuffinUserException
- if an error occurred while writing the filepublic Sample getSampleByName(java.lang.String name)
null
if no such sample exists.name
- a sample namenull
if no such sample existspublic int getCurrentSampleIndex()
public void setCurrentSampleIndex(int value)
value
- the index defining the current samplepublic Sample getCurrentSample()
public java.util.List<Sample> getSamples()
getSamples
in interface SampleGroup
public MeasurementType getMeasurementType()
public java.lang.String getName()
public int getNumSamples()
public Sample getSampleByIndex(int i)
i
- an index number for a samplepublic int getIndexBySample(Sample sample)
sample
- a sample in the suite-1
if not in this suitepublic java.lang.String toString()
toString
in class java.lang.Object
public java.util.List<java.lang.String> toStrings()
public void fromString(java.lang.String string)
toStrings()
method.string
- a string from which to read suite datapublic void importLocations(java.io.File file) throws java.io.IOException
file
- the file from which to read site locationsjava.io.IOException
- if an error occurred while reading the filepublic void importAmsFromDelimitedFile(java.util.List<java.io.File> files, boolean directions) throws java.io.IOException
directions==false
, line format is k11 k22 k33 k12 k23 k13
(tensor components) otherwise it's
inc1 dec1 inc2 dec2 inc3 dec3 (axis directions, decreasing magnitude).
If there's no sample in the suite from which to take the sample
and formation corrections, importAmsWithDialog will try to read them as
fields appended to the end of the line.
Not fully tested -- use with caution. Not currently accessible from the PuffinPlot GUI.
files
- the files from which to read the datadirections
- true
to read axis directions,
false
to read tensor componentsjava.io.IOException
- if there was an I/O error reading the filespublic void importAmsFromAsc(java.util.List<java.io.File> files, boolean magneticNorth, boolean overwriteSampleCorrection, boolean overwriteFormationCorrection) throws java.io.IOException
overwriteSampleCorrection
and overwriteFormationCorrection
arguments only have an effect when
importing into an existing sample; if a new sample is created for
AMS data, the orientations in the ASC file will always be used.files
- the ASC files to readmagneticNorth
- true
if the sample and formation dip
azimuths in the file
are relative to magnetic north; false
if they are relative to
geographic northoverwriteSampleCorrection
- If importing to an existing sample,
overwrite the sample's sample correction with the values specified
in the ASC file. Otherwise, retain the values already set for the
sample.overwriteFormationCorrection
- If importing to an existing sample,
overwrite the sample's formation correction with the values specified
in the ASC file. Otherwise, retain the values already set for the
sample.java.io.IOException
- if an I/O error occurred while reading the filepublic void exportToFiles(java.io.File directory, java.util.List<TreatmentParameter> fields)
directory
- the directory in which to create the filesfields
- the fields to exportpublic CustomFields<java.lang.String> getCustomFlagNames()
public CustomFields<java.lang.String> getCustomNoteNames()
public java.util.List<KentParams> getAmsBootstrapParams()
public java.util.List<KentParams> getAmsHextParams()
public void clearAmsCalculations()
public java.util.List<Site> getSites()
public Site getSiteByName(java.lang.String siteName)
null
if this suite
contains no such site.siteName
- a site namenull
if this suite
contains no such sitepublic java.io.File getPuffinFile()
public boolean isSaved()
public void setSaved(boolean saved)
saved
- the saved state to setpublic java.lang.String getCreator()
public java.util.List<Sample> getSamplesByDiscreteId(java.lang.String id)
id
- a discrete IDpublic void rotateSamplesByDiscreteId(java.util.Map<java.lang.String,java.lang.Double> rotations)
rotations
- a map from discrete sample IDs to rotation angles
(clockwise in degrees)public void alignSectionDeclinations(int margin, double targetDeclination, CoreSections.TargetDeclinationType targetType)
margin
- the number of samples to average at the end of each section
to determine the declinationtargetDeclination
- the declination to which to align the coretargetType
- the core declination to align with the targetCoreSections.alignSections(int, double, net.talvi.puffinplot.data.CoreSections.TargetDeclinationType)
public boolean areSectionEndDirectionsDefined(int margin)
margin
- the number of samples to regard as being "near" the
end of a core sectiontrue
if and only if all samples near the end of
a core section have an associated directionCoreSections.areSectionEndDirectionsDefined(int)
public void mergeDuplicateTreatmentSteps(java.util.Collection<Sample> samplesToMerge)
samplesToMerge
- samples containing the TreatmentStep objects to
merge (where possible)public void mergeDuplicateSamples(java.util.Collection<Sample> samples)
samples
- the collection of samples within which to merge duplicatespublic void calculateAmsStatistics(java.util.List<Sample> samples, AmsCalculationType calcType, java.lang.String scriptPath) throws java.io.IOException, java.lang.IllegalArgumentException
samples
- the samples on which to calculate statisticscalcType
- the type of AMS calculation to performscriptPath
- the filesystem path of the script which will perform
the calculationjava.io.IOException
- if there was an error running the script or reading
its outputjava.lang.IllegalArgumentException
- if the samples contain insufficient AMS
datapublic double getMinDepth()
public double getMaxDepth()
public void clearSites(java.util.Collection<Sample> samples)
null
, and any sites with
no associated samples will be removed from this suite's list of sites.samples
- samples for which to clear sitespublic void setSitesForSamples(java.util.Collection<Sample> samples, Suite.SiteNamer siteNamer)
samples
- the samples for which to set sitessiteNamer
- the site namer which will produce the site namespublic void setNamedSiteForSamples(java.util.Collection<Sample> samples, java.lang.String siteName)
samples
- the samples for which to set the sitesiteName
- the name of the site into which to put the samplespublic void setSiteNamesBySubstring(java.util.Collection<Sample> samples, java.util.BitSet charMask)
samples
- the samples for which to set sitescharMask
- the mask determining which characters to use for the site
namepublic void setSiteNamesByDepth(java.util.Collection<Sample> samples, double thickness)
samples
- the samples for which to set site namesthickness
- the thickness of each sitepublic boolean containsSample(java.lang.String id)
id
- a sample identifiertrue
if this suite contains a sample with the specified
identifierpublic void rescaleMagSus(double factor)
factor
- a factor by which to multiply all the magnetic
susceptibility measurements in this suitepublic void sortSamplesByDepth()
public void removeSamplesOutsideDepthRange(double minDepth, double maxDepth)
minDepth
- Minimum depth of samples to retainmaxDepth
- Maximum depth of samples to retainpublic void removeSamplesByTreatmentType(java.util.Collection<Sample> removableSamples, TreatmentType treatmentType)
removableSamples
- samples to consider for removal (must be
within this suite)treatmentType
- the treatment type that selects which samples
should be removed.public void removeSamples(java.util.Collection<Sample> samplesToRemove)
samplesToRemove
- the samples to removepublic void convertDiscreteToContinuous(java.util.Map<java.lang.String,java.lang.String> nameToDepth) throws Suite.MissingSampleNameException
nameToDepth
- a map containing a depth string for each sample nameSuite.MissingSampleNameException
- if the map does not contain
all the sample names in this suite as keyspublic void convertDiscreteToContinuous(java.io.File file) throws java.io.IOException, Suite.MissingSampleNameException
file
- a text file consisting of lines in the format
<sample-name>,<sample-depth>java.io.IOException
- if there was a problem reading the fileSuite.MissingSampleNameException
- if there are samples in this suite
which are not listed in the specified filepublic void addSavedListener(Suite.SavedListener savedListener)
savedListener
- the new listenerpublic void removeSavedListener(Suite.SavedListener savedListener)
savedListener
- the listener to remove