mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-25 08:32:32 +00:00
commit
49f7bb6094
@ -6,7 +6,7 @@
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/Java 17">
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -39,3 +39,4 @@ settings.xml
|
||||
.classpath
|
||||
.classpath
|
||||
.classpath
|
||||
.classpath
|
||||
|
@ -23,17 +23,14 @@ package pamguard;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.UIManager;
|
||||
|
||||
import Acquisition.AcquisitionControl;
|
||||
import Acquisition.FolderInputSystem;
|
||||
import PamController.PamController;
|
||||
import PamController.PamGUIManager;
|
||||
import PamController.PamSettingManager;
|
||||
import PamController.PamguardVersionInfo;
|
||||
import PamController.pamBuoyGlobals;
|
||||
import PamController.command.TerminalController;
|
||||
import PamModel.SMRUEnable;
|
||||
import PamUtils.FileFunctions;
|
||||
import PamUtils.PamCalendar;
|
||||
import PamUtils.PamExceptionHandler;
|
||||
import PamUtils.PlatformInfo;
|
||||
import PamUtils.Splash;
|
||||
@ -45,6 +42,7 @@ import PamguardMVC.debug.Debug;
|
||||
import binaryFileStorage.BinaryStore;
|
||||
import dataPlotsFX.JamieDev;
|
||||
import generalDatabase.DBControl;
|
||||
import rocca.RoccaDev;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
@ -190,6 +188,10 @@ public class Pamguard {
|
||||
JamieDev.setEnabled(true);
|
||||
System.out.println("Enabling Jamie Macaulay modifications.");
|
||||
}
|
||||
else if (anArg.equalsIgnoreCase("-rocca")) {
|
||||
RoccaDev.setEnabled(true);
|
||||
System.out.println("Enabling Rocca development mode");
|
||||
}
|
||||
else if (anArg.equalsIgnoreCase(Debug.flag)) {
|
||||
Debug.setPrintDebug(true);
|
||||
Debug.out.println("Enabling debug terminal output.");
|
||||
|
@ -408,92 +408,102 @@ public class RoccaClassifier {
|
||||
|
||||
// load the whistle classifier
|
||||
if (roccaControl.roccaParameters.isClassifyWhistles()) {
|
||||
String fname = roccaControl.roccaParameters.roccaClassifierModelFilename.getAbsolutePath();
|
||||
File f = new File(fname);
|
||||
if (f.exists() == false) {
|
||||
WarnOnce.showWarning(roccaControl.getUnitName(), "Rocca whistle classifier file cannot be found at " + fname, WarnOnce.WARNING_MESSAGE);
|
||||
roccaControl.roccaParameters.setClassifyWhistles(false);
|
||||
}
|
||||
else {
|
||||
try {
|
||||
BufferedInputStream input = new BufferedInputStream(
|
||||
(new ProgressMonitorInputStream(null, "Loading Whistle Classifier - Please wait",
|
||||
new FileInputStream(fname))));
|
||||
Object[] modelParams = SerializationHelper.readAll(input);
|
||||
// separate the classifier model from the training dataset info
|
||||
// roccaClassifierModel = (AbstractClassifier) modelParams[0];
|
||||
// trainedDataset = (Instances) modelParams[1];
|
||||
|
||||
// there are 2 different styles of model file, the original version and the version
|
||||
// developed for the 2-stage classifier. Both files contain 2 objects.
|
||||
// The original version contained the classifier and the training dataset. The newer
|
||||
// version contains a String description and the classifier. Test the first object;
|
||||
// if it's a String, then this is the newer version and the String is the description.
|
||||
// If it's not a String, assume this is the old version and create a RoccaRFModel
|
||||
// object from the file contents.
|
||||
if (modelParams[0] instanceof String) {
|
||||
modelList = (RoccaRFModel) modelParams[1];
|
||||
} else {
|
||||
AbstractClassifier classifier = (AbstractClassifier) modelParams[0];
|
||||
Instances dataset = (Instances) modelParams[1];
|
||||
RoccaRFModel[] models = new RoccaRFModel[dataset.numClasses()];
|
||||
for (int i=0; i<dataset.numClasses(); i++) {
|
||||
models[i]=null;
|
||||
}
|
||||
modelList = new RoccaRFModel(classifier, dataset, models);
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
System.err.println("Deserialization of Whistle Classifier failed: " + ex.getMessage());
|
||||
ex.printStackTrace();
|
||||
roccaControl.roccaParameters.setClassifyWhistles(false);
|
||||
}
|
||||
}
|
||||
if (roccaControl.roccaParameters.roccaClassifierModelFilename==null) {
|
||||
roccaControl.roccaParameters.setClassifyWhistles(false);
|
||||
}
|
||||
else {
|
||||
String fname = roccaControl.roccaParameters.roccaClassifierModelFilename.getAbsolutePath();
|
||||
File f = new File(fname);
|
||||
if (f.exists() == false) {
|
||||
WarnOnce.showWarning(roccaControl.getUnitName(), "Rocca whistle classifier file cannot be found at " + fname, WarnOnce.WARNING_MESSAGE);
|
||||
roccaControl.roccaParameters.setClassifyWhistles(false);
|
||||
}
|
||||
else {
|
||||
try {
|
||||
BufferedInputStream input = new BufferedInputStream(
|
||||
(new ProgressMonitorInputStream(null, "Loading Whistle Classifier - Please wait",
|
||||
new FileInputStream(fname))));
|
||||
Object[] modelParams = SerializationHelper.readAll(input);
|
||||
// separate the classifier model from the training dataset info
|
||||
// roccaClassifierModel = (AbstractClassifier) modelParams[0];
|
||||
// trainedDataset = (Instances) modelParams[1];
|
||||
|
||||
// there are 2 different styles of model file, the original version and the version
|
||||
// developed for the 2-stage classifier. Both files contain 2 objects.
|
||||
// The original version contained the classifier and the training dataset. The newer
|
||||
// version contains a String description and the classifier. Test the first object;
|
||||
// if it's a String, then this is the newer version and the String is the description.
|
||||
// If it's not a String, assume this is the old version and create a RoccaRFModel
|
||||
// object from the file contents.
|
||||
if (modelParams[0] instanceof String) {
|
||||
modelList = (RoccaRFModel) modelParams[1];
|
||||
} else {
|
||||
AbstractClassifier classifier = (AbstractClassifier) modelParams[0];
|
||||
Instances dataset = (Instances) modelParams[1];
|
||||
RoccaRFModel[] models = new RoccaRFModel[dataset.numClasses()];
|
||||
for (int i=0; i<dataset.numClasses(); i++) {
|
||||
models[i]=null;
|
||||
}
|
||||
modelList = new RoccaRFModel(classifier, dataset, models);
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
System.err.println("Deserialization of Whistle Classifier failed: " + ex.getMessage());
|
||||
ex.printStackTrace();
|
||||
roccaControl.roccaParameters.setClassifyWhistles(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// serialVersionUID=24 2016/08/10 added to load click classifier
|
||||
if (roccaControl.roccaParameters.isClassifyClicks()) {
|
||||
String fname = roccaControl.roccaParameters.roccaClickClassifierModelFilename.getAbsolutePath();
|
||||
File f = new File(fname);
|
||||
if (f.exists() == false) {
|
||||
WarnOnce.showWarning(roccaControl.getUnitName(), "Rocca click classifier file cannot be found at " + fname, WarnOnce.WARNING_MESSAGE);
|
||||
roccaControl.roccaParameters.setClassifyClicks(false);
|
||||
}
|
||||
else {
|
||||
try {
|
||||
BufferedInputStream input = new BufferedInputStream(
|
||||
(new ProgressMonitorInputStream(null, "Loading Click Classifier - Please wait",
|
||||
new FileInputStream(fname))));
|
||||
Object[] modelParams = SerializationHelper.readAll(input);
|
||||
// separate the classifier model from the training dataset info
|
||||
// roccaClassifierModel = (AbstractClassifier) modelParams[0];
|
||||
// trainedDataset = (Instances) modelParams[1];
|
||||
|
||||
// there are 2 different styles of model file, the original version and the version
|
||||
// developed for the 2-stage classifier. Both files contain 2 objects.
|
||||
// The original version contained the classifier and the training dataset. The newer
|
||||
// version contains a String description and the classifier. Test the first object;
|
||||
// if it's a String, then this is the newer version and the String is the description.
|
||||
// If it's not a String, assume this is the old version and create a RoccaRFModel
|
||||
// object from the file contents.
|
||||
if (modelParams[0] instanceof String) {
|
||||
clickModelList = (RoccaRFModel) modelParams[1];
|
||||
} else {
|
||||
AbstractClassifier classifier = (AbstractClassifier) modelParams[0];
|
||||
Instances dataset = (Instances) modelParams[1];
|
||||
RoccaRFModel[] models = new RoccaRFModel[dataset.numClasses()];
|
||||
for (int i=0; i<dataset.numClasses(); i++) {
|
||||
models[i]=null;
|
||||
}
|
||||
clickModelList = new RoccaRFModel(classifier, dataset, models);
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
System.err.println("Deserialization of Click Classifier failed: " + ex.getMessage());
|
||||
ex.printStackTrace();
|
||||
roccaControl.roccaParameters.setClassifyClicks(false);
|
||||
}
|
||||
if (roccaControl.roccaParameters.roccaClickClassifierModelFilename==null) {
|
||||
roccaControl.roccaParameters.setClassifyClicks(false);
|
||||
}
|
||||
else {
|
||||
String fname = roccaControl.roccaParameters.roccaClickClassifierModelFilename.getAbsolutePath();
|
||||
File f = new File(fname);
|
||||
if (f.exists() == false) {
|
||||
WarnOnce.showWarning(roccaControl.getUnitName(), "Rocca click classifier file cannot be found at " + fname, WarnOnce.WARNING_MESSAGE);
|
||||
roccaControl.roccaParameters.setClassifyClicks(false);
|
||||
}
|
||||
else {
|
||||
try {
|
||||
BufferedInputStream input = new BufferedInputStream(
|
||||
(new ProgressMonitorInputStream(null, "Loading Click Classifier - Please wait",
|
||||
new FileInputStream(fname))));
|
||||
Object[] modelParams = SerializationHelper.readAll(input);
|
||||
// separate the classifier model from the training dataset info
|
||||
// roccaClassifierModel = (AbstractClassifier) modelParams[0];
|
||||
// trainedDataset = (Instances) modelParams[1];
|
||||
|
||||
// there are 2 different styles of model file, the original version and the version
|
||||
// developed for the 2-stage classifier. Both files contain 2 objects.
|
||||
// The original version contained the classifier and the training dataset. The newer
|
||||
// version contains a String description and the classifier. Test the first object;
|
||||
// if it's a String, then this is the newer version and the String is the description.
|
||||
// If it's not a String, assume this is the old version and create a RoccaRFModel
|
||||
// object from the file contents.
|
||||
if (modelParams[0] instanceof String) {
|
||||
clickModelList = (RoccaRFModel) modelParams[1];
|
||||
} else {
|
||||
AbstractClassifier classifier = (AbstractClassifier) modelParams[0];
|
||||
Instances dataset = (Instances) modelParams[1];
|
||||
RoccaRFModel[] models = new RoccaRFModel[dataset.numClasses()];
|
||||
for (int i=0; i<dataset.numClasses(); i++) {
|
||||
models[i]=null;
|
||||
}
|
||||
clickModelList = new RoccaRFModel(classifier, dataset, models);
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
System.err.println("Deserialization of Click Classifier failed: " + ex.getMessage());
|
||||
ex.printStackTrace();
|
||||
roccaControl.roccaParameters.setClassifyClicks(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if we didn't load either classifier, don't bother loading trying to load an encounter
|
||||
@ -505,43 +515,48 @@ public class RoccaClassifier {
|
||||
|
||||
// serialVersionUID=24 2016/08/10 added to load event classifier
|
||||
if (roccaControl.roccaParameters.isClassifyEvents()) {
|
||||
String fname = roccaControl.roccaParameters.roccaEventClassifierModelFilename.getAbsolutePath();
|
||||
File f = new File(fname);
|
||||
if (f.exists() == false) {
|
||||
WarnOnce.showWarning(roccaControl.getUnitName(), "Rocca events classifier file cannot be found at " + fname, WarnOnce.WARNING_MESSAGE);
|
||||
roccaControl.roccaParameters.setClassifyEvents(false);
|
||||
}
|
||||
else {
|
||||
try {
|
||||
BufferedInputStream input = new BufferedInputStream(
|
||||
(new ProgressMonitorInputStream(null, "Loading Event Classifier - Please wait",
|
||||
new FileInputStream(fname))));
|
||||
Object[] modelParams = SerializationHelper.readAll(input);
|
||||
|
||||
// there are 2 different styles of model file, the original version and the version
|
||||
// developed for the 2-stage classifier. Both files contain 2 objects.
|
||||
// The original version contained the classifier and the training dataset. The newer
|
||||
// version contains a String description and the classifier. Test the first object;
|
||||
// if it's a String, then this is the newer version and the String is the description.
|
||||
// If it's not a String, assume this is the old version and create a RoccaRFModel
|
||||
// object from the file contents.
|
||||
if (modelParams[0] instanceof String) {
|
||||
eventModelList = (RoccaRFModel) modelParams[1];
|
||||
} else {
|
||||
AbstractClassifier classifier = (AbstractClassifier) modelParams[0];
|
||||
Instances dataset = (Instances) modelParams[1];
|
||||
RoccaRFModel[] models = new RoccaRFModel[dataset.numClasses()];
|
||||
for (int i=0; i<dataset.numClasses(); i++) {
|
||||
models[i]=null;
|
||||
}
|
||||
eventModelList = new RoccaRFModel(classifier, dataset, models);
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
System.err.println("Deserialization of Event Classifier failed: " + ex.getMessage());
|
||||
roccaControl.roccaParameters.setClassifyEvents(false);
|
||||
}
|
||||
}
|
||||
if (roccaControl.roccaParameters.roccaEventClassifierModelFilename==null) {
|
||||
roccaControl.roccaParameters.setClassifyEvents(false);
|
||||
}
|
||||
else {
|
||||
String fname = roccaControl.roccaParameters.roccaEventClassifierModelFilename.getAbsolutePath();
|
||||
File f = new File(fname);
|
||||
if (f.exists() == false) {
|
||||
WarnOnce.showWarning(roccaControl.getUnitName(), "Rocca events classifier file cannot be found at " + fname, WarnOnce.WARNING_MESSAGE);
|
||||
roccaControl.roccaParameters.setClassifyEvents(false);
|
||||
}
|
||||
else {
|
||||
try {
|
||||
BufferedInputStream input = new BufferedInputStream(
|
||||
(new ProgressMonitorInputStream(null, "Loading Event Classifier - Please wait",
|
||||
new FileInputStream(fname))));
|
||||
Object[] modelParams = SerializationHelper.readAll(input);
|
||||
|
||||
// there are 2 different styles of model file, the original version and the version
|
||||
// developed for the 2-stage classifier. Both files contain 2 objects.
|
||||
// The original version contained the classifier and the training dataset. The newer
|
||||
// version contains a String description and the classifier. Test the first object;
|
||||
// if it's a String, then this is the newer version and the String is the description.
|
||||
// If it's not a String, assume this is the old version and create a RoccaRFModel
|
||||
// object from the file contents.
|
||||
if (modelParams[0] instanceof String) {
|
||||
eventModelList = (RoccaRFModel) modelParams[1];
|
||||
} else {
|
||||
AbstractClassifier classifier = (AbstractClassifier) modelParams[0];
|
||||
Instances dataset = (Instances) modelParams[1];
|
||||
RoccaRFModel[] models = new RoccaRFModel[dataset.numClasses()];
|
||||
for (int i=0; i<dataset.numClasses(); i++) {
|
||||
models[i]=null;
|
||||
}
|
||||
eventModelList = new RoccaRFModel(classifier, dataset, models);
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
System.err.println("Deserialization of Event Classifier failed: " + ex.getMessage());
|
||||
roccaControl.roccaParameters.setClassifyEvents(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resetSidePanel();
|
||||
|
27
src/rocca/RoccaDev.java
Normal file
27
src/rocca/RoccaDev.java
Normal file
@ -0,0 +1,27 @@
|
||||
package rocca;
|
||||
|
||||
/**
|
||||
* Global flag set at runtime for Rocca development flags.
|
||||
* @author mo55
|
||||
*
|
||||
*/
|
||||
public class RoccaDev {
|
||||
|
||||
|
||||
private static boolean enabled = false;
|
||||
|
||||
/**
|
||||
* @return the enabled
|
||||
*/
|
||||
public static boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param enabled the enabled to set
|
||||
*/
|
||||
public static void setEnabled(boolean enabled) {
|
||||
RoccaDev.enabled = enabled;
|
||||
}
|
||||
|
||||
}
|
@ -26,7 +26,6 @@ import java.awt.Frame;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.Point;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
import java.util.Vector;
|
||||
@ -48,8 +47,6 @@ import PamUtils.PamFileChooser;
|
||||
import PamView.dialog.PamDialog;
|
||||
import PamView.dialog.SourcePanel;
|
||||
import PamguardMVC.PamDataBlock;
|
||||
import PamguardMVC.PamDataUnit;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Insets;
|
||||
import java.awt.event.ActionEvent;
|
||||
@ -60,20 +57,14 @@ import java.io.BufferedInputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.GroupLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JScrollPane;
|
||||
@ -87,7 +78,6 @@ import javax.swing.border.EtchedBorder;
|
||||
import clickDetector.ClickControl;
|
||||
import clickDetector.ClickDetection;
|
||||
import clickDetector.NoiseDataBlock;
|
||||
import weka.classifiers.AbstractClassifier;
|
||||
import weka.core.Attribute;
|
||||
import weka.core.Instances;
|
||||
import weka.core.SerializationHelper;
|
||||
@ -523,7 +513,13 @@ public class RoccaParametersDialog extends PamDialog implements ActionListener,
|
||||
reclassifyButton.addActionListener(this);
|
||||
reclassifyButton.setToolTipText("Load the whistle data from the contour stats output file, and run it through the current Classifier");
|
||||
reclassifyButton.setVisible(true);
|
||||
extraButtonsSubPanel.setVisible(true); // ******** THIS LINES CONTROLS THE VISIBILITY ********
|
||||
|
||||
// ******** THIS LINES CONTROLS THE VISIBILITY ********
|
||||
if (RoccaDev.isEnabled()) {
|
||||
extraButtonsSubPanel.setVisible(true);
|
||||
} else {
|
||||
extraButtonsSubPanel.setVisible(false);
|
||||
}
|
||||
GroupLayout extraPanelLayout = new GroupLayout(extraButtonsSubPanel);
|
||||
extraButtonsSubPanel.setLayout(extraPanelLayout);
|
||||
extraPanelLayout.setAutoCreateGaps(true);
|
||||
|
Loading…
Reference in New Issue
Block a user