public final class Suite
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Suite.AmsCalcType
The type of a statistical calculation on AMS tensors.
|
class |
Suite.MissingSampleNameException |
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 |
addDatum(Datum d)
Adds a datum to the suite.
|
void |
addSavedListener(Suite.SavedListener savedListener)
Add a listener for the Suite's save state
|
void |
calculateAmsStatistics(java.util.List<Sample> samples,
Suite.AmsCalcType 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 suite.
|
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()
Clears all sites for 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) |
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)
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)
Calculate mean directions for all suitable sites in the suite.
|
void |
exportToFiles(java.io.File directory,
java.util.List<DatumField> 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()
Get 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.
|
java.util.List<java.lang.String> |
getLoadWarnings()
Get the list of warnings produced when data was being loaded from
one or more files.
|
double |
getMaxDepth()
For a continuous suite, returns the maximum depth of a sample within the suite.
|
MeasType |
getMeasType()
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.
|
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.
|
Datum |
getTrayCorrection(Datum d)
Returns the tray correction for the specified data point.
|
void |
importAmsFromAsc(java.util.List<java.io.File> files,
boolean magneticNorth)
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 |
mergeDuplicateMeasurements(java.util.Collection<Sample> samples)
Merges Datum objects with the same Sample and treatment step (EXPERIMENTAL).
|
void |
readDirectionalData(java.util.Collection<java.io.File> files)
Reads sample direction data from text files.
|
void |
readFiles(java.util.List<java.io.File> files)
Convenience method for reading PuffinPlot files.
|
void |
readFiles(java.util.List<java.io.File> files,
SensorLengths sensorLengths,
TwoGeeLoader.Protocol protocol,
boolean usePolarMoment,
FileType fileType,
FileFormat format,
java.util.Map<java.lang.Object,java.lang.Object> importOptions)
Reads data into this suite from the specified files.
|
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 |
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.
|
public Suite(java.lang.String creator)
creator
- a string identifying the program and version creating the suitepublic java.util.List<java.lang.String> getLoadWarnings()
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)
getSuiteMeans()
.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 addDatum(Datum d)
UNSET
. In the latter case, the suite's measurement
type will be set to that of the supplied datum.d
- the datum to addjava.lang.IllegalArgumentException
- if the measurement type of
the datum does not match the measurement type of the suitepublic void doSampleCalculations(Correction correction)
correction
- the correction to apply to the magnetic moment
data when performing the calculationspublic void doSiteCalculations(Correction correction)
correction
- the correction to apply to the magnetic moment
data when performing the calculationspublic void readFiles(java.util.List<java.io.File> files) throws java.io.IOException
ReadFiles(List<File>, SensorLengths, TwoGeeLoader.Protocol, boolean,
FileType, FileFormat, Map<Object,Object>)
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 void readFiles(java.util.List<java.io.File> files, SensorLengths sensorLengths, TwoGeeLoader.Protocol protocol, boolean usePolarMoment, FileType fileType, FileFormat format, java.util.Map<java.lang.Object,java.lang.Object> importOptions) throws java.io.IOException
Reads data into this suite from the specified files.
After readFiles returns, #getLoadWarnings() can be used to return a list of problems that occurred during file reading.
files
- the files from which to read the datasensorLengths
- for 2G long core files only: the effective lengths
of the magnetometer's SQUID sensors,
used to correct Cartesian magnetic moment dataprotocol
- for 2G files only: the measurement protocol usedusePolarMoment
- for 2G files only: use polar (dec/inc/int)
data fields instead of Cartesian ones (X/Y/Z) to determine magnetic momentfileType
- type of the specified filesformat
- explicitly specified custom tabular file formatimportOptions
- 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 void 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)
correction
- the correction to apply to the magnetic moment
data when performing the calculationspublic 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()
public MeasType getMeasType()
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 Datum getTrayCorrection(Datum d)
d
- a data point representing a magnetic measurementpublic 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
Imports AMS data from a whitespace-delimited file.
If 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 currently used in PuffinPlot.
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) throws java.io.IOException
files
- the ASC files to readmagneticNorth
- true
if the sample dip azimuths
in the file are relative to magnetic north; false
if
they are relative to geographic northjava.io.IOException
- if an I/O error occurred while reading the filepublic void exportToFiles(java.io.File directory, java.util.List<DatumField> 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 void mergeDuplicateMeasurements(java.util.Collection<Sample> samples)
samples
- samples containing the Datum objects to merge (where possible)public void calculateAmsStatistics(java.util.List<Sample> samples, Suite.AmsCalcType 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()
public 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 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
java.io.IOException
Suite.MissingSampleNameException
public void addSavedListener(Suite.SavedListener savedListener)
savedListener
- the new listenerpublic void removeSavedListener(Suite.SavedListener savedListener)
savedListener
- the listener to remove