From ccd0fc796537e54f0ba8fc61f07f85adb800e41d Mon Sep 17 00:00:00 2001 From: m2oswald <45486636+m2oswald@users.noreply.github.com> Date: Mon, 14 Nov 2022 11:00:15 +0000 Subject: [PATCH] small updates to Rocca (#84) * allow Rocca to run without classifiers Fixed bug that threw an error if no classifier files were specified in Rocca Params dialog * add rocca switch to enable dev mode currently only shows/hides extra buttons in the Params dialog, but will extend to more options in the future --- .classpath | 2 +- .gitignore | 1 + src/pamguard/Pamguard.java | 8 +- src/rocca/RoccaClassifier.java | 251 ++++++++++++++------------- src/rocca/RoccaDev.java | 27 +++ src/rocca/RoccaParametersDialog.java | 18 +- 6 files changed, 174 insertions(+), 133 deletions(-) create mode 100644 src/rocca/RoccaDev.java diff --git a/.classpath b/.classpath index a5d40376..26c568d7 100644 --- a/.classpath +++ b/.classpath @@ -6,7 +6,7 @@ - + diff --git a/.gitignore b/.gitignore index 6df976a9..c9419840 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,4 @@ settings.xml .classpath .classpath .classpath +.classpath diff --git a/src/pamguard/Pamguard.java b/src/pamguard/Pamguard.java index f6865503..4a142c0b 100644 --- a/src/pamguard/Pamguard.java +++ b/src/pamguard/Pamguard.java @@ -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."); diff --git a/src/rocca/RoccaClassifier.java b/src/rocca/RoccaClassifier.java index fe699137..20acb872 100644 --- a/src/rocca/RoccaClassifier.java +++ b/src/rocca/RoccaClassifier.java @@ -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