Skip to content

Commit

Permalink
Merge pull request #230 from bowring/11april2024
Browse files Browse the repository at this point in the history
Progress
  • Loading branch information
bowring authored Apr 25, 2024
2 parents 364e29f + e92e34a commit 9c74781
Show file tree
Hide file tree
Showing 24 changed files with 1,204 additions and 34 deletions.
6 changes: 3 additions & 3 deletions TripoliCore/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ dependencies {
// https://mvnrepository.com/artifact/org.jblas/jblas
implementation("org.jblas:jblas:1.2.5")

// https://mvnrepository.com/artifact/com.thoughtworks.xstream/xstream
implementation("com.thoughtworks.xstream:xstream:1.4.20")


testImplementation("com.github.cirdles:commons:bc38781605")
Expand All @@ -84,15 +86,13 @@ tasks.test {
useJUnitPlatform()
}


val timestamp = {
SimpleDateFormat("dd MMMM yyyy").format(Date())
}
repositories {
mavenCentral()
}


extraJavaModuleInfo {
failOnMissingModuleInfo.set(false)
automaticModule("commons-bc38781605.jar", "commons.bc38781605")
Expand All @@ -105,7 +105,7 @@ extraJavaModuleInfo {

automaticModule("org.jblas:jblas", "jblas")

//automaticModule("javax.xml.bind:jaxb-api", "jaxb.api")//javax.xml.bind:jaxb-api:2.3.1
automaticModule("com.thoughtworks.xstream:xstream", "xstream")//javax.xml.bind:jaxb-api:2.3.1
}


Expand Down
2 changes: 2 additions & 0 deletions TripoliCore/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
requires jakarta.xml.bind;
requires java.xml.bind;
requires jblas;
requires xstream;
requires java.logging;


exports org.cirdles.tripoli;
Expand Down
109 changes: 109 additions & 0 deletions TripoliCore/src/main/java/org/cirdles/tripoli/DataDictionary.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/****************************************************************************
* Copyright 2004-2024 James F. Bowring and www.Earth-Time.org
* Ported from OGTripoli
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
****************************************************************************/

package org.cirdles.tripoli;

public enum DataDictionary {
;
public static String[] EarthTimeBariumPhosphateICIsotopeNames = new String[]{
"pct130Ba_BaPO2",
"pct132Ba_BaPO2",
"pct134Ba_BaPO2",
"pct135Ba_BaPO2",
"pct136Ba_BaPO2",
"pct137Ba_BaPO2",
"pct138Ba_BaPO2",
"pct16O_BaPO2",
"pct17O_BaPO2",
"pct18O_BaPO2"
};

public static String[] EarthTimeThalliumICIsotopeNames = new String[]{
"pct203Tl_Tl",
"pct205Tl_Tl"
};

public static String[] EarthTimeTracerRatioNames = new String[]{
"206_204",
"207_206",
"206_208",
"206_205",
"207_205",
"208_205",
"202_205",
"238_235",
"233_235",
"233_236",
"235_205"};

public static String[] UPbReduxMeasuredRatioNames = new String[]{
"206_204",
"207_204",
"208_204",
"206_207",
"206_208",
"204_205",
"206_205",
"207_205",
"208_205",
"202_205",
"238_236", //jan 2011
"233_236",
"238_235",
"233_235",
"238_233"};
public static String[] isotopeNames = new String[]
{"Pb205",
"U235"};
public static String[] TracerTypes = new String[]
{"mixed 205-235",
"mixed 205-233-235",
"mixed 208-235",
"mixed 205-233-236",
"mixed 202-205-233-235",
"mixed 202-205-233-236",
"mixed 205-233-235-230Th"};

public static String getEarthTimeBariumPhosphateICIsotopeNames(int index) {
return EarthTimeBariumPhosphateICIsotopeNames[index];
}

public static String getEarthTimeThalliumICIsotopeNames(int index) {
return EarthTimeThalliumICIsotopeNames[index];
}

public static String getTracerRatioName(int index) {
return "r" + EarthTimeTracerRatioNames[index] + "t";
}

public static String getTracerIsotopeConcName(int index) {
return "conc" + isotopeNames[index] + "t";
}

public static String getMeasuredRatioName(int index) {
return "r" + UPbReduxMeasuredRatioNames[index] + "m";
}

public static String getElementNameOfRatio(String name) {
if (name.substring(1, 1).equals("0"))
return "Pb";
else
return "U";
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public enum TripoliConstants {


public static final String SPACES_100 = CharBuffer.allocate(100).toString().replace('\0', ' ');
public static final String SPACES_150 = CharBuffer.allocate(150).toString().replace('\0', ' ');

public static final String MISSING_STRING_FIELD = "MISSING";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,19 @@ public class UserFunction implements Serializable {
@Serial
private static final long serialVersionUID = -5408855769497340457L;
private String name;
private String etReduxName;
private int columnIndex;
private boolean treatAsIsotopicRatio;
private boolean displayed;
private boolean inverted;

public UserFunction(String name, int columnIndex) {
this(name, columnIndex, false, true);
}

public UserFunction(String name, int columnIndex, boolean treatAsIsotopicRatio, boolean displayed) {
this.name = name;
this.etReduxName = "";
this.columnIndex = columnIndex;
this.treatAsIsotopicRatio = treatAsIsotopicRatio;
this.displayed = displayed;
Expand All @@ -43,6 +49,14 @@ public String getName() {
return name;
}

public String getEtReduxName() {
return etReduxName;
}

public void setEtReduxName(String etReduxName) {
this.etReduxName = etReduxName;
}

public String showInvertedRatioName() {
String retVal = name;
if (treatAsIsotopicRatio) {
Expand All @@ -60,6 +74,10 @@ public boolean isTreatAsIsotopicRatio() {
return treatAsIsotopicRatio;
}

public void setTreatAsIsotopicRatio(boolean treatAsIsotopicRatio) {
this.treatAsIsotopicRatio = treatAsIsotopicRatio;
}

public boolean isDisplayed() {
return displayed;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,11 @@ public void extractMassSpecDataFromPath(Path dataFilePath)
}
} else {
// case1
analysisName = dataFilePath.toFile().getName().substring(0, dataFilePath.toFile().getName().length() - 4);
analysisMethod = AnalysisMethod.createAnalysisMethodFromCase1(massSpecExtractedData);
initializeBlockProcessing();
}

}

public void initializeBlockProcessing() {
Expand Down Expand Up @@ -394,7 +396,7 @@ public AllBlockInitForMCMC.PlottingData assemblePostProcessPlottingData() {

public final String prettyPrintAnalysisSummary() {
return analysisName +
SPACES_100.substring(0, 40 - analysisName.length()) +
SPACES_150.substring(0, 100 - analysisName.length()) +
(null == analysisMethod ? "NO Method" : analysisMethod.prettyPrintMethodSummary(false));
}

Expand All @@ -421,18 +423,20 @@ public final String prettyPrintAnalysisDataSummary() {
StringBuilder sb = new StringBuilder();
if (getAnalysisCaseNumber() == 1) {
sb.append(String.format("%30s", "Column headers: "));
for (String header : massSpecExtractedData.getColumnHeaders()) {
for (String header : massSpecExtractedData.getUsedColumnHeaders()) {
sb.append(header + ", ");
}
sb.replace(sb.length() - 2, sb.length(), "");
sb.append("\n");
sb.append(String.format("%30s", "Block count: "))
.append(String.format("%-3s", massSpecExtractedData.getBlocksDataLite().size()))
.append(String.format("%-3s", "each with " + massSpecExtractedData.getBlocksDataLite().get(1).cycleData().length) + " cycles");
.append(String.format("%-3s", massSpecExtractedData.getBlocksDataLite().size()));
if (massSpecExtractedData.getBlocksDataLite().size() > 0) {
sb.append(String.format("%-3s", "each with " + massSpecExtractedData.getBlocksDataLite().get(1).cycleData().length) + " cycles");
}
sb.append("\n");
} else {
sb.append(String.format("%30s", "Column headers: "));
for (String header : massSpecExtractedData.getColumnHeaders()) {
for (String header : massSpecExtractedData.getUsedColumnHeaders()) {
sb.append(header + ", ");
}
sb.replace(sb.length() - 2, sb.length(), "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ public static AllBlockInitForMCMC.PlottingData initBlockModels(AnalysisInterface
}
}

return new AllBlockInitForMCMC.PlottingData(
return (countOfBlocks > 0) ? new AllBlockInitForMCMC.PlottingData(
null,
null,
singleBlockRawDataLiteSetRecords,
singleBlockRawDataLiteSetRecords[0].blockRawDataLiteArray().length, true, 1);
singleBlockRawDataLiteSetRecords[0].blockRawDataLiteArray().length, true, 1) : null;
}

private static SingleBlockRawDataLiteSetRecord prepareSingleBlockDataLiteCaseOne(int blockID, MassSpecExtractedData massSpecExtractedData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,12 @@ public int[] assignBlockIdToSessionTimeLite() {
return blockIDs;
}

public void expandCycleDataForUraniumOxideCorrection(int r270_267ColumnIndex, int r265_267ColumnIndex, double r18O_16O) {
for (Integer blockID : blocksDataLite.keySet()) {
blocksDataLite.put(blockID, blocksDataLite.get(blockID).expandForUraniumOxideCorrection(r270_267ColumnIndex, r265_267ColumnIndex, r18O_16O));
}
}

public MassSpectrometerContextEnum getMassSpectrometerContext() {
return massSpectrometerContext;
}
Expand All @@ -214,6 +220,16 @@ public void setColumnHeaders(String[] columnHeaders) {
this.columnHeaders = columnHeaders;
}

public String[] getUsedColumnHeaders() {
List<String> usedColumnHeadersList = new ArrayList<>();
for (String ch : columnHeaders) {
if (ch != null) {
usedColumnHeadersList.add(ch);
}
}
return usedColumnHeadersList.toArray(new String[0]);
}

public DetectorSetup getDetectorSetup() {
return detectorSetup;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,19 @@ public record MassSpecOutputBlockRecordLite(
int blockID,
double[][] cycleData
) implements Serializable {
public MassSpecOutputBlockRecordLite expandForUraniumOxideCorrection(int r270_267ColumnIndex, int r265_267ColumnIndex, double r18O_16O) {
double[][] cycleDataExpand = new double[cycleData.length][];
for (int row = 0; row < cycleData.length; row++) {
cycleDataExpand[row] = new double[cycleData[row].length + 3];
System.arraycopy(cycleData[row], 0, cycleDataExpand[row], 0, cycleData[row].length);

cycleDataExpand[row][cycleData[row].length + 0]
= cycleData[row][r265_267ColumnIndex] / (1.0 - 2.0 * r18O_16O * cycleData[row][r265_267ColumnIndex]);
cycleDataExpand[row][cycleData[row].length + 1]
= cycleData[row][r270_267ColumnIndex] / (1.0 - 2.0 * r18O_16O * cycleData[row][r270_267ColumnIndex]);
cycleDataExpand[row][cycleData[row].length + 2]
= cycleDataExpand[row][cycleData[row].length + 1] / cycleDataExpand[row][cycleData[row].length + 0];
}
return new MassSpecOutputBlockRecordLite(blockID, cycleDataExpand);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import java.util.*;
import java.util.stream.Collectors;

import static java.lang.StrictMath.ceil;

/**
* @author James F. Bowring
*/
Expand Down Expand Up @@ -73,11 +75,29 @@ public static MassSpecExtractedData extractMetaDataAndBlockDataFromIonvantageXLS
}
}

String localDateTimeZero = lines[startCtrlSheet + 21].split("\t")[2];

// String sampleName = lines[startCtrlSheet + 7].split("\t")[3];
String methodName = lines[startCtrlSheet + 11].split("\t")[2];
int cyclesPerBlock = Integer.parseInt(lines[startCtrlSheet + 12].split("\t")[3]);
int blockCount = Integer.parseInt(lines[startCtrlSheet + 13].split("\t")[3]);
String localDateTimeZero = lines[startCtrlSheet + 21].split("\t")[2];

// April 2024 to handle aborted runs, find end of cycles and divide by cyclesperblock
int cyclesStart = startCycleSheet + 16;
int startBlockSheet = 0;
for (int i = startCycleSheet; i < lines.length; i++) {
if (lines[i].trim().compareTo("BLOCK") == 0) {
startBlockSheet = i;
break;
}
}

int lastCycleNumber;
if (lines[startBlockSheet - 2].startsWith("0")) {
lastCycleNumber = 0;
} else {
lastCycleNumber = Integer.parseInt(lines[startBlockSheet - 2].split("\t")[0]);
}
int blockCount = (int) ceil(lastCycleNumber / cyclesPerBlock) + (int) Math.signum(lastCycleNumber % cyclesPerBlock);

MassSpecExtractedData.MassSpecExtractedHeader header = new MassSpecExtractedData.MassSpecExtractedHeader(
"IonVantage",
Expand All @@ -90,12 +110,14 @@ public static MassSpecExtractedData extractMetaDataAndBlockDataFromIonvantageXLS
);
massSpecExtractedData.setHeader(header);

int cyclesStart = startCycleSheet + 16;
List<List<String>> dataByBlocks = new ArrayList<>();
for (int blockID = 1; blockID <= blockCount; blockID++) {

List<String> dataByBlock = new ArrayList<>();
for (int cycleNum = 1; cycleNum <= cyclesPerBlock; cycleNum++) {
dataByBlock.add(lines[cyclesStart + (blockID - 1) * cyclesPerBlock + cycleNum]);
if ((lastCycleNumber % cyclesPerBlock) == 0 || (lastCycleNumber % cyclesPerBlock) > cycleNum) {
dataByBlock.add(lines[cyclesStart + (blockID - 1) * cyclesPerBlock + cycleNum]);
}
}
dataByBlocks.add(dataByBlock);
List<String[]> cycleDataByLineSplit = new ArrayList<>();
Expand Down
Loading

0 comments on commit 9c74781

Please sign in to comment.