Skip to content

Commit c4d8d83

Browse files
authored
Improve WeightedMeans Handling (#710)
* Updated gradle * Fixed issues #706 and #709 * New Version
1 parent ff7081c commit c4d8d83

File tree

11 files changed

+55
-31
lines changed

11 files changed

+55
-31
lines changed

common.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ apply plugin: 'maven-publish'
77

88

99
String mavenGroupId = 'org.cirdles'
10-
String mavenVersion = '1.10.0'
10+
String mavenVersion = '1.10.1'
1111

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

squidApp/src/main/java/org/cirdles/squid/gui/dateInterpretations/plots/plotControllers/PlotsController.java

+10-6
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,8 @@
5959
import static org.cirdles.squid.gui.dateInterpretations.plots.topsoil.TopsoilDataFactory.prepareWetherillDatum;
6060
import static org.cirdles.squid.gui.utilities.stringUtilities.StringTester.stringIsSquidRatio;
6161
import static org.cirdles.squid.tasks.expressions.builtinExpressions.BuiltInExpressionsDataDictionary.*;
62-
import static org.cirdles.squid.utilities.conversionUtilities.RoundingUtilities.squid3RoundedToSize;
63-
import static org.cirdles.topsoil.Variable.X;
64-
import static org.cirdles.topsoil.Variable.Y;
62+
import static org.cirdles.squid.utilities.conversionUtilities.RoundingUtilities.squid3RoundedToSizeForPlottingDisplay;
63+
import static org.cirdles.topsoil.Variable.*;
6564
import static org.cirdles.topsoil.plot.PlotOption.MCLEAN_REGRESSION;
6665
import static org.cirdles.topsoil.plot.PlotOption.SHOW_UNINCLUDED;
6766

@@ -626,10 +625,14 @@ public String toString(TreeItem<SampleTreeNodeInterface> object) {
626625
}
627626
String ageOrValueSource = WeightedMeanPlot.makeAgeString(expressionValues[0][0], uncertainty);
628627

628+
// updated June 2022 issue # 709 to show uncertainties
629629
try {
630630
nodeString += " " + ageOrValueSource
631-
+ " (" + squid3RoundedToSize(((Double) item.getDatum().get(X.getTitle())), 5)
632-
+ ", " + squid3RoundedToSize(((Double) item.getDatum().get(Y.getTitle())), 5) + ")";
631+
+ " (" + squid3RoundedToSizeForPlottingDisplay(((Double) item.getDatum().get(X.getTitle())), 5)
632+
+ " ±" + squid3RoundedToSizeForPlottingDisplay(((Double) item.getDatum().get(SIGMA_X.getTitle())), 5)
633+
+ ", " + squid3RoundedToSizeForPlottingDisplay(((Double) item.getDatum().get(Y.getTitle())), 5)
634+
+ " ±" + squid3RoundedToSizeForPlottingDisplay(((Double) item.getDatum().get(SIGMA_Y.getTitle())), 5)
635+
+ ")";
633636
} catch (Exception e) {
634637
}
635638
}
@@ -844,7 +847,6 @@ public TreeItem<SampleTreeNodeInterface> fromString(String string) {
844847
= new CheckBoxTreeItem<>(fractionNodes.get(i));
845848
rootItemWM.getChildren().add(checkBoxTreeItemWM);
846849

847-
checkBoxTreeItemWM.setSelected(!spotSummaryDetails.getRejectedIndices()[i]);
848850
checkBoxTreeItemWM.selectedProperty().addListener((observable, oldValue, newValue) -> {
849851
checkBoxTreeItemWM.getValue().setSelectedProperty(new SimpleBooleanProperty(newValue));
850852
spotSummaryDetails.setIndexOfRejectedIndices(((WeightedMeanSpotNode) checkBoxTreeItemWM.getValue())
@@ -855,6 +857,8 @@ public TreeItem<SampleTreeNodeInterface> fromString(String string) {
855857
}
856858
refreshPlot();
857859
});
860+
// June 2022 issue #709 moved the next line from before setting listener in order to force update
861+
checkBoxTreeItemWM.setSelected(!spotSummaryDetails.getRejectedIndices()[i]);
858862
}
859863

860864
spotListAnchorPane.getChildren().clear();

squidApp/src/main/java/org/cirdles/squid/gui/dateInterpretations/plots/plotControllers/RefMatWeightedMeanToolBoxNode.java

+16-2
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@
3131
import javafx.scene.shape.Path;
3232
import javafx.scene.shape.Rectangle;
3333
import javafx.scene.text.TextAlignment;
34-
import org.cirdles.squid.gui.dialogs.SquidMessageDialog;
3534
import org.cirdles.squid.exceptions.SquidException;
3635
import org.cirdles.squid.gui.dataViews.SampleNode;
3736
import org.cirdles.squid.gui.dataViews.SampleTreeNodeInterface;
3837
import org.cirdles.squid.gui.dateInterpretations.plots.PlotDisplayInterface;
3938
import org.cirdles.squid.gui.dateInterpretations.plots.squid.PlotRefreshInterface;
4039
import org.cirdles.squid.gui.dateInterpretations.plots.squid.WeightedMeanPlot;
40+
import org.cirdles.squid.gui.dialogs.SquidMessageDialog;
4141
import org.cirdles.squid.shrimp.ShrimpFractionExpressionInterface;
4242
import org.cirdles.squid.squidReports.squidReportCategories.SquidReportCategoryInterface;
4343
import org.cirdles.squid.squidReports.squidReportColumns.SquidReportColumnInterface;
@@ -323,6 +323,7 @@ public void changed(ObservableValue<? extends SquidReportCategoryInterface> obse
323323
@Override
324324
public void changed(ObservableValue<? extends SquidReportColumnInterface> observable, SquidReportColumnInterface oldValue, SquidReportColumnInterface newValue) {
325325
if (newValue != null) {
326+
PlotsController.spotsTreeViewCheckBox.setRoot(sampleItem);
326327
String selectedExpression = newValue.getExpressionName();
327328
if (categoryComboBox.getSelectionModel().getSelectedItem().getDisplayName().compareToIgnoreCase("AGES") == 0) {
328329
try {
@@ -337,9 +338,12 @@ public void changed(ObservableValue<? extends SquidReportColumnInterface> observ
337338
PlotDisplayInterface myPlot = sampleNode.getSamplePlotWM();
338339
((WeightedMeanPlot) myPlot).setSpotSummaryDetails(spotSummaryDetailsWM);
339340
((WeightedMeanPlot) myPlot).setAgeOrValueLookupString(selectedExpression);
341+
refreshSampleCheckboxSelectionStatus(spotSummaryDetailsWM);
340342
sortFractionCheckboxesByValue(spotSummaryDetailsWM);
341343
PlotsController.plot = myPlot;
342344
} catch (SquidException squidException) {
345+
PlotsController.plot = null;
346+
PlotsController.spotsTreeViewCheckBox.setRoot(null);
343347
}
344348

345349
} else {
@@ -355,12 +359,13 @@ public void changed(ObservableValue<? extends SquidReportColumnInterface> observ
355359
WeightedMeanPlot.switchRefMatViewToCalibConst = false;
356360
PlotDisplayInterface myPlot = new WeightedMeanPlot(
357361
new Rectangle(1000, 600),
358-
" Sample " + sampleNode.getNodeName(),
362+
" Reference Material " + sampleNode.getNodeName(),
359363
spotSummaryDetailsWM,
360364
selectedExpression,
361365
0.0,
362366
plotsController);
363367

368+
refreshSampleCheckboxSelectionStatus(spotSummaryDetailsWM);
364369
sortFractionCheckboxesByValue(spotSummaryDetailsWM);
365370
PlotsController.plot = myPlot;
366371
sampleNode.setSamplePlotWM(myPlot);
@@ -370,6 +375,7 @@ public void changed(ObservableValue<? extends SquidReportColumnInterface> observ
370375
if (sampleNode != null) {
371376
String selectedSortExpression = expressionSortComboBox.getSelectionModel().getSelectedItem().getExpressionName();
372377
sampleNode.getSpotSummaryDetailsWM().setSelectedExpressionName(selectedSortExpression);
378+
refreshSampleCheckboxSelectionStatus(sampleNode.getSpotSummaryDetailsWM());
373379
sortFractionCheckboxesByValue(sampleNode.getSpotSummaryDetailsWM());
374380
plotsController.refreshPlot();
375381
}
@@ -452,6 +458,7 @@ public void changed(ObservableValue<? extends SquidReportColumnInterface> observ
452458
String selectedExpression = newValue.getExpressionName();
453459
sampleNode.getSpotSummaryDetailsWM().setSelectedExpressionName(
454460
selectedExpression);
461+
refreshSampleCheckboxSelectionStatus(sampleNode.getSpotSummaryDetailsWM());
455462
sortFractionCheckboxesByValue(sampleNode.getSpotSummaryDetailsWM());
456463
plotsController.refreshPlot();
457464
}
@@ -732,4 +739,11 @@ private void sortFractionCheckboxesByValue(SpotSummaryDetails spotSummaryDetails
732739
return Double.compare(valueFromNode1, valueFromNode2);
733740
});
734741
}
742+
743+
private void refreshSampleCheckboxSelectionStatus(SpotSummaryDetails spotSummaryDetails){
744+
for (int i = 0; i < sampleItem.getChildren().size(); i++) {
745+
((CheckBoxTreeItem<SampleTreeNodeInterface>)sampleItem.getChildren().get(i)).setSelected(!spotSummaryDetails
746+
.getRejectedIndices()[i]);
747+
}
748+
}
735749
}

squidApp/src/main/java/org/cirdles/squid/gui/dateInterpretations/plots/plotControllers/SamplesWeightedMeanToolBoxNode.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ public void changed(ObservableValue<? extends SquidReportColumnInterface> observ
372372
.evaluateSelectedExpressionWeightedMeanForUnknownGroup(
373373
selectedExpression, sampleNode.getNodeName(), sampleNode.getSpotSummaryDetailsWM().getSelectedSpots());
374374
spotSummaryDetailsWM.setManualRejectionEnabled(true);
375-
// spotSummaryDetailsWM.setMinProbabilityWM(probabilitySlider.getValue());
375+
376376
if (filterInfoCheckBox.isSelected()) {
377377
spotSummaryDetailsWM.setRejectedIndices(((WeightedMeanPlot) sampleNode.getSamplePlotWM()).getRejectedIndices());
378378
}

squidApp/src/main/java/org/cirdles/squid/gui/expressions/ExpressionBuilderController.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,9 @@ private void initListViews() {
688688
customExpressionsListView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
689689
if (newValue != null) {
690690
if (currentMode.get().equals(Mode.VIEW)) {
691-
selectedExpressionIsEditable.set(!SampleAgeTypesEnum.isReservedName(newValue.getName()));
691+
selectedExpressionIsEditable.set(!(SampleAgeTypesEnum.isReservedName(newValue.getName())
692+
||
693+
(newValue.getName().contains("_WM"))));
692694
selectedExpressionIsBuiltIn.set(false);
693695
selectedExpression.set(newValue);
694696

squidCore/src/main/java/org/cirdles/squid/tasks/Task.java

+10-7
Original file line numberDiff line numberDiff line change
@@ -2112,10 +2112,14 @@ public void evaluateUnknownsWithChangedParameters(List<ShrimpFractionExpressionI
21122112
= namedExpressionsMap.get(spot.getSelectedAgeExpressionName());
21132113
// run SK 3 times per Ludwig
21142114
for (int i = 0; i < 3; i++) {
2115-
spot.getCommonLeadSpecsForSpot().updateCommonLeadRatiosFromSK(
2116-
spot.getTaskExpressionsEvaluationsPerSpot().get(selectedAgeExpression)[0][0]);
2117-
// update
2118-
evaluateExpressionsForSampleSpot(spot);
2115+
try {
2116+
spot.getCommonLeadSpecsForSpot().updateCommonLeadRatiosFromSK(
2117+
spot.getTaskExpressionsEvaluationsPerSpot().get(selectedAgeExpression)[0][0]);
2118+
// update
2119+
evaluateExpressionsForSampleSpot(spot);
2120+
} catch (Exception e) {
2121+
throw new SquidException("");
2122+
}
21192123
}
21202124
break;
21212125
case METHOD_COMMON_LEAD_MODEL:
@@ -2163,11 +2167,10 @@ public SpotSummaryDetails evaluateSelectedExpressionWeightedMeanForUnknownGroup(
21632167

21642168
private Expression constructCustomWMExpression(String expressionName, String sampleName) {
21652169
// calculate weighted mean of selected expressionName without auto-rejection
2166-
boolean isRefMat = expressionName.contains("_RM");
2170+
boolean isRefMat = expressionName.contains("_RM") || filterForRefMatSpotNames.compareToIgnoreCase(sampleName) == 0;
21672171
Expression expressionWM = buildExpression(expressionName + "_WM_" + sampleName,
21682172
"WtdAv([\"" + expressionName + "\"])", isRefMat, !isRefMat, true);
2169-
// "WtdMeanACalc([\"" + expressionName + "\"],[%\"" + expressionName + "\"],TRUE,FALSE)", false, true, true);
2170-
expressionWM.setNotes("Expression generated from the Samples Weighted Mean screen under Interpretations.");
2173+
expressionWM.setNotes("Expression generated from the " + (isRefMat ? "RM" : "Samples") + " Weighted Mean screen under Interpretations.");
21712174

21722175
expressionWM.getExpressionTree().setUnknownsGroupSampleName(sampleName);
21732176
expressionWM.getExpressionTree().setSquidSpecialUPbThExpression(false);

squidCore/src/main/java/org/cirdles/squid/tasks/TaskInterface.java

+9-5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
import java.io.File;
3535
import java.util.List;
36+
import java.util.Locale;
3637
import java.util.Map;
3738
import java.util.TreeMap;
3839

@@ -770,11 +771,14 @@ public default boolean isPbU() {
770771
public default boolean expressionTreeIsCandidateForSwitchNU(String excelExpression) {
771772
boolean retVal = false;
772773

773-
for (String ratioName : getRatioNames()) {
774-
if (excelExpression.contains(ratioName)) {
775-
// check to make sure excelExpression is not just a ratio
776-
retVal = (excelExpression.trim().compareTo("[\"" + ratioName + "\"]") != 0);
777-
break;
774+
// june 2022 added WM condition
775+
if (!excelExpression.toUpperCase(Locale.ROOT).contains("WTDAV")) {
776+
for (String ratioName : getRatioNames()) {
777+
if (excelExpression.contains(ratioName)) {
778+
// check to make sure excelExpression is not just a ratio
779+
retVal = (excelExpression.trim().compareTo("[\"" + ratioName + "\"]") != 0);
780+
break;
781+
}
778782
}
779783
}
780784

squidCore/src/main/java/org/cirdles/squid/tasks/expressions/spots/SpotSummaryDetails.java

+1-8
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,6 @@ public void rejectNone() {
139139
rejectedIndices = new boolean[selectedSpots.size()];
140140
}
141141

142-
public void rejectAll() {
143-
rejectedIndices = new boolean[selectedSpots.size()];
144-
for (int i = 0; i < rejectedIndices.length; i++) {
145-
rejectedIndices[i] = true;
146-
}
147-
}
148-
149142
public boolean[] getRejectedIndices() {
150143
return this.rejectedIndices.clone();
151144
}
@@ -206,4 +199,4 @@ public int hashCode() {
206199
result = 31 * result + Arrays.hashCode(getRejectedIndices());
207200
return result;
208201
}
209-
}
202+
}

squidCore/src/main/java/org/cirdles/squid/utilities/conversionUtilities/RoundingUtilities.java

+4
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,8 @@ public static double squid3RoundedToSize(double value, int sigFigs) {
2626
// return org.cirdles.ludwig.squid25.Utilities.roundedToSize(value, USE_SIG_FIG_15 ? 15 : sigFigs);
2727
return org.cirdles.ludwig.squid25.Utilities.roundedToSize(value, 15);
2828
}
29+
30+
public static double squid3RoundedToSizeForPlottingDisplay(double value, int sigFigs) {
31+
return org.cirdles.ludwig.squid25.Utilities.roundedToSize(value, sigFigs);
32+
}
2933
}
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)