Skip to content

Commit

Permalink
Merge pull request #777 from bowring/fixswap
Browse files Browse the repository at this point in the history
Fixed #776
  • Loading branch information
bowring authored Jun 21, 2024
2 parents 9859ef0 + 13aa2d8 commit 1f8ba34
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 41 deletions.
2 changes: 1 addition & 1 deletion common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ apply plugin: 'maven-publish'


String mavenGroupId = 'org.cirdles'
String mavenVersion = '2.0.8'
String mavenVersion = '2.0.9'

[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ public void initialize(URL url, ResourceBundle rb) {
}

private void init() throws SquidException {
if (squidProject.getTask().getOvercountCorrectionType().equals(Squid3Constants.OvercountCorrectionTypes.FR_Custom))
{
OvercountCorrection.correctionCustom(squidProject.getTask());
}
// update
try {
squidProject.getTask().setupSquidSessionSpecsAndReduceAndReport(false);
Expand Down Expand Up @@ -161,10 +165,13 @@ private void init() throws SquidException {
mapOfWeightedMeansBySampleNames.put(entry.getKey(), spotSummaryDetails);
}

// showUnknownsWithOvercountCorrections();
ExpressionTreeInterface customExpression = squidProject.getTask().getNamedExpressionsMap().get(SWAP_CUSTOM_CORRECTION_204);
if ((customExpression == null) || !customExpression.isValueModel()){
customSWAPRB.setDisable(true);
squidProject.getTask().setOvercountCorrectionType(Squid3Constants.OvercountCorrectionTypes.NONE);
correctionNoneRB.setSelected(true);
}

ExpressionTreeInterface customExpression = squidProject.getTask().getNamedExpressionsMap().get("SWAPCustomCorrection204");
customSWAPRB.setDisable((customExpression == null) || !customExpression.isValueModel());
switch (squidProject.getTask().getOvercountCorrectionType()) {
case NONE:
correctionNoneRB.setSelected(true);
Expand All @@ -177,7 +184,6 @@ private void init() throws SquidException {
break;
case FR_Custom:
customSWAPRB.setSelected(true);
OvercountCorrection.correctionCustom(squidProject.getTask());
}

showUnknownsWithOvercountCorrections();
Expand Down Expand Up @@ -228,7 +234,7 @@ public void setUpHeader() {

biweight208Label.setText("biWgt 204 ovrCnts: " + formatter);

customSWAPLabel.setText("SWAPCustomCorrection204");
customSWAPLabel.setText(SWAP_CUSTOM_CORRECTION_204);

viewDetailsButton.setStyle("-fx-font-size: 12px;-fx-font-weight: bold; -fx-padding: 0 0 0 0;");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@
import static org.cirdles.squid.gui.SquidUI.PIXEL_OFFSET_FOR_MENU;
import static org.cirdles.squid.gui.SquidUI.primaryStageWindow;
import static org.cirdles.squid.gui.SquidUIController.squidProject;
import static org.cirdles.squid.tasks.expressions.builtinExpressions.BuiltInExpressionsDataDictionary.BIWT_204_OVR_CTS_FROM_207;
import static org.cirdles.squid.tasks.expressions.builtinExpressions.BuiltInExpressionsDataDictionary.BIWT_204_OVR_CTS_FROM_208;
import static org.cirdles.squid.tasks.expressions.builtinExpressions.BuiltInExpressionsDataDictionary.*;

/**
* FXML Controller class
Expand Down Expand Up @@ -84,6 +83,13 @@ public class CountCorrectionsController implements Initializable {
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
if (squidProject.getTask().getOvercountCorrectionType().equals(Squid3Constants.OvercountCorrectionTypes.FR_Custom)) {
try {
OvercountCorrection.correctionCustom(squidProject.getTask());
} catch (SquidException e) {
// throw new RuntimeException(e);
}
}
// update
try {
squidProject.getTask().setupSquidSessionSpecsAndReduceAndReport(false);
Expand All @@ -95,8 +101,12 @@ public void initialize(URL url, ResourceBundle rb) {
spotsTreeViewTextFlow.prefHeightProperty().bind(primaryStageWindow.getScene().heightProperty()
.subtract(PIXEL_OFFSET_FOR_MENU + headerHBox.getPrefHeight()));

ExpressionTreeInterface customExpression = squidProject.getTask().getNamedExpressionsMap().get("SWAPCustomCorrection204");
customSWAPRB.setDisable((customExpression == null) || !customExpression.isValueModel());
ExpressionTreeInterface customExpression = squidProject.getTask().getNamedExpressionsMap().get(SWAP_CUSTOM_CORRECTION_204);
if ((customExpression == null) || !customExpression.isValueModel()) {
customSWAPRB.setDisable(true);
squidProject.getTask().setOvercountCorrectionType(Squid3Constants.OvercountCorrectionTypes.NONE);
}

switch (squidProject.getTask().getOvercountCorrectionType()) {
case NONE:
correctionNoneRB.setSelected(true);
Expand All @@ -109,11 +119,6 @@ public void initialize(URL url, ResourceBundle rb) {
break;
case FR_Custom:
customSWAPRB.setSelected(true);
try {
OvercountCorrection.correctionCustom(squidProject.getTask());
} catch (SquidException e) {
// throw new RuntimeException(e);
}
}

setUpHeader();
Expand Down Expand Up @@ -181,10 +186,10 @@ private void showUnknownsWithOvercountCorrections() {
double[][] r204_206_208 = spot.getTaskExpressionsEvaluationsPerSpot()
.get(squidProject.getTask().getNamedExpressionsMap().get("SWAPCountCorrectionExpression204From208"));
double[][] custom204 = new double[r204_206_208.length][r204_206_208[0].length];
ExpressionTreeInterface customExp = squidProject.getTask().getNamedExpressionsMap().get("SWAPCustomCorrection204");
ExpressionTreeInterface customExp = squidProject.getTask().getNamedExpressionsMap().get(SWAP_CUSTOM_CORRECTION_204);
if ((null != customExp) && customExp.isValueModel()) {
custom204 = spot.getTaskExpressionsEvaluationsPerSpot()
.get(squidProject.getTask().getNamedExpressionsMap().get("SWAPCustomCorrection204"));
.get(squidProject.getTask().getNamedExpressionsMap().get(SWAP_CUSTOM_CORRECTION_204));
}

TextFlow textFlowI = new TextFlow();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<AnchorPane xmlns:fx="http://javafx.com/fxml/1" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="600.0" minWidth="900.0"
<AnchorPane xmlns:fx="http://javafx.com/fxml/1" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="600.0"
minWidth="900.0"
prefHeight="600.0" prefWidth="900.0" stylesheets="@../css/squidLabData.css"
xmlns="http://javafx.com/javafx/17"
fx:controller="org.cirdles.squid.gui.parameters.ParametersManagerGUIController">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.math.RoundingMode;
import java.util.*;

import static org.cirdles.squid.tasks.expressions.builtinExpressions.BuiltInExpressionsDataDictionary.SWAP_CUSTOM_CORRECTION_204;
import static org.cirdles.squid.utilities.conversionUtilities.CloningUtilities.clone2dArray;

/**
Expand Down Expand Up @@ -1001,7 +1002,7 @@ public String getOverCtCorr() {
retVal.append("Corrected from 208");
break;
case CUSTOM:
retVal.append("SWAPCustomCorrection204");
retVal.append(SWAP_CUSTOM_CORRECTION_204);
break;
}
return retVal.toString();
Expand Down
10 changes: 7 additions & 3 deletions squidCore/src/main/java/org/cirdles/squid/tasks/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,9 @@ public void updateTaskFromTaskDesign(TaskDesign taskDesign, boolean taskSkeleton
String targetSampleName = customExp.getName().split("_WM_")[1].trim();
customExp.getExpressionTree().setUnknownsGroupSampleName(targetSampleName);
}
if (taskExpressionsOrdered.contains(customExp)) {
taskExpressionsOrdered.remove(customExp);
}
taskExpressionsOrdered.add(customExp);
}

Expand Down Expand Up @@ -668,9 +671,10 @@ public void generateBuiltInExpressions() {

SortedSet<Expression> overCountExpressionsOrdered = generateOverCountExpressions(isDirectAltPD());
taskExpressionsOrdered.addAll(overCountExpressionsOrdered);
if (!namedExpressionsMap.containsKey("SWAPCustomCorrection204")) {
if (!namedExpressionsMap.containsKey(SWAP_CUSTOM_CORRECTION_204)) {
Expression customExp = buildCountCorrectionCustomExpression();
namedExpressionsMap.put("SWAPCustomCorrection204", customExp.getExpressionTree());
namedExpressionsMap.put(SWAP_CUSTOM_CORRECTION_204, customExp.getExpressionTree());
taskExpressionsOrdered.remove(customExp);
taskExpressionsOrdered.add(customExp);
}

Expand Down Expand Up @@ -1080,7 +1084,7 @@ public void updateAllUnknownSpotsWithOverCountCorrectedBy204_206_208() {
}

public void updateAllUnknownSpotsWithCustomCorrection() {
ExpressionTreeInterface customExp = namedExpressionsMap.get("SWAPCustomCorrection204");
ExpressionTreeInterface customExp = namedExpressionsMap.get(SWAP_CUSTOM_CORRECTION_204);
if ((null != customExp) && customExp.isValueModel()) {
for (ShrimpFractionExpressionInterface spot : unknownSpots) {
SquidRatiosModel ratio204_206 = ((ShrimpFraction) spot).getRatioByName("204/206");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

import static org.cirdles.squid.constants.Squid3Constants.TaskTypeEnum.GEOCHRON;
import static org.cirdles.squid.tasks.expressions.builtinExpressions.BuiltInExpressionsDataDictionary.*;
import static org.cirdles.squid.tasks.expressions.builtinExpressions.BuiltinExpressionsCountCorrection204.*;
import static org.cirdles.squid.tasks.expressions.builtinExpressions.BuiltinExpressionsCountCorrection204.buildCountCorrectionCustomExpression;

/**
* @author James F. Bowring
Expand Down Expand Up @@ -415,10 +415,6 @@ default void applyDirectives(boolean customizeTaskExpressions) throws SquidExcep
}

List<Expression> customExpressions = getCustomTaskExpressions();
// special temporary case Sep 2019
customExpressions.remove(buildCountCorrectionExpressionFrom207());
customExpressions.remove(buildCountCorrectionExpressionFrom208());
customExpressions.remove(buildCountCorrectionCustomExpression());

getTaskExpressionsOrdered().clear();

Expand Down Expand Up @@ -497,6 +493,14 @@ default void applyDirectives(boolean customizeTaskExpressions) throws SquidExcep
getTaskExpressionsOrdered().add(parentPPM);
}


Expression defaultCustomExp = buildCountCorrectionCustomExpression();
if (customExpressions.contains(defaultCustomExp)) {
Expression customExp = customExpressions.get(customExpressions.indexOf(defaultCustomExp));
getNamedExpressionsMap().put(SWAP_CUSTOM_CORRECTION_204, customExp.getExpressionTree());
getTaskExpressionsOrdered().remove(defaultCustomExp);
}

getTaskExpressionsOrdered().addAll(customExpressions);

setChanged(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

import static org.cirdles.squid.constants.Squid3Constants.*;
import static org.cirdles.squid.constants.Squid3Constants.SpotTypes.UNKNOWN;
import static org.cirdles.squid.tasks.expressions.builtinExpressions.BuiltInExpressionsDataDictionary.SWAP_CUSTOM_CORRECTION_204;
import static org.cirdles.squid.tasks.expressions.functions.Function.replaceAliasedFunctionNamesInExpressionString;

/**
Expand Down Expand Up @@ -350,6 +351,9 @@ public String getNotes() {
if (this.expressionTree.isSquidSpecialUPbThExpression()) {
notes = BuiltInExpressionsNotes.BUILTIN_EXPRESSION_NOTES.get(name);
}
if (this.expressionTree.getName().compareToIgnoreCase(SWAP_CUSTOM_CORRECTION_204) == 0) {
notes = BuiltInExpressionsNotes.BUILTIN_EXPRESSION_NOTES.get(SWAP_CUSTOM_CORRECTION_204);
}
if (this.isParameterValue()
|| this.isReferenceMaterialValue()) {
notes = "from Model: " + sourceModelNameAndVersion + "\n\n" + BuiltInExpressionsNotes.BUILTIN_EXPRESSION_NOTES.get(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ public class BuiltInExpressionsDataDictionary {
public static final String RAD_206PB204PB_FACTOR = "Rad_206Pb204Pb_Factor";
public static final String RAD_208PB204PB_FACTOR = "Rad_208Pb204Pb_Factor";
public static final List<String> COMPOSITION_EXPRESSION_NAMES = new ArrayList<>();
// ************************ CUSTOM SWAPPING *********************
public static final String SWAP_CUSTOM_CORRECTION_204 = "SWAPCustomCorrection204";
// ************************ MISC CONSTANTS *********************
private static final String R206_238CALIB_CONST = CALIB_CONST_206_238_ROOT + "_CalibConst";
public static final String PB4COR206_238CALIB_CONST = PB4CORR + R206_238CALIB_CONST;
public static final String PB4COR206_238CALIB_CONST_WM = WTDAV_PREFIX + PB4COR206_238CALIB_CONST;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,5 +546,14 @@ public class BuiltInExpressionsNotes {
+ " (i.e. the third element of the WtdAv vector output) calculated from "
+ "any RM dataset of WtdAv_Xcor_208Pb232Th_CalibConst values. In this context, "
+ "Xcor denotes the index isotope used for the common Pb correction in the RM (i.e. 204Pb or 207Pb).");

BUILTIN_EXPRESSION_NOTES.put(SWAP_CUSTOM_CORRECTION_204,
"Edit this expression to calculate a custom corrected value "
+ "for 204/206 as per Squid2.5 'column swapping' and invoke it from the Common Pb menu "
+ "window for overcounts of 204. \n\n"
+ "REQUIRED: Use the expression name '" + SWAP_CUSTOM_CORRECTION_204 + "' and define a ValueModel. \n"
+ "The default definition is: 'ValueModel(Orig([\"204/206\"]),Orig([±\"204/206\"]),true)'. \n\n"
+ " NOTE: Use the 'Orig' function to retrieve the unmutable value of a ratio. Otherwise, "
+ "a circular logic obtains.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@

import org.cirdles.squid.tasks.expressions.Expression;

import static org.cirdles.squid.tasks.expressions.builtinExpressions.BuiltInExpressionsDataDictionary.BIWT_204_OVR_CTS_FROM_207;
import static org.cirdles.squid.tasks.expressions.builtinExpressions.BuiltInExpressionsDataDictionary.BIWT_204_OVR_CTS_FROM_208;
import static org.cirdles.squid.tasks.expressions.builtinExpressions.BuiltInExpressionsDataDictionary.*;
import static org.cirdles.squid.tasks.expressions.builtinExpressions.BuiltInExpressionsFactory.buildExpression;

/**
Expand All @@ -28,7 +27,7 @@ public class BuiltinExpressionsCountCorrection204 {

/**
* @return
* @see https://github.com/CIRDLES/ET_Redux/wiki/SQ2.50-Procedural-Framework:-Part-7a-(204-overcounts)
* @see <a href="https://github.com/CIRDLES/ET_Redux/wiki/SQ2.50-Procedural-Framework:-Part-7a-(204-overcounts)">...</a>
*/
public static Expression buildCountCorrectionExpressionFrom207() {

Expand Down Expand Up @@ -67,7 +66,7 @@ public static Expression buildCountCorrectionExpressionFrom207() {

/**
* @return
* @see https://github.com/CIRDLES/ET_Redux/wiki/SQ2.50-Procedural-Framework:-Part-7a-(204-overcounts)
* @see <a href="https://github.com/CIRDLES/ET_Redux/wiki/SQ2.50-Procedural-Framework:-Part-7a-(204-overcounts)">...</a>
*/
public static Expression buildCountCorrectionExpressionFrom208() {

Expand Down Expand Up @@ -107,18 +106,10 @@ public static Expression buildCountCorrectionExpressionFrom208() {
public static Expression buildCountCorrectionCustomExpression() {

Expression countCorrectionCustom = buildExpression(
"SWAPCustomCorrection204",
SWAP_CUSTOM_CORRECTION_204,
"ValueModel(Orig([\"204/206\"]),Orig([±\"204/206\"]),true)", false, true, false);

countCorrectionCustom.getExpressionTree().setSquidSpecialUPbThExpression(true);
countCorrectionCustom.setNotes(
"Edit this expression to calculate a custom corrected value "
+ "for 204/206 as per Squid2.5 'column swapping' and invoke it from the Common Pb menu "
+ "window for overcounts of 204. \n\n"
+ "REQUIRED: Use the expression name 'SWAPCustomCorrection204' and define a ValueModel. \n"
+ "The default definition is: 'ValueModel(Orig([\"204/206\"]),Orig([±\"204/206\"]),true)'. \n\n"
+ " NOTE: Use the 'Orig' function to retrieve the unmutable value of a ratio. Otherwise, "
+ "a circular logic obtains.");
countCorrectionCustom.getExpressionTree().setSquidSpecialUPbThExpression(false);

return countCorrectionCustom;
}
Expand Down
Binary file not shown.

0 comments on commit 1f8ba34

Please sign in to comment.