Bug fixes to click train detector

Fixed bug with number of coasts in the MHT Kernel
Added an option for amplitude to have a maximum
Removed print statements.
This commit is contained in:
Jamie Mac 2022-08-06 11:47:38 +01:00
parent 36fb1e0e3d
commit 3c72fb78d9
24 changed files with 304 additions and 51 deletions

View File

@ -6,6 +6,7 @@ import java.io.File;
import java.io.FileReader; import java.io.FileReader;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.text.DecimalFormat;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@ -62,7 +63,7 @@ public class TxtFileUtils {
boolean isNaN=false; boolean isNaN=false;
for (String line : lines) { for (String line : lines) {
System.out.println(line); //System.out.println(line);
String[] recordsOnLine = line.split(delimeter); 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 // //This was causing isses with some numbers with e-06...dunno why so switched to parse double
// String input = new String(recordsOnLine[i].toCharArray()); // String input = new String(recordsOnLine[i].toCharArray());
// //System.out.println(input); // System.out.println("|" + recordsOnLine[i] + "|");
// dat = nF.parse(input).doubleValue(); // dat = nF.parse(input).doubleValue();
//5/08/2022 - there was a bug here where there is some sort of invisible character that does not appear on the
dat = Double.parseDouble(recordsOnLine[i]); //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){ catch (Exception e){
e.printStackTrace(); e.printStackTrace();

View File

@ -5,6 +5,7 @@ import java.util.List;
import PamUtils.PamArrayUtils; import PamUtils.PamArrayUtils;
import PamguardMVC.PamDataUnit; import PamguardMVC.PamDataUnit;
import PamguardMVC.debug.Debug;
/** /**
* Holds some basic IDI info on the click train. * Holds some basic IDI info on the click train.
@ -47,7 +48,7 @@ public class IDIInfo {
lastNumber = dataUnits.size(); lastNumber = dataUnits.size();
if (dataUnits.size()<3) { 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; return;
} }

View File

@ -31,7 +31,6 @@ public class SimpleCTClassification implements CTClassification {
@Override @Override
public String getSummaryString() { public String getSummaryString() {
// TODO Auto-generated method stub
return "SimpleClssf: SpeciesID: " + speciesID + " ClassifierType: " + classifierType; return "SimpleClssf: SpeciesID: " + speciesID + " ClassifierType: " + classifierType;
} }

View File

@ -1,8 +1,8 @@
package clickTrainDetector.classification.bearingClassifier; package clickTrainDetector.classification.bearingClassifier;
import org.renjin.gcc.runtime.Debug;
import PamUtils.PamArrayUtils; import PamUtils.PamArrayUtils;
import PamguardMVC.debug.Debug;
import clickTrainDetector.CTDataUnit; import clickTrainDetector.CTDataUnit;
import clickTrainDetector.ClickTrainControl; import clickTrainDetector.ClickTrainControl;
import clickTrainDetector.classification.CTClassification; import clickTrainDetector.classification.CTClassification;
@ -95,7 +95,7 @@ public class BearingClassifier implements CTClassifier {
if (nullcount>clickTrain.getSubDetectionsCount()-4) { if (nullcount>clickTrain.getSubDetectionsCount()-4) {
//less than three data units with loc results //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); 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 medianBearingD = PamArrayUtils.median(bearingDiff);
double stdBearingD = PamArrayUtils.std(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; int speciesID = CTClassifier.NOSPECIES;
boolean passed= true; boolean passed= true;
@ -120,31 +120,31 @@ public class BearingClassifier implements CTClassifier {
//is the minimum and maximum bearing in range... //is the minimum and maximum bearing in range...
if ((min>=bearingClssfrParams.bearingLimMin && min<=bearingClssfrParams.bearingLimMax) || if ((min>=bearingClssfrParams.bearingLimMin && min<=bearingClssfrParams.bearingLimMax) ||
(max>=bearingClssfrParams.bearingLimMin && max<=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; else passed =false;
//mean bearing derivative //mean bearing derivative
if (bearingClssfrParams.useMean && meanBearingD>=bearingClssfrParams.minMeanBearingD if (bearingClssfrParams.useMean && meanBearingD>=bearingClssfrParams.minMeanBearingD
&& meanBearingD<=bearingClssfrParams.maxMeanBearingD) { && meanBearingD<=bearingClssfrParams.maxMeanBearingD) {
Debug.println("Passed on mean bearing"); Debug.out.println("Passed on mean bearing");
} }
else if (bearingClssfrParams.useMean) passed=false; else if (bearingClssfrParams.useMean) passed=false;
//median bearing derivative //median bearing derivative
Debug.println("Median Bearing: " + Math.toDegrees(medianBearingD) + Debug.out.println("Median Bearing: " + Math.toDegrees(medianBearingD) +
" minlim: " + Math.toDegrees(bearingClssfrParams.minMedianBearingD)+ " minlim: " + Math.toDegrees(bearingClssfrParams.minMedianBearingD)+
" maxlim: " + Math.toDegrees(bearingClssfrParams.maxMedianBearingD)); " maxlim: " + Math.toDegrees(bearingClssfrParams.maxMedianBearingD));
if (bearingClssfrParams.useMedian && medianBearingD>=bearingClssfrParams.minMedianBearingD if (bearingClssfrParams.useMedian && medianBearingD>=bearingClssfrParams.minMedianBearingD
&& medianBearingD<=bearingClssfrParams.maxMedianBearingD) { && medianBearingD<=bearingClssfrParams.maxMedianBearingD) {
Debug.println("Passed on median bearing"); Debug.out.println("Passed on median bearing");
} }
else if (bearingClssfrParams.useMedian) passed = false; else if (bearingClssfrParams.useMedian) passed = false;
//standard deviation derivative //standard deviation derivative
if (bearingClssfrParams.useStD && stdBearingD>=bearingClssfrParams.minStdBearingD if (bearingClssfrParams.useStD && stdBearingD>=bearingClssfrParams.minStdBearingD
&& stdBearingD<=bearingClssfrParams.maxStdBearingD) { && stdBearingD<=bearingClssfrParams.maxStdBearingD) {
Debug.println("Passed on std bearing"); Debug.out.println("Passed on std bearing");
} }
else if (bearingClssfrParams.useStD) passed= false; else if (bearingClssfrParams.useStD) passed= false;
@ -152,7 +152,7 @@ public class BearingClassifier implements CTClassifier {
speciesID = this.bearingClssfrParams.speciesFlag; speciesID = this.bearingClssfrParams.speciesFlag;
} }
Debug.println("SPECIESID!! " + speciesID); Debug.out.println("SPECIESID!! " + speciesID);
return new BearingClassification(speciesID, meanBearingD, medianBearingD, stdBearingD); return new BearingClassification(speciesID, meanBearingD, medianBearingD, stdBearingD);

View File

@ -71,10 +71,12 @@ public class MHTGarbageBot {
//check the current set of click train possible ICI's //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. //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)) { 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 //check whether the next click has a gap so big that all click trains should be restarted
//grab tracks //grab tracks
mhtKernel.confirmRemainingTracks(); mhtKernel.confirmRemainingTracks();

View File

@ -159,8 +159,8 @@ public class MHTKernel<T> {
Debug.out.println("Possiblity matrix size is " + possibleTracks.size() + " x " + kcount ); Debug.out.println("Possiblity matrix size is " + possibleTracks.size() + " x " + kcount );
} }
// for (int i=0; i<possibleTracks.size(); i++) { // for (int i=0; i<possibleTracks.size(); i++) {
// System.out.println("Pos " + i + " chi^2 "+ possibleTracks.get(i).chi2Track + // System.out.println("Pos " + i + " chi^2 "+ possibleTracks.get(i).chi2Track.getChi2() +
// " " + printBitSet(possibleTracks.get(i).trackBitSet) ); // " " + MHTKernel.bitSetString(possibleTracks.get(i).trackBitSet,kcount));
// } // }
//prune the probability matrix. //prune the probability matrix.
@ -412,6 +412,7 @@ public class MHTKernel<T> {
testBranch = newPossibleTracks.get(j); testBranch = newPossibleTracks.get(j);
testBitSet=testBranch.trackBitSet.get(0, kcount-(pruneback)); testBitSet=testBranch.trackBitSet.get(0, kcount-(pruneback));
//now test whether the current and test branch are the same. //now test whether the current and test branch are the same.
if (testBitSet.equals(currentBitSet)) { if (testBitSet.equals(currentBitSet)) {
indexConfirm[j]=true; indexConfirm[j]=true;
@ -423,6 +424,7 @@ public class MHTKernel<T> {
indexRemove[j]=true; indexRemove[j]=true;
} }
} }
} }
//long time2a=System.currentTimeMillis(); //long time2a=System.currentTimeMillis();
@ -437,9 +439,11 @@ public class MHTKernel<T> {
if (nCoasts>=this.mHTParams.maxCoast || confirmAll || currentBranch.flag==TrackBitSet.JUNK_TRACK) { if (nCoasts>=this.mHTParams.maxCoast || confirmAll || currentBranch.flag==TrackBitSet.JUNK_TRACK) {
//the branch needs to be confirmed. //the branch needs to be confirmed.
// System.out.println(i + " DONE: "+ String.format("%.3f ", possibleTracks.get(i).chi2Track.getChi2())+ // System.out.println(i + " DONE: " + (nCoasts >= this.mHTParams.maxCoast) + " " + confirmAll + " "
// " " + String.format("%d ", possibleTracks.get(i).chi2Track.getNCoasts()) // + (currentBranch.flag == TrackBitSet.JUNK_TRACK) + " "
// + MHTKernel.bitSetString(possibleTracks.get(i).trackBitSet, kcount)); // + String.format("%.3f ", currentBranch.chi2Track.getChi2()) + " "
// + String.format("%d ", currentBranch.chi2Track.getNCoasts())
// + MHTKernel.bitSetString(currentBranch.trackBitSet, kcount));
/** /**
* 27/02/2020 * 27/02/2020
@ -471,6 +475,7 @@ public class MHTKernel<T> {
indexRemove[j]=true; indexRemove[j]=true;
} }
} }
} }
else { else {
//save as an active track. //save as an active track.
@ -678,7 +683,7 @@ public class MHTKernel<T> {
/** /**
* *
* Set a new reference index and junk all data before that index. This can be * 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 * data units have been detecteded. Note that the function deletes the currently
* confirmed tracks. These should be extracted beforehand; * confirmed tracks. These should be extracted beforehand;
* *

View File

@ -5,6 +5,7 @@ import java.util.BitSet;
import PamUtils.PamArrayUtils; import PamUtils.PamArrayUtils;
import PamguardMVC.PamDataUnit; import PamguardMVC.PamDataUnit;
import PamguardMVC.debug.Debug;
import clickTrainDetector.clickTrainAlgorithms.CTAlgorithmInfo; import clickTrainDetector.clickTrainAlgorithms.CTAlgorithmInfo;
import clickTrainDetector.clickTrainAlgorithms.mht.electricalNoiseFilter.ElectricalNoiseFilter; import clickTrainDetector.clickTrainAlgorithms.mht.electricalNoiseFilter.ElectricalNoiseFilter;
import clickTrainDetector.clickTrainAlgorithms.mht.electricalNoiseFilter.SimpleElectricalNoiseFilter; import clickTrainDetector.clickTrainAlgorithms.mht.electricalNoiseFilter.SimpleElectricalNoiseFilter;
@ -225,17 +226,18 @@ public class StandardMHTChi2 implements MHTChi2<PamDataUnit>, Cloneable {
getIDIManager().setForceCalc(true); getIDIManager().setForceCalc(true);
this.lastIDIData = getIDIManager().getIDIStruct(bitSet); this.lastIDIData = getIDIManager().getIDIStruct(bitSet);
//System.out.println("Time diff: " + lastIDIData.timeDiff + " " + lastIDIData.medianIDI); //System.out.println("Time diff: " + lastIDIData.timeDiff + " " + lastIDIData.medianIDI);
nCoasts=(int) Math.floor(lastIDIData.timeDiff/Math.abs(lastIDIData.medianIDI)); nCoasts=(int) Math.floor(lastIDIData.timeDiff/Math.abs(lastIDIData.medianIDI));
} }
else if (bitcount==1) { else if (bitcount==1) {
//this stops a single units being stuck in the back of the probability matrix. //this stops a single units being stuck in the back of the probability matrix.
nCoasts = (int) Math.floor((newdataUnit.getTimeMilliseconds()/1000. nCoasts = (int) Math.floor(((newdataUnit.getTimeMilliseconds()-getIDIManager().getFirstDataUnit().getTimeMilliseconds())/1000.
-getIDIManager().getLastTime(bitSet)/this.getChi2Params().maxICI)); -getIDIManager().getLastTime(bitSet))/this.getChi2Params().maxICI);
} }
//System.out.println("nCoasts: " + nCoasts);
return nCoasts; return nCoasts;
} }
@ -332,6 +334,8 @@ public class StandardMHTChi2 implements MHTChi2<PamDataUnit>, Cloneable {
double totalTracktime = PamArrayUtils.sum(lastIDIData.idiSeries); 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 * 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 * 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<PamDataUnit>, Cloneable {
//19/03/2020 - fixed a bug; Was multiplying instead of dividing - as such long tracks were being //19/03/2020 - fixed a bug; Was multiplying instead of dividing - as such long tracks were being
//discriminated against causing fragmentation...ooops //discriminated against causing fragmentation...ooops
chi2=chi2/Math.pow(totalTracktime/getIDIManager().getTotalTime(),getChi2Params().longTrackExponent); 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<PamDataUnit>, Cloneable {
//All done. Set the values. //All done. Set the values.
//set the chi2 values. //set the chi2 values.
//long time3=System.nanoTime(); //long time3=System.nanoTime();
//Debug.out.println("Track chi2: " + chi2 + " " + bitcount );
return chi2; return chi2;
} }

View File

@ -2,6 +2,9 @@ package clickTrainDetector.clickTrainAlgorithms.mht.mhtvar;
import PamguardMVC.PamDataUnit; 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 * Chi^2 value for dB amplitude of tracks. Measures the chnage in track delta between
@ -13,9 +16,14 @@ import PamguardMVC.PamDataUnit;
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
public class AmplitudeChi2 extends SimpleChi2VarDelta { public class AmplitudeChi2 extends SimpleChi2VarDelta {
private double lastDiff;
private AmplitudeChi2Params amplitudeParams;
public AmplitudeChi2() { public AmplitudeChi2() {
super(); super();
super.setSimpleChiVarParams(defaultSettings()); super.setSimpleChiVarParams(amplitudeParams = (AmplitudeChi2Params) defaultSettings());
} }
/** /**
@ -23,7 +31,7 @@ public class AmplitudeChi2 extends SimpleChi2VarDelta {
* @return * @return
*/ */
private SimpleChi2VarParams defaultSettings() { private SimpleChi2VarParams defaultSettings() {
SimpleChi2VarParams simpleChiVarParams = new SimpleChi2VarParams(getName(), getUnits()); AmplitudeChi2Params simpleChiVarParams = new AmplitudeChi2Params(getName(), getUnits());
//simpleChiVarParams.errLimits=new double[] {Double.MIN_VALUE, 100}; //simpleChiVarParams.errLimits=new double[] {Double.MIN_VALUE, 100};
simpleChiVarParams.error=30; simpleChiVarParams.error=30;
simpleChiVarParams.minError=1; simpleChiVarParams.minError=1;
@ -36,13 +44,15 @@ public class AmplitudeChi2 extends SimpleChi2VarDelta {
return "Amplitude"; return "Amplitude";
} }
@Override @Override
public double getDiffValue(PamDataUnit pamDataUnit0, PamDataUnit pamDataUnit1) { public double getDiffValue(PamDataUnit pamDataUnit0, PamDataUnit pamDataUnit1) {
//System.out.println("DB: " + pamDataUnit0.getAmplitudeDB()); //System.out.println("DB: " + pamDataUnit0.getAmplitudeDB());
//made this abs so it can deal with increasing then decreasing click trains. i.e. //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 //the click trian is not penalised if it gradually increasing then starts to gradually decrease
//in amplitude. //in amplitude.
return Math.abs(pamDataUnit0.getAmplitudeDB()-pamDataUnit1.getAmplitudeDB()); this.lastDiff = Math.abs(pamDataUnit0.getAmplitudeDB()-pamDataUnit1.getAmplitudeDB());
return lastDiff;
} }
@Override @Override
@ -51,12 +61,55 @@ public class AmplitudeChi2 extends SimpleChi2VarDelta {
return super.getError(); 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 @Override
public String getUnits() { public String getUnits() {
return "dB"; 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<SimpleChi2VarParams> getSettingsPane() {
if (this.settingsPane==null) this.settingsPane= new AmplitudeMHTVarPane(getSimpleChiVarParams(), new ResultConverter());
settingsPane.setParams(getSimpleChiVarParams());
return settingsPane;
}
} }

View File

@ -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
}

View File

@ -141,7 +141,7 @@ public class BearingChi2Delta extends SimpleChi2VarDelta {
if (delta>bearingParams.maxBearingJump) { if (delta>bearingParams.maxBearingJump) {
//System.out.println("Hello!!!! Reverse Bearing"); //System.out.println("Hello!!!! Reverse Bearing");
chi2=chi2*StandardMHTChi2Params.JUNK_TRACK_PENALTY; chi2=chi2+StandardMHTChi2Params.JUNK_TRACK_PENALTY;
} }
} }

View File

@ -536,6 +536,10 @@ public class IDIManager {
return (this.lastDetection.getTimeMilliseconds()- this.firstDetection.getTimeMilliseconds())/1000.; return (this.lastDetection.getTimeMilliseconds()- this.firstDetection.getTimeMilliseconds())/1000.;
} }
public PamDataUnit getFirstDataUnit() {
return this.firstDetection;
}

View File

@ -16,7 +16,6 @@ public class LengthChi2 extends SimpleChi2Var {
@Override @Override
public String getName() { public String getName() {
// TODO Auto-generated method stub
return "Click Length"; return "Click Length";
} }
@ -44,7 +43,7 @@ public class LengthChi2 extends SimpleChi2Var {
//simpleChiVarParams.errLimits=new double[] {Double.MIN_VALUE, 100}; //simpleChiVarParams.errLimits=new double[] {Double.MIN_VALUE, 100};
simpleChiVarParams.error=0.2; simpleChiVarParams.error=0.2;
simpleChiVarParams.minError=0.002; simpleChiVarParams.minError=0.002;
simpleChiVarParams.errorScaleValue = SimpleChi2VarParams.SCALE_FACTOR_ICI; simpleChiVarParams.errorScaleValue = SimpleChi2VarParams.SCALE_FACTOR_ICI*10;
return simpleChiVarParams; return simpleChiVarParams;
} }

View File

@ -28,7 +28,7 @@ public class AdvMHTVarPane extends DynamicSettingsPane<SimpleChi2VarParams> {
/** /**
* Default divisor of error for min error. * 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. * The main pane.

View File

@ -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<Double> 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<Double>(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);
}
}

View File

@ -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);
}
}

View File

@ -8,7 +8,6 @@ public class BearingMHTVarPane extends SimpleMHTVarPane {
public BearingMHTVarPane(SimpleChi2VarParams simpleChi2Var, ResultConverter resultsConverter) { public BearingMHTVarPane(SimpleChi2VarParams simpleChi2Var, ResultConverter resultsConverter) {
super(simpleChi2Var, resultsConverter); super(simpleChi2Var, resultsConverter);
// TODO Auto-generated constructor stub
} }
/** /**

View File

@ -86,11 +86,11 @@ public class CorrelationAdvMHTPane extends AdvMHTVarPane {
CorrelationChi2Params newParams = new CorrelationChi2Params(super.getParams(currParams)); 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); 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(); newParams.useFilter=this.useFilterBox.isSelected();

View File

@ -42,6 +42,7 @@ public class ICIChi2AdvPane extends AdvMHTVarPane {
}); });
gridPane.add(minICISpinner, 1, gridY); gridPane.add(minICISpinner, 1, gridY);
gridPane.add(new Label("ms"), 2, gridY); gridPane.add(new Label("ms"), 2, gridY);
minICISpinner.setEditable(true);
//create tool tip //create tool tip
Tooltip errorCoeffTip = new Tooltip( "The minimum IDI defines a minimum IDI allowed in a click train \n" Tooltip errorCoeffTip = new Tooltip( "The minimum IDI defines a minimum IDI allowed in a click train \n"

View File

@ -98,7 +98,7 @@ public class ClickTrainDetLogging extends SuperDetLogging {
//average spectrum //average spectrum
tableDef.addTableItem(avrg_Spectrum_max = new PamTableItem("avrg_spectrum_max", Types.DOUBLE)); 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(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 //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 //is read from the JSON strings when reloading the data unit. If they end being different something has gone
@ -280,6 +280,8 @@ public class ClickTrainDetLogging extends SuperDetLogging {
//set the classifications. //set the classifications.
String classifiersData = classifiers.getStringValue(); String classifiersData = classifiers.getStringValue();
//FIXME
//System.out.println(classifiersData);
if (classifiersData!=null && classifiersData.length()>0) { if (classifiersData!=null && classifiersData.length()>0) {
String[] classifiersDatas = classifiersData.split(JSON_DELIMITER); String[] classifiersDatas = classifiersData.split(JSON_DELIMITER);

View File

@ -44,7 +44,7 @@ public class CTProcessDialog extends OLProcessDialog {
getTaskCheckBoxs()[i].setEnabled(aTask.canRun() && nr); getTaskCheckBoxs()[i].setEnabled(aTask.canRun() && nr);
//added extra but here so that only one tasks can be run at a time- may change //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 more tasks are added to the click train detector.
if (aTask.canRun() == false || (aTask!=task && task!=null)) { if (aTask.canRun() == false || (aTask!=task && task!=null)) {
getTaskCheckBoxs()[i].setSelected(false); getTaskCheckBoxs()[i].setSelected(false);

View File

@ -41,6 +41,7 @@ public class ImportTemplateCSV implements TemplateImport {
//the first row is the waveform //the first row is the waveform
double[] waveform = new double[data.get(0).size()]; double[] waveform = new double[data.get(0).size()];
for (int i=0; i<waveform.length; i++) { for (int i=0; i<waveform.length; i++) {
//System.out.println("i: " + i + " : " + data.get(0).get(i));
waveform[i]=data.get(0).get(i); waveform[i]=data.get(0).get(i);
} }

View File

@ -71,7 +71,7 @@ public abstract class OfflineTask<T extends PamDataUnit> {
*/ */
PamControlledUnit parentControl = getTaskControlledUnit(); PamControlledUnit parentControl = getTaskControlledUnit();
if (parentControl == null) { 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 { else {
OfflineTaskManager.getManager().registerTask(this); OfflineTaskManager.getManager().registerTask(this);

View File

@ -187,21 +187,32 @@ public class TaskLogging {
String modType = moduleType.getDeblankedStringValue(); String modType = moduleType.getDeblankedStringValue();
String modName = moduleName.getDeblankedStringValue(); String modName = moduleName.getDeblankedStringValue();
String tskName = taskName.getDeblankedStringValue(); String tskName = taskName.getDeblankedStringValue();
long dStart = SQLTypes.millisFromTimeStamp(dataStart.getValue());
long dEnd = SQLTypes.millisFromTimeStamp(dataEnd.getValue()); Long dEnd = null, dStart = null, procEnd = null;
long procEnd = SQLTypes.millisFromTimeStamp(runEnd.getValue()); 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(); String compStatus = completionCode.getDeblankedStringValue();
TaskStatus status = null; TaskStatus status = null;
if (compStatus==null) return null;
try { try {
status = TaskStatus.valueOf(TaskStatus.class, compStatus); status = TaskStatus.valueOf(TaskStatus.class, compStatus);
} }
catch (IllegalArgumentException e) { catch (IllegalArgumentException e) {
System.out.printf("Uknown completion code \"%s\" for task %s ended at %s\n", compStatus, tskName, PamCalendar.formatDateTime(dEnd)); System.out.printf("Uknown completion code \"%s\" for task %s ended at %s\n", compStatus, tskName, PamCalendar.formatDateTime(dEnd));
} }
String taskNote = note.getDeblankedStringValue(); String taskNote = note.getDeblankedStringValue();
if (dStart!=null && dEnd!=null && procEnd!=null) {
OldTaskData monData = new OldTaskData(status, dStart, dEnd, utc, procEnd, taskNote); OldTaskData monData = new OldTaskData(status, dStart, dEnd, utc, procEnd, taskNote);
return monData; return monData;
} }
else {
return null;
}
}
/** /**
* Get the last data for an offline task. * Get the last data for an offline task.

View File

@ -74,7 +74,7 @@ public class PlaybackFilter implements PlaybackPreprocess {
} }
public String getTextValue() { 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(); double f = getValue() * playbackControl.getSourceSampleRate();
if (f == 0) { if (f == 0) {
return "High pass filter off"; return "High pass filter off";