Merge pull request #11 from PAMGuard/main

Fixes to CTD
This commit is contained in:
Douglas Gillespie 2022-08-23 14:50:08 +01:00 committed by GitHub
commit c182279d38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 56 additions and 15 deletions

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.pamguard</groupId>
<artifactId>Pamguard</artifactId>
<version>2.02.04a</version>
<version>2.02.04f</version>
<name>Pamguard Java12+</name>
<description>Pamguard for Java 12+, using Maven to control dependcies</description>
<url>www.pamguard.org</url>

View File

@ -222,6 +222,9 @@ abstract public class PamSymbolManager<T extends PamSymbolChooser> implements Pa
* @param psc
*/
private void addSuperDetectionModifiers(PamSymbolChooser psc) {
/**
* This is going in an infinite loop. Need to do something to stop it !
*/
ArrayList<SuperDetDataBlock> superDetBlocks = OfflineSuperDetFilter.findPossibleSuperDetections(getPamDataBlock());
// Debug.out.println("The number of super det datablock is: " + superDetBlocks + " for the chooser: " + psc);
@ -233,6 +236,12 @@ abstract public class PamSymbolManager<T extends PamSymbolChooser> implements Pa
if (superMan == null) {
continue;
}
if (superBlock == getPamDataBlock()) {
continue;
}
if (superBlock.getClass() == getPamDataBlock().getClass()) {
continue;
}
// Debug.out.println("The number of super det datablock superMan: " + superMan + " for the chooser: " + psc);
PamSymbolChooser superSC = superMan.getSymbolChooser("Super det': " + psc.getDisplayName(), psc.getProjector());

View File

@ -46,6 +46,7 @@ public abstract class CTDetectionGroupDataUnit extends DetectionGroupDataUnit im
public int addSubDetections(List<PamDataUnit> list) {
int h = super.addSubDetections(list);
this.calcMinMaxAng();
//make sure there is a non null start sample otherwise
//the click trian detector will crash in real time mode.
// this.calcStartSample();

View File

@ -86,13 +86,20 @@ public class ClickTrainProcess extends PamInstantProcess {
//TODO - this is a bit messy. Ideally probably should have the datablock's long name in the settings but
//this would break previous configurations...
sourceDataBlock = PamController.getInstance().getDataBlock(ClickDetection.class,
getClickTrainParams().dataSourceName);
// sourceDataBlock = PamController.getInstance().getDataBlock(ClickDetection.class,
// getClickTrainParams().dataSourceName);
/*
* Identify by long name since that is unique, otherwise doesn't work with multiple click detectors.
*/
sourceDataBlock = PamController.getInstance().getDataBlockByLongName(getClickTrainParams().dataSourceName);
if (sourceDataBlock == null) {
// otherwise find any click detector.
sourceDataBlock = PamController.getInstance().getDataBlock(ClickDetection.class, 0);
}
if (sourceDataBlock==null) {
sourceDataBlock = PamController.getInstance().getDataBlock(CPODClick.class,
getClickTrainParams().dataSourceName);
}
//System.out.println("CPOD sample rate: " + sourceDataBlock.getSampleRate());

View File

@ -154,7 +154,6 @@ public class BearingClassifier implements CTClassifier {
Debug.out.println("SPECIESID!! " + speciesID);
return new BearingClassification(speciesID, meanBearingD, medianBearingD, stdBearingD);
}

View File

@ -116,7 +116,7 @@ public class StandardClassifier implements CTClassifier {
for (int i=0; i<classifiers.size(); i++) {
if (standardClssfrParams.ctClassifierParams[i]==null) {
//set default settings
standardClssfrParams.ctClassifierParams[i]= classifiers.get(i).getParams();
standardClssfrParams.ctClassifierParams[i] = classifiers.get(i).getParams();
}
else {
//the standard classifier should have settings set.
@ -178,6 +178,7 @@ public class StandardClassifier implements CTClassifier {
}
public StandardClassifierParams getParams() {
return standardClssfrParams;
}

View File

@ -848,6 +848,7 @@ public class MHTKernel<T> {
*/
public T getLastDataUnit() {
if (this.dataUnits==null) return null;
if (this.dataUnits.size()<1) return null;
return dataUnits.get(dataUnits.size()-1);
}

View File

@ -61,7 +61,7 @@ public class CTFXGUI extends PamControlledGUIFX {
//data source may have potentially changed. e.g. by a datamodelfx Need to set in params.
//System.out.println("FFTControl: CHANGED_PROCESS_SETTINGS : " +fftProcess.getParentDataBlock());
if (clickTrainControl.getClickTrainProcess().getParentDataBlock()!=null){
clickTrainControl.getClickTrainParams().dataSourceName=clickTrainControl.getClickTrainProcess().getParentDataBlock().getDataName();
clickTrainControl.getClickTrainParams().dataSourceName=clickTrainControl.getClickTrainProcess().getParentDataBlock().getLongDataName();
}
else clickTrainControl.getClickTrainParams().dataSourceName="";
break;

View File

@ -94,7 +94,7 @@ public class CTSwingGUI extends PamControlledGUISwing {
@Override
public JMenuItem createDetectionMenu(Frame parentFrame) {
JMenu submenu = new JMenu("Click Train Detector");
JMenu submenu = new JMenu(clickTrainControl.getUnitName());
JMenuItem menuItem = new JMenuItem("Detection Settings ...");

View File

@ -408,7 +408,7 @@ public class ClickTrainAlgorithmPaneFX extends SettingsPane<ClickTrainParams> {
public ClickTrainParams getParams(ClickTrainParams currParams) {
try {
currParams.dataSourceIndex = sourcePane.getSourceIndex();
currParams.dataSourceName = sourcePane.getSourceName();
currParams.dataSourceName = sourcePane.getSourceLongName();
//use the data selector.
@ -511,7 +511,7 @@ public class ClickTrainAlgorithmPaneFX extends SettingsPane<ClickTrainParams> {
// and fill in the data source list (may have changed - or might in later versions)
ArrayList<PamDataBlock> rd = PamController.getInstance().getDataBlocks(ClickDetection.class, true);
PamDataBlock datablock = PamController.getInstance().getRawDataBlock(clickTrainParams.dataSourceName);
PamDataBlock datablock = PamController.getInstance().getDataBlockByLongName(clickTrainParams.dataSourceName);
//use the data selector.
dataSelectorCheckBox.setSelected(clickTrainParams.useDataSelector);

View File

@ -170,12 +170,17 @@ public class CTClassifierPane extends PamBorderPane {
// break;
// }
// }
classifierListBox.getSelectionModel().select(params.type);
setClassifierPane(params.type);
//species Id
setBasicParams(params);
// //when setting parameters have to figure out what pane to create first!
// currentClassifier = clickTrainControl.getClassifierManager().createClassifier(params.type);
// //Classifier pane
@ -197,7 +202,9 @@ public class CTClassifierPane extends PamBorderPane {
*/
private void setClassifierPane(CTClassifierType ctClassifierType) {
if (ctClassifierType==null) return;
currentClassifier = clickTrainControl.getClassifierManager().createClassifier(ctClassifierType);
//Classifier pane- this also sets parameters for the classifier specific pane
if (currentClassifier.getCTClassifierGraphics()!=null) {
settingsHolder.setCenter(currentClassifier.getCTClassifierGraphics().getCTClassifierPane());

View File

@ -228,6 +228,7 @@ public class CTClassifiersPane extends PamBorderPane {
//set the parameters.
tab = (ClassifierTab) pamTabPane.getTabs().get(i);
//set the parameters for the tab.
tab.getCTClassifierPane().setParams(clickTrainParams.ctClassifierParams[i]);
}

View File

@ -41,7 +41,7 @@ public class BearingClassifierGraphics implements CTClassifierGraphics {
bearingClassifierPane = new BearingClassifierPane(bearingClassifer);
}
//params are set here.
bearingClassifierPane.setParams(bearingClassifer.getParams());
//bearingClassifierPane.setParams(bearingClassifer.getParams()); <- warning - causes an error in which params are overriden
return (Pane) bearingClassifierPane.getContentNode();
}

View File

@ -105,7 +105,7 @@ public class BearingClassifierPane extends SettingsPane<BearingClassifierParams
currParams.minStdBearingD = Math.toRadians(params.min.doubleValue());
currParams.maxStdBearingD = Math.toRadians(params.max.doubleValue());
currParams.useStD = params.enabled;
return currParams;
}
@ -126,6 +126,7 @@ public class BearingClassifierPane extends SettingsPane<BearingClassifierParams
@Override
public void setParams(BearingClassifierParams input) {
//bearing limits
this.bearingLims.setParams(Math.toDegrees(input.bearingLimMin), Math.toDegrees(input.bearingLimMax), true);

View File

@ -366,7 +366,7 @@ public class CTDataSelectPanel implements PamDialogPanel {
return true;
}
catch (Exception e) {
e.printStackTrace();
// e.printStackTrace();
return false;
}
}

View File

@ -134,9 +134,12 @@ public abstract class SpectrumPlot <D extends PamDataUnit> implements Detection
this.sR=sR;
int[] minmax = getAxisMinMaxSamples(plotProjector);
if (minmax[1]>=data.getSampleDuration()) minmax[1]=(int) (data.getSampleDuration()-1);
if (data.getSampleDuration()!=null) {
if (minmax[1]>=data.getSampleDuration()) minmax[1]=(int) (data.getSampleDuration()-1);
}
if (minmax[0]<0 || minmax[0]>=minmax[1]) minmax[0]=0;
//System.out.println("Min max: " + minmax[0] + " " + minmax[1]);

View File

@ -14,7 +14,9 @@ import javax.swing.JCheckBoxMenuItem;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.JPopupMenu.Separator;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.JSeparator;
import javax.swing.SwingUtilities;
import PamView.PamSymbol;
@ -197,6 +199,12 @@ public class PamUtilsFX {
if (JMenuItem.class.isAssignableFrom(item.getClass())) {
itemList.add(swingMenuItemToFX( (JMenuItem) item));
}
else {
Component unkItem = item;
if (item instanceof Separator) {
// MenuItem mi = new Separator();
}
}
}
return itemList;
@ -300,6 +308,9 @@ public class PamUtilsFX {
radioItem.setSelected(((JRadioButtonMenuItem) swingItem).isSelected());
}
// else if (swingItem.getClass() == JSeparator.class) {
//
// }
if (fxItem == null) {
return null;
}