diff --git a/src/PamUtils/TxtFileUtils.java b/src/PamUtils/TxtFileUtils.java index f2190a38..58d8c72b 100644 --- a/src/PamUtils/TxtFileUtils.java +++ b/src/PamUtils/TxtFileUtils.java @@ -6,6 +6,7 @@ import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; +import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.ArrayList; import java.util.Collection; @@ -62,7 +63,7 @@ public class TxtFileUtils { boolean isNaN=false; for (String line : lines) { - System.out.println(line); + //System.out.println(line); String[] recordsOnLine = line.split(delimeter); @@ -82,11 +83,15 @@ public class TxtFileUtils { // //This was causing isses with some numbers with e-06...dunno why so switched to parse double // String input = new String(recordsOnLine[i].toCharArray()); -// //System.out.println(input); +// System.out.println("|" + recordsOnLine[i] + "|"); // dat = nF.parse(input).doubleValue(); - - dat = Double.parseDouble(recordsOnLine[i]); + //5/08/2022 - there was a bug here where there is some sort of invisible character that does not appear on the + //print screen - the only way you can tell is the char array is greater than the number of digits - removed all non numeric + //characters. + String number = new String(recordsOnLine[i].strip().replaceAll("[^\\d.]", "")); + dat = Double.valueOf(number); + //dat = DecimalFormat.getNumberInstance().parse(new String(recordsOnLine[i].strip().toCharArray())).doubleValue(); } catch (Exception e){ e.printStackTrace(); diff --git a/src/clickTrainDetector/IDIInfo.java b/src/clickTrainDetector/IDIInfo.java index fa050111..da59ebd2 100644 --- a/src/clickTrainDetector/IDIInfo.java +++ b/src/clickTrainDetector/IDIInfo.java @@ -5,6 +5,7 @@ import java.util.List; import PamUtils.PamArrayUtils; import PamguardMVC.PamDataUnit; +import PamguardMVC.debug.Debug; /** * Holds some basic IDI info on the click train. @@ -47,7 +48,7 @@ public class IDIInfo { lastNumber = dataUnits.size(); if (dataUnits.size()<3) { - System.out.println("CTDataUnit: Cannot calculate IDIInfo for less than three data units"); + Debug.out.println("CTDataUnit: Cannot calculate IDIInfo for less than three data units"); return; } diff --git a/src/clickTrainDetector/classification/SimpleCTClassification.java b/src/clickTrainDetector/classification/SimpleCTClassification.java index 4a079670..ba7db1d8 100644 --- a/src/clickTrainDetector/classification/SimpleCTClassification.java +++ b/src/clickTrainDetector/classification/SimpleCTClassification.java @@ -31,7 +31,6 @@ public class SimpleCTClassification implements CTClassification { @Override public String getSummaryString() { - // TODO Auto-generated method stub return "SimpleClssf: SpeciesID: " + speciesID + " ClassifierType: " + classifierType; } diff --git a/src/clickTrainDetector/classification/bearingClassifier/BearingClassifier.java b/src/clickTrainDetector/classification/bearingClassifier/BearingClassifier.java index 615581b9..0507f367 100644 --- a/src/clickTrainDetector/classification/bearingClassifier/BearingClassifier.java +++ b/src/clickTrainDetector/classification/bearingClassifier/BearingClassifier.java @@ -1,8 +1,8 @@ package clickTrainDetector.classification.bearingClassifier; -import org.renjin.gcc.runtime.Debug; import PamUtils.PamArrayUtils; +import PamguardMVC.debug.Debug; import clickTrainDetector.CTDataUnit; import clickTrainDetector.ClickTrainControl; import clickTrainDetector.classification.CTClassification; @@ -95,7 +95,7 @@ public class BearingClassifier implements CTClassifier { if (nullcount>clickTrain.getSubDetectionsCount()-4) { //less than three data units with loc results - Debug.println("The bearing classifier has a null count: "); + Debug.out.println("The bearing classifier has a null count: "); return new BearingClassification(CTClassifier.NOSPECIES, Double.NaN, Double.NaN, Double.NaN); } @@ -111,7 +111,7 @@ public class BearingClassifier implements CTClassifier { double medianBearingD = PamArrayUtils.median(bearingDiff); double stdBearingD = PamArrayUtils.std(bearingDiff); - Debug.println("Bearing classifier: No. Detections: " + clickTrain.getSubDetectionsCount() + " medianBearing: " + medianBearingD); + Debug.out.println("Bearing classifier: No. Detections: " + clickTrain.getSubDetectionsCount() + " medianBearing: " + medianBearingD); int speciesID = CTClassifier.NOSPECIES; boolean passed= true; @@ -120,31 +120,31 @@ public class BearingClassifier implements CTClassifier { //is the minimum and maximum bearing in range... if ((min>=bearingClssfrParams.bearingLimMin && min<=bearingClssfrParams.bearingLimMax) || (max>=bearingClssfrParams.bearingLimMin && max<=bearingClssfrParams.bearingLimMax)) { - Debug.println("Passed on min max bearing"); + Debug.out.println("Passed on min max bearing"); } else passed =false; //mean bearing derivative if (bearingClssfrParams.useMean && meanBearingD>=bearingClssfrParams.minMeanBearingD && meanBearingD<=bearingClssfrParams.maxMeanBearingD) { - Debug.println("Passed on mean bearing"); + Debug.out.println("Passed on mean bearing"); } else if (bearingClssfrParams.useMean) passed=false; //median bearing derivative - Debug.println("Median Bearing: " + Math.toDegrees(medianBearingD) + + Debug.out.println("Median Bearing: " + Math.toDegrees(medianBearingD) + " minlim: " + Math.toDegrees(bearingClssfrParams.minMedianBearingD)+ " maxlim: " + Math.toDegrees(bearingClssfrParams.maxMedianBearingD)); if (bearingClssfrParams.useMedian && medianBearingD>=bearingClssfrParams.minMedianBearingD && medianBearingD<=bearingClssfrParams.maxMedianBearingD) { - Debug.println("Passed on median bearing"); + Debug.out.println("Passed on median bearing"); } else if (bearingClssfrParams.useMedian) passed = false; //standard deviation derivative if (bearingClssfrParams.useStD && stdBearingD>=bearingClssfrParams.minStdBearingD && stdBearingD<=bearingClssfrParams.maxStdBearingD) { - Debug.println("Passed on std bearing"); + Debug.out.println("Passed on std bearing"); } else if (bearingClssfrParams.useStD) passed= false; @@ -152,7 +152,7 @@ public class BearingClassifier implements CTClassifier { speciesID = this.bearingClssfrParams.speciesFlag; } - Debug.println("SPECIESID!! " + speciesID); + Debug.out.println("SPECIESID!! " + speciesID); return new BearingClassification(speciesID, meanBearingD, medianBearingD, stdBearingD); diff --git a/src/clickTrainDetector/clickTrainAlgorithms/mht/MHTGarbageBot.java b/src/clickTrainDetector/clickTrainAlgorithms/mht/MHTGarbageBot.java index 483b43a4..7758997f 100644 --- a/src/clickTrainDetector/clickTrainAlgorithms/mht/MHTGarbageBot.java +++ b/src/clickTrainDetector/clickTrainAlgorithms/mht/MHTGarbageBot.java @@ -70,11 +70,13 @@ public class MHTGarbageBot { double maxICI = mhtKernel.getMHTParams().maxCoast * mhtKernel.getMHTChi2Provider().getChi2Params().maxICI; //check the current set of click train possible ICI's - + + //Debug.out.println("MHTGARBAGEBOT: maxICI " + maxICI + " " + iciPrev); + //we have reached the hard limit. Save click trains, wipe the detector and start again. if (mhtKernel.getKCount()>mhtKernel.getMHTParams().nPruneBackStart && (iciPrev>maxICI || mhtKernel.getKCount()>DETECTION_HARD_LIMIT)) { -// Debug.out.println("MHTGarbageBot: KERNEL HARD LIMIT"); + //Debug.out.println("MHTGARBAGEBOT: KERNEL HARD LIMIT"); //check whether the next click has a gap so big that all click trains should be restarted //grab tracks mhtKernel.confirmRemainingTracks(); diff --git a/src/clickTrainDetector/clickTrainAlgorithms/mht/MHTKernel.java b/src/clickTrainDetector/clickTrainAlgorithms/mht/MHTKernel.java index 03a90f75..fe4a5ab9 100644 --- a/src/clickTrainDetector/clickTrainAlgorithms/mht/MHTKernel.java +++ b/src/clickTrainDetector/clickTrainAlgorithms/mht/MHTKernel.java @@ -158,10 +158,10 @@ public class MHTKernel { if (verbosity>0) { Debug.out.println("Possiblity matrix size is " + possibleTracks.size() + " x " + kcount ); } - // for (int i=0; i { testBranch = newPossibleTracks.get(j); testBitSet=testBranch.trackBitSet.get(0, kcount-(pruneback)); + //now test whether the current and test branch are the same. if (testBitSet.equals(currentBitSet)) { indexConfirm[j]=true; @@ -423,6 +424,7 @@ public class MHTKernel { indexRemove[j]=true; } } + } //long time2a=System.currentTimeMillis(); @@ -437,9 +439,11 @@ public class MHTKernel { if (nCoasts>=this.mHTParams.maxCoast || confirmAll || currentBranch.flag==TrackBitSet.JUNK_TRACK) { //the branch needs to be confirmed. - // System.out.println(i + " DONE: "+ String.format("%.3f ", possibleTracks.get(i).chi2Track.getChi2())+ - // " " + String.format("%d ", possibleTracks.get(i).chi2Track.getNCoasts()) - // + MHTKernel.bitSetString(possibleTracks.get(i).trackBitSet, kcount)); +// System.out.println(i + " DONE: " + (nCoasts >= this.mHTParams.maxCoast) + " " + confirmAll + " " +// + (currentBranch.flag == TrackBitSet.JUNK_TRACK) + " " +// + String.format("%.3f ", currentBranch.chi2Track.getChi2()) + " " +// + String.format("%d ", currentBranch.chi2Track.getNCoasts()) +// + MHTKernel.bitSetString(currentBranch.trackBitSet, kcount)); /** * 27/02/2020 @@ -460,7 +464,7 @@ public class MHTKernel { //add confirmed track confirmedTracks.add(currentBranch); - + //// //if a branch is confirmed then all the tracks which include it's clicks must also be removed. //// //test the testBranch against all other branches. TODO - Is this the most efficient code -could add if statements to above loop? for (int j=0; j { indexRemove[j]=true; } } + } else { //save as an active track. @@ -678,7 +683,7 @@ public class MHTKernel { /** * * Set a new reference index and junk all data before that index. This can be - * useful for long data sets to save memory once all click trains in preceeding + * useful for long data sets to save memory once all click trains in preceding * data units have been detecteded. Note that the function deletes the currently * confirmed tracks. These should be extracted beforehand; * diff --git a/src/clickTrainDetector/clickTrainAlgorithms/mht/StandardMHTChi2.java b/src/clickTrainDetector/clickTrainAlgorithms/mht/StandardMHTChi2.java index ee8ec6ca..1a8d67e7 100644 --- a/src/clickTrainDetector/clickTrainAlgorithms/mht/StandardMHTChi2.java +++ b/src/clickTrainDetector/clickTrainAlgorithms/mht/StandardMHTChi2.java @@ -5,6 +5,7 @@ import java.util.BitSet; import PamUtils.PamArrayUtils; import PamguardMVC.PamDataUnit; +import PamguardMVC.debug.Debug; import clickTrainDetector.clickTrainAlgorithms.CTAlgorithmInfo; import clickTrainDetector.clickTrainAlgorithms.mht.electricalNoiseFilter.ElectricalNoiseFilter; import clickTrainDetector.clickTrainAlgorithms.mht.electricalNoiseFilter.SimpleElectricalNoiseFilter; @@ -225,16 +226,17 @@ public class StandardMHTChi2 implements MHTChi2, Cloneable { getIDIManager().setForceCalc(true); this.lastIDIData = getIDIManager().getIDIStruct(bitSet); - //System.out.println("Time diff: " + lastIDIData.timeDiff + " " + lastIDIData.medianIDI); nCoasts=(int) Math.floor(lastIDIData.timeDiff/Math.abs(lastIDIData.medianIDI)); } else if (bitcount==1) { //this stops a single units being stuck in the back of the probability matrix. - nCoasts = (int) Math.floor((newdataUnit.getTimeMilliseconds()/1000. - -getIDIManager().getLastTime(bitSet)/this.getChi2Params().maxICI)); + nCoasts = (int) Math.floor(((newdataUnit.getTimeMilliseconds()-getIDIManager().getFirstDataUnit().getTimeMilliseconds())/1000. + -getIDIManager().getLastTime(bitSet))/this.getChi2Params().maxICI); } + + //System.out.println("nCoasts: " + nCoasts); return nCoasts; } @@ -332,6 +334,8 @@ public class StandardMHTChi2 implements MHTChi2, Cloneable { double totalTracktime = PamArrayUtils.sum(lastIDIData.idiSeries); + //System.out.println("Total track time: " + totalTracktime); + /** * Add a nudge towards longer tracks (remember to cast to double when dividing). Note that * kcount coefficient is meaningless because all tracks are multiplied by it and x^2 is only used @@ -341,7 +345,7 @@ public class StandardMHTChi2 implements MHTChi2, Cloneable { //19/03/2020 - fixed a bug; Was multiplying instead of dividing - as such long tracks were being //discriminated against causing fragmentation...ooops chi2=chi2/Math.pow(totalTracktime/getIDIManager().getTotalTime(),getChi2Params().longTrackExponent); - + //chi2=chi2/Math.pow(bitSet.cardinality(),getChi2Params().longTrackExponent); } @@ -374,6 +378,8 @@ public class StandardMHTChi2 implements MHTChi2, Cloneable { //All done. Set the values. //set the chi2 values. //long time3=System.nanoTime(); + //Debug.out.println("Track chi2: " + chi2 + " " + bitcount ); + return chi2; } diff --git a/src/clickTrainDetector/clickTrainAlgorithms/mht/mhtvar/AmplitudeChi2.java b/src/clickTrainDetector/clickTrainAlgorithms/mht/mhtvar/AmplitudeChi2.java index cff7d705..43fbb67a 100644 --- a/src/clickTrainDetector/clickTrainAlgorithms/mht/mhtvar/AmplitudeChi2.java +++ b/src/clickTrainDetector/clickTrainAlgorithms/mht/mhtvar/AmplitudeChi2.java @@ -2,6 +2,9 @@ package clickTrainDetector.clickTrainAlgorithms.mht.mhtvar; import PamguardMVC.PamDataUnit; +import clickTrainDetector.clickTrainAlgorithms.mht.StandardMHTChi2Params; +import clickTrainDetector.layout.mht.AmplitudeMHTVarPane; +import clickTrainDetector.layout.mht.MHTVarSettingsPane; /** * Chi^2 value for dB amplitude of tracks. Measures the chnage in track delta between @@ -13,9 +16,14 @@ import PamguardMVC.PamDataUnit; @SuppressWarnings("rawtypes") public class AmplitudeChi2 extends SimpleChi2VarDelta { + private double lastDiff; + + private AmplitudeChi2Params amplitudeParams; + + public AmplitudeChi2() { super(); - super.setSimpleChiVarParams(defaultSettings()); + super.setSimpleChiVarParams(amplitudeParams = (AmplitudeChi2Params) defaultSettings()); } /** @@ -23,7 +31,7 @@ public class AmplitudeChi2 extends SimpleChi2VarDelta { * @return */ private SimpleChi2VarParams defaultSettings() { - SimpleChi2VarParams simpleChiVarParams = new SimpleChi2VarParams(getName(), getUnits()); + AmplitudeChi2Params simpleChiVarParams = new AmplitudeChi2Params(getName(), getUnits()); //simpleChiVarParams.errLimits=new double[] {Double.MIN_VALUE, 100}; simpleChiVarParams.error=30; simpleChiVarParams.minError=1; @@ -36,13 +44,15 @@ public class AmplitudeChi2 extends SimpleChi2VarDelta { return "Amplitude"; } + @Override public double getDiffValue(PamDataUnit pamDataUnit0, PamDataUnit pamDataUnit1) { //System.out.println("DB: " + pamDataUnit0.getAmplitudeDB()); //made this abs so it can deal with increasing then decreasing click trains. i.e. //the click trian is not penalised if it gradually increasing then starts to gradually decrease //in amplitude. - return Math.abs(pamDataUnit0.getAmplitudeDB()-pamDataUnit1.getAmplitudeDB()); + this.lastDiff = Math.abs(pamDataUnit0.getAmplitudeDB()-pamDataUnit1.getAmplitudeDB()); + return lastDiff; } @Override @@ -50,6 +60,28 @@ public class AmplitudeChi2 extends SimpleChi2VarDelta { //just a simple static error coefficient. return super.getError(); } + + @Override + public double calcDeltaChi2(double lastDelta, double newDelta, double timeDiff) { + + double chi2 = super.calcDeltaChi2(lastDelta, newDelta, timeDiff); + + /** + * There was a problem here with using the delta instead of the absolute difference between amplitudes. + * When using the delta there could be a slow change of amplitude gradient which could lead to giant + * changes in absolute amplitude. By ensuring this is the absolute + * value between bearings (lastdiff) then the bearingJump threshold works as it should. + */ + + //System.out.println("Amplitude: " + amplitudeParams.ampJumpEnable + " " + lastDiff + " " + amplitudeParams.maxAmpJump); + + if (lastDiff>amplitudeParams.maxAmpJump && amplitudeParams.ampJumpEnable ) { + chi2=chi2+StandardMHTChi2Params.JUNK_TRACK_PENALTY; + } + + + return chi2; + } @Override @@ -57,6 +89,27 @@ public class AmplitudeChi2 extends SimpleChi2VarDelta { return "dB"; } + @Override + public void setSimpleChiVarParams(SimpleChi2VarParams params) { + if (params==null) amplitudeParams = new AmplitudeChi2Params(getName(), getUnits()); //backwards compatibility + else this.amplitudeParams = (AmplitudeChi2Params) params; ; + + super.setSimpleChiVarParams(params); + //save a reference to params so we don;t have to keep casting. + } + + @Override + public void setSettingsObject(Object object) { + this.setSimpleChiVarParams((AmplitudeChi2Params) object); + } + + @Override + public MHTVarSettingsPane getSettingsPane() { + if (this.settingsPane==null) this.settingsPane= new AmplitudeMHTVarPane(getSimpleChiVarParams(), new ResultConverter()); + settingsPane.setParams(getSimpleChiVarParams()); + return settingsPane; + } + } diff --git a/src/clickTrainDetector/clickTrainAlgorithms/mht/mhtvar/AmplitudeChi2Params.java b/src/clickTrainDetector/clickTrainAlgorithms/mht/mhtvar/AmplitudeChi2Params.java new file mode 100644 index 00000000..20fa3e3a --- /dev/null +++ b/src/clickTrainDetector/clickTrainAlgorithms/mht/mhtvar/AmplitudeChi2Params.java @@ -0,0 +1,46 @@ +package clickTrainDetector.clickTrainAlgorithms.mht.mhtvar; + +import PamModel.parametermanager.ManagedParameters; + +public class AmplitudeChi2Params extends SimpleChi2VarParams implements ManagedParameters { + + + + public AmplitudeChi2Params(String name, String unitString, double error, double minError, double errorScaleValue) { + super(name, unitString, error, minError, errorScaleValue); + // TODO Auto-generated constructor stub + } + public AmplitudeChi2Params(String name, String unitString, double error, double minError) { + super(name, unitString, error, minError); + // TODO Auto-generated constructor stub + } + public AmplitudeChi2Params(String name, String unitString) { + super(name, unitString); + // TODO Auto-generated constructor stub + } + public AmplitudeChi2Params(String name) { + super(name); + } + + public AmplitudeChi2Params(SimpleChi2VarParams params) { + this(params.name, params.getUnits(), params.error, params.minError, params.errorScaleValue); + } + + /** + * + */ + private static final long serialVersionUID = 1L; + + /** + * Whether the bearing jump is used. + */ + public boolean ampJumpEnable = true; + + /** + * The maximum allowed bearing bearing jump in a click train in RADIANS + */ + public double maxAmpJump = 10; //dB + + + +} \ No newline at end of file diff --git a/src/clickTrainDetector/clickTrainAlgorithms/mht/mhtvar/BearingChi2Delta.java b/src/clickTrainDetector/clickTrainAlgorithms/mht/mhtvar/BearingChi2Delta.java index 703257fa..49e571b8 100644 --- a/src/clickTrainDetector/clickTrainAlgorithms/mht/mhtvar/BearingChi2Delta.java +++ b/src/clickTrainDetector/clickTrainAlgorithms/mht/mhtvar/BearingChi2Delta.java @@ -141,7 +141,7 @@ public class BearingChi2Delta extends SimpleChi2VarDelta { if (delta>bearingParams.maxBearingJump) { //System.out.println("Hello!!!! Reverse Bearing"); - chi2=chi2*StandardMHTChi2Params.JUNK_TRACK_PENALTY; + chi2=chi2+StandardMHTChi2Params.JUNK_TRACK_PENALTY; } } diff --git a/src/clickTrainDetector/clickTrainAlgorithms/mht/mhtvar/IDIManager.java b/src/clickTrainDetector/clickTrainAlgorithms/mht/mhtvar/IDIManager.java index d6691247..f698e603 100644 --- a/src/clickTrainDetector/clickTrainAlgorithms/mht/mhtvar/IDIManager.java +++ b/src/clickTrainDetector/clickTrainAlgorithms/mht/mhtvar/IDIManager.java @@ -536,6 +536,10 @@ public class IDIManager { return (this.lastDetection.getTimeMilliseconds()- this.firstDetection.getTimeMilliseconds())/1000.; } + public PamDataUnit getFirstDataUnit() { + return this.firstDetection; + } + diff --git a/src/clickTrainDetector/clickTrainAlgorithms/mht/mhtvar/LengthChi2.java b/src/clickTrainDetector/clickTrainAlgorithms/mht/mhtvar/LengthChi2.java index 4ae8f6f1..96dd3515 100644 --- a/src/clickTrainDetector/clickTrainAlgorithms/mht/mhtvar/LengthChi2.java +++ b/src/clickTrainDetector/clickTrainAlgorithms/mht/mhtvar/LengthChi2.java @@ -16,7 +16,6 @@ public class LengthChi2 extends SimpleChi2Var { @Override public String getName() { - // TODO Auto-generated method stub return "Click Length"; } @@ -44,7 +43,7 @@ public class LengthChi2 extends SimpleChi2Var { //simpleChiVarParams.errLimits=new double[] {Double.MIN_VALUE, 100}; simpleChiVarParams.error=0.2; simpleChiVarParams.minError=0.002; - simpleChiVarParams.errorScaleValue = SimpleChi2VarParams.SCALE_FACTOR_ICI; + simpleChiVarParams.errorScaleValue = SimpleChi2VarParams.SCALE_FACTOR_ICI*10; return simpleChiVarParams; } diff --git a/src/clickTrainDetector/layout/mht/AdvMHTVarPane.java b/src/clickTrainDetector/layout/mht/AdvMHTVarPane.java index 74a2ee1c..285da0f4 100644 --- a/src/clickTrainDetector/layout/mht/AdvMHTVarPane.java +++ b/src/clickTrainDetector/layout/mht/AdvMHTVarPane.java @@ -28,7 +28,7 @@ public class AdvMHTVarPane extends DynamicSettingsPane { /** * Default divisor of error for min error. */ - private static final Double ERROR_DIVISOR = 10000.0; + private static final Double ERROR_DIVISOR = 100.0; /** * The main pane. diff --git a/src/clickTrainDetector/layout/mht/AmplitudeChi2AdvPane.java b/src/clickTrainDetector/layout/mht/AmplitudeChi2AdvPane.java new file mode 100644 index 00000000..b4631820 --- /dev/null +++ b/src/clickTrainDetector/layout/mht/AmplitudeChi2AdvPane.java @@ -0,0 +1,97 @@ +package clickTrainDetector.layout.mht; + +import org.controlsfx.control.ToggleSwitch; + +import clickTrainDetector.clickTrainAlgorithms.mht.mhtvar.AmplitudeChi2Params; +import clickTrainDetector.clickTrainAlgorithms.mht.mhtvar.IDIChi2Params; +import clickTrainDetector.clickTrainAlgorithms.mht.mhtvar.ResultConverter; +import clickTrainDetector.clickTrainAlgorithms.mht.mhtvar.SimpleChi2VarParams; +import javafx.scene.control.Label; +import javafx.scene.control.Spinner; +import javafx.scene.control.Tooltip; +import javafx.scene.layout.GridPane; +import pamViewFX.fxNodes.PamSpinner; + +public class AmplitudeChi2AdvPane extends AdvMHTVarPane { + + private PamSpinner ampJumpSpinner; + private ToggleSwitch ampEnaleSwitch; + + + public AmplitudeChi2AdvPane(SimpleChi2VarParams simpleChi2Var2, ResultConverter resultConverter) { + super(simpleChi2Var2, resultConverter); + } + + + @Override + protected GridPane createAdvPane() { + + GridPane gridPane = (GridPane) super.createAdvPane(); + + int gridY=3; + + gridPane.add(ampEnaleSwitch = new ToggleSwitch("Max jump"), 0, gridY); + ampEnaleSwitch.selectedProperty().addListener((obsVal, newVal, oldVal)->{ + ampJumpSpinner.setDisable(!ampEnaleSwitch.isSelected()); + }); + ampJumpSpinner = new PamSpinner(0.,Double.MAX_VALUE,0.,1.0); + ampJumpSpinner.getStyleClass().add(Spinner.STYLE_CLASS_SPLIT_ARROWS_HORIZONTAL); + ampJumpSpinner.setPrefWidth(90); + ampJumpSpinner.valueProperty().addListener((obs,oldVal,newVal)->{ + notifySettingsListeners(); + }); + gridPane.add(ampJumpSpinner, 1, gridY); + gridPane.add(new Label("dB"), 2, gridY); + ampJumpSpinner.setEditable(true); + + //create tool tip + Tooltip errorCoeffTip = new Tooltip( + "The minimum Amplitude defines the maximum decibel jump between two detection allowed in a click train" + + "If an IDI below this minimum occurs in a click train it will incur" + + "a large chi^2 penalty and so the click train is unlikely to be kept" + + "in the hypothesis mix."); + errorCoeffTip.setWrapText(true); + errorCoeffTip.setPrefWidth(200); + ampEnaleSwitch.setTooltip(errorCoeffTip); + ampJumpSpinner.setTooltip(errorCoeffTip); + + ampJumpSpinner.setDisable(!ampEnaleSwitch.isSelected()); + + + return gridPane; + } + + + @Override + public AmplitudeChi2Params getParams(SimpleChi2VarParams currParams) { + + System.out.println("Get params: AMPLITUDE"); + + AmplitudeChi2Params newParams = new AmplitudeChi2Params(super.getParams(currParams)); + + newParams.maxAmpJump = ampJumpSpinner.getValue(); + newParams.ampJumpEnable = ampEnaleSwitch.isSelected(); + + return newParams; + } + + + @Override + public void setParams(SimpleChi2VarParams currParams) { + + AmplitudeChi2Params newParams; + if (currParams instanceof AmplitudeChi2Params) { + newParams = (AmplitudeChi2Params) currParams; + } + else { + newParams = new AmplitudeChi2Params(currParams); + } + + super.setParams(newParams); + + ampJumpSpinner.setDisable(!ampEnaleSwitch.isSelected()); + ampJumpSpinner.getValueFactory().setValue(newParams.maxAmpJump); + ampEnaleSwitch.setSelected(newParams.ampJumpEnable); + } + +} diff --git a/src/clickTrainDetector/layout/mht/AmplitudeMHTVarPane.java b/src/clickTrainDetector/layout/mht/AmplitudeMHTVarPane.java new file mode 100644 index 00000000..0c314755 --- /dev/null +++ b/src/clickTrainDetector/layout/mht/AmplitudeMHTVarPane.java @@ -0,0 +1,22 @@ +package clickTrainDetector.layout.mht; + +import clickTrainDetector.clickTrainAlgorithms.mht.mhtvar.ResultConverter; +import clickTrainDetector.clickTrainAlgorithms.mht.mhtvar.SimpleChi2VarParams; + +public class AmplitudeMHTVarPane extends SimpleMHTVarPane { + + public AmplitudeMHTVarPane(SimpleChi2VarParams simpleChi2Var, ResultConverter resultsConverter) { + super(simpleChi2Var, resultsConverter); + // TODO Auto-generated constructor stub + } + + /** + * Create the advanced settings pane. + * @return the advanced settings pane. + */ + @Override + public AdvMHTVarPane createAdvMHTVarPane(SimpleChi2VarParams simpleChi2VarParams, ResultConverter resultConverter) { + return new AmplitudeChi2AdvPane(simpleChi2VarParams, resultConverter); + } + +} diff --git a/src/clickTrainDetector/layout/mht/BearingMHTVarPane.java b/src/clickTrainDetector/layout/mht/BearingMHTVarPane.java index 7039f3cb..cb3036a0 100644 --- a/src/clickTrainDetector/layout/mht/BearingMHTVarPane.java +++ b/src/clickTrainDetector/layout/mht/BearingMHTVarPane.java @@ -8,7 +8,6 @@ public class BearingMHTVarPane extends SimpleMHTVarPane { public BearingMHTVarPane(SimpleChi2VarParams simpleChi2Var, ResultConverter resultsConverter) { super(simpleChi2Var, resultsConverter); - // TODO Auto-generated constructor stub } /** diff --git a/src/clickTrainDetector/layout/mht/CorrelationAdvMHTPane.java b/src/clickTrainDetector/layout/mht/CorrelationAdvMHTPane.java index 9b4e6166..5238b24d 100644 --- a/src/clickTrainDetector/layout/mht/CorrelationAdvMHTPane.java +++ b/src/clickTrainDetector/layout/mht/CorrelationAdvMHTPane.java @@ -86,11 +86,11 @@ public class CorrelationAdvMHTPane extends AdvMHTVarPane { CorrelationChi2Params newParams = new CorrelationChi2Params(super.getParams(currParams)); - System.out.println("GETPARAMS:fftFilterParams_OLD HIGHPASS: " + newParams.fftFilterParams.highPassFreq); + //System.out.println("GETPARAMS:fftFilterParams_OLD HIGHPASS: " + newParams.fftFilterParams.highPassFreq); newParams.fftFilterParams=filterPane.getParams(newParams.fftFilterParams); - System.out.println("GETPARAMS:fftFilterParams_NEW HIGHPASS: " + newParams.fftFilterParams.highPassFreq); + //System.out.println("GETPARAMS:fftFilterParams_NEW HIGHPASS: " + newParams.fftFilterParams.highPassFreq); newParams.useFilter=this.useFilterBox.isSelected(); diff --git a/src/clickTrainDetector/layout/mht/ICIChi2AdvPane.java b/src/clickTrainDetector/layout/mht/ICIChi2AdvPane.java index 53327efc..9af6bca4 100644 --- a/src/clickTrainDetector/layout/mht/ICIChi2AdvPane.java +++ b/src/clickTrainDetector/layout/mht/ICIChi2AdvPane.java @@ -42,7 +42,8 @@ public class ICIChi2AdvPane extends AdvMHTVarPane { }); gridPane.add(minICISpinner, 1, gridY); gridPane.add(new Label("ms"), 2, gridY); - + minICISpinner.setEditable(true); + //create tool tip Tooltip errorCoeffTip = new Tooltip( "The minimum IDI defines a minimum IDI allowed in a click train \n" + "If an IDI below this minimum occurs in a click train it will incur\n" diff --git a/src/clickTrainDetector/logging/ClickTrainDetLogging.java b/src/clickTrainDetector/logging/ClickTrainDetLogging.java index f4081e49..4ebe115d 100644 --- a/src/clickTrainDetector/logging/ClickTrainDetLogging.java +++ b/src/clickTrainDetector/logging/ClickTrainDetLogging.java @@ -98,7 +98,7 @@ public class ClickTrainDetLogging extends SuperDetLogging { //average spectrum tableDef.addTableItem(avrg_Spectrum_max = new PamTableItem("avrg_spectrum_max", Types.DOUBLE)); tableDef.addTableItem(avrg_Spectrum = new PamTableItem("avrg_spectrum", Types.CHAR, 8*DEFAULT_SPECTRUM_LEN)); - tableDef.addTableItem(classifiers = new PamTableItem("classifiers", Types.CHAR, 4096)); + tableDef.addTableItem(classifiers = new PamTableItem("classifiers", Types.CHAR, 8128)); //a species flag, this is entirely for user convenience and is NOT read back - the species flag //is read from the JSON strings when reloading the data unit. If they end being different something has gone @@ -279,7 +279,9 @@ public class ClickTrainDetLogging extends SuperDetLogging { //set the classifications. String classifiersData = classifiers.getStringValue(); - + + //FIXME + //System.out.println(classifiersData); if (classifiersData!=null && classifiersData.length()>0) { String[] classifiersDatas = classifiersData.split(JSON_DELIMITER); diff --git a/src/clickTrainDetector/offline/CTProcessDialog.java b/src/clickTrainDetector/offline/CTProcessDialog.java index 0f8e07cf..39cecd03 100644 --- a/src/clickTrainDetector/offline/CTProcessDialog.java +++ b/src/clickTrainDetector/offline/CTProcessDialog.java @@ -44,7 +44,7 @@ public class CTProcessDialog extends OLProcessDialog { getTaskCheckBoxs()[i].setEnabled(aTask.canRun() && nr); //added extra but here so that only one tasks can be run at a time- may change - System.out.println("A task can run: !!" + aTask.canRun() + " " + aTask.getDataBlock()); + //System.out.println("A task can run: !!" + aTask.canRun() + " " + aTask.getDataBlock()); //if more tasks are added to the click train detector. if (aTask.canRun() == false || (aTask!=task && task!=null)) { getTaskCheckBoxs()[i].setSelected(false); diff --git a/src/matchedTemplateClassifer/ImportTemplateCSV.java b/src/matchedTemplateClassifer/ImportTemplateCSV.java index c3c1be20..0713f026 100644 --- a/src/matchedTemplateClassifer/ImportTemplateCSV.java +++ b/src/matchedTemplateClassifer/ImportTemplateCSV.java @@ -41,6 +41,7 @@ public class ImportTemplateCSV implements TemplateImport { //the first row is the waveform double[] waveform = new double[data.get(0).size()]; for (int i=0; i { */ PamControlledUnit parentControl = getTaskControlledUnit(); if (parentControl == null) { - System.out.printf("Offline task %d with datablock %s is not associated with a PAMGuard module\n", getName(), parentDataBlock); + System.out.printf("Offline task %s with datablock %s is not associated with a PAMGuard module\n", getName(), parentDataBlock==null ? "null": parentDataBlock.getDataName()); } else { OfflineTaskManager.getManager().registerTask(this); diff --git a/src/offlineProcessing/logging/TaskLogging.java b/src/offlineProcessing/logging/TaskLogging.java index 1193e05f..b8812b03 100644 --- a/src/offlineProcessing/logging/TaskLogging.java +++ b/src/offlineProcessing/logging/TaskLogging.java @@ -187,20 +187,31 @@ public class TaskLogging { String modType = moduleType.getDeblankedStringValue(); String modName = moduleName.getDeblankedStringValue(); String tskName = taskName.getDeblankedStringValue(); - long dStart = SQLTypes.millisFromTimeStamp(dataStart.getValue()); - long dEnd = SQLTypes.millisFromTimeStamp(dataEnd.getValue()); - long procEnd = SQLTypes.millisFromTimeStamp(runEnd.getValue()); + + Long dEnd = null, dStart = null, procEnd = null; + dStart = SQLTypes.millisFromTimeStamp(dataStart.getValue()); + dEnd = SQLTypes.millisFromTimeStamp(dataEnd.getValue()); + procEnd = SQLTypes.millisFromTimeStamp(runEnd.getValue()); + if (dStart==null && dEnd==null && procEnd==null) return null; + String compStatus = completionCode.getDeblankedStringValue(); TaskStatus status = null; + if (compStatus==null) return null; try { status = TaskStatus.valueOf(TaskStatus.class, compStatus); } catch (IllegalArgumentException e) { System.out.printf("Uknown completion code \"%s\" for task %s ended at %s\n", compStatus, tskName, PamCalendar.formatDateTime(dEnd)); } + String taskNote = note.getDeblankedStringValue(); - OldTaskData monData = new OldTaskData(status, dStart, dEnd, utc, procEnd, taskNote); - return monData; + if (dStart!=null && dEnd!=null && procEnd!=null) { + OldTaskData monData = new OldTaskData(status, dStart, dEnd, utc, procEnd, taskNote); + return monData; + } + else { + return null; + } } /** diff --git a/src/soundPlayback/preprocess/PlaybackFilter.java b/src/soundPlayback/preprocess/PlaybackFilter.java index 97d55120..e4a98d5a 100644 --- a/src/soundPlayback/preprocess/PlaybackFilter.java +++ b/src/soundPlayback/preprocess/PlaybackFilter.java @@ -74,7 +74,7 @@ public class PlaybackFilter implements PlaybackPreprocess { } public String getTextValue() { - System.out.println("Playback control Sample rate: " + playbackControl.getSourceSampleRate() + " val: " + getValue()); + //System.out.println("Playback control Sample rate: " + playbackControl.getSourceSampleRate() + " val: " + getValue()); double f = getValue() * playbackControl.getSourceSampleRate(); if (f == 0) { return "High pass filter off";