diff --git a/.gitignore b/.gitignore index a2ea3fcc..63858ec4 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ *.nar *.ear *.zip +!src/test/**/*.zip *.tar.gz *.rar *.dll @@ -37,6 +38,10 @@ bin/ .classpath target/WMM.COF +# IntellIJ +.idea + +# Eclipse settings.xml .classpath .classpath diff --git a/pom.xml b/pom.xml index 486850bb..9fb221b8 100644 --- a/pom.xml +++ b/pom.xml @@ -182,7 +182,15 @@ --> - + + + maven-surefire-plugin + 3.5.1 + + false + + + - @@ -325,16 +332,6 @@ https://nexus.bedatadriven.com/content/groups/public/ - - - - false - - talan - talan - https://nexus.talanlabs.com/content/repositories/releases/ - - central https://repo1.maven.org/maven2 @@ -344,6 +341,17 @@ + + + + org.junit + junit-bom + 5.11.3 + pom + import + + + @@ -351,6 +359,13 @@ io.github.macster110 jpamutils 0.0.59d + + + + org.junit.platform + junit-platform-surefire-provider + + @@ -1049,5 +1064,11 @@ + + + org.junit.jupiter + junit-jupiter + test + \ No newline at end of file diff --git a/src/PamController/soundMedium/GlobalMedium.java b/src/PamController/soundMedium/GlobalMedium.java index 7aaacaf2..1c18c4cd 100644 --- a/src/PamController/soundMedium/GlobalMedium.java +++ b/src/PamController/soundMedium/GlobalMedium.java @@ -200,6 +200,50 @@ public class GlobalMedium { return zString; } + /** + * Get a string description of the dB reference for a power spectral density. + * @param currentMedium - the current medium. + * @return string of dB reference + */ + public static String getdBPSDString(SoundMedium currentMedium) { + String zString; + switch (currentMedium) { + case Air: + zString = "dB re 400\u00B5Pa\u00B2/Hz"; + break; + case Water: + zString = "dB re 1\u00B5Pa\u00B2/Hz"; + break; + default: + zString = "dB re 1\u00B5Pa\u00B2/Hz"; + break; + } + + return zString; + } + + /** + * Get a string description of the dB reference for a sound exposure level. + * @param currentMedium - the current medium. + * @return string of dB reference + */ + public static String getdBSELString(SoundMedium currentMedium) { + String zString; + switch (currentMedium) { + case Air: + zString = "dB re 400\u00B5Pa\u00B2s"; + break; + case Water: + zString = "dB re 1\u00B5Pa\u00B2s"; + break; + default: + zString = "dB re 1\u00B5Pa\u00B2s"; + break; + } + + return zString; + } + /** * Get the z coefficient value for displays. Height are always stored so * that +z points up (i.e. -g). In display height is input as depth as so must diff --git a/src/PamController/soundMedium/GlobalMediumManager.java b/src/PamController/soundMedium/GlobalMediumManager.java index 2fff40d5..267e10e1 100644 --- a/src/PamController/soundMedium/GlobalMediumManager.java +++ b/src/PamController/soundMedium/GlobalMediumManager.java @@ -136,6 +136,21 @@ public class GlobalMediumManager implements PamSettings { return GlobalMedium.getdBRefString(globalMediumParams.currentMedium); } + /** + * Get the string for the default dB reference unit for power spectral density e.g. dB re 1uPa^2/Hz. + * @return the string for dB values. + */ + public String getdBPSDString() { + return GlobalMedium.getdBPSDString(globalMediumParams.currentMedium); + } + + /** + * Get the string for the default dB reference unit for power spectral density e.g. dB re 1uPa^2/Hz. + * @return the string for dB values. + */ + public String getdBSELString() { + return GlobalMedium.getdBSELString(globalMediumParams.currentMedium); + } /** * Get the height coefficient value for displays. Heights are always stored so diff --git a/src/Spectrogram/SpectrogramDisplay.java b/src/Spectrogram/SpectrogramDisplay.java index ba6230b8..da718df8 100644 --- a/src/Spectrogram/SpectrogramDisplay.java +++ b/src/Spectrogram/SpectrogramDisplay.java @@ -809,7 +809,7 @@ InternalFrameListener, DisplayPanelContainer, SpectrogramParametersUser, PamSett createColours(); timeAxis = new PamAxis(10, 0, imageWidth, 0, 0, - spectrogramParameters.displayLength, true, "seconds", "%3.1f"); + spectrogramParameters.displayLength, true, "Time (s)", "%3.1f"); spectrogramAxis.setNorthAxis(timeAxis); if (rangeSpinner != null) { @@ -817,13 +817,15 @@ InternalFrameListener, DisplayPanelContainer, SpectrogramParametersUser, PamSett } double fScale = 1; + String westLabel = "Frequency (Hz)"; if (spectrogramParameters.frequencyLimits[1] > 2000) { fScale = 1000; + westLabel = "Frequency (kHz)"; } frequencyAxis = new PamAxis(0, 200, 0, 10, spectrogramParameters.frequencyLimits[0] / fScale, - spectrogramParameters.frequencyLimits[1] / fScale, true, "", + spectrogramParameters.frequencyLimits[1] / fScale, true, westLabel, null); frequencyAxis.setFractionalScale(true); frequencyAxis.setCrampLabels(true); @@ -1696,9 +1698,11 @@ InternalFrameListener, DisplayPanelContainer, SpectrogramParametersUser, PamSett // setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 10)); setLayout(new BorderLayout()); add(new AmplitudeBar(), BorderLayout.CENTER); + + String label = String.format("PSD (%s)", PamController.getInstance().getGlobalMediumManager().getdBPSDString()); amplitudeAxis = new PamAxis(0, 200, 0, 10, spectrogramParameters.amplitudeLimits[0], - spectrogramParameters.amplitudeLimits[1], false, "", "%3.0f"); + spectrogramParameters.amplitudeLimits[1], false, label, "%3.0f"); setEastAxis(amplitudeAxis); } diff --git a/src/annotation/DataAnnotationType.java b/src/annotation/DataAnnotationType.java index e212e73b..a86d4df1 100644 --- a/src/annotation/DataAnnotationType.java +++ b/src/annotation/DataAnnotationType.java @@ -21,7 +21,7 @@ import generalDatabase.SQLLoggingAddon; * @see SoloAnnotationType * */ -public abstract class DataAnnotationType { +public abstract class DataAnnotationType> { public abstract String getAnnotationName(); diff --git a/src/annotation/dataselect/AnnotationDataSelCreator.java b/src/annotation/dataselect/AnnotationDataSelCreator.java index 539f0262..78b3af3e 100644 --- a/src/annotation/dataselect/AnnotationDataSelCreator.java +++ b/src/annotation/dataselect/AnnotationDataSelCreator.java @@ -5,7 +5,7 @@ import PamguardMVC.dataSelector.DataSelectorCreator; import annotation.DataAnnotation; import annotation.DataAnnotationType; -public abstract class AnnotationDataSelCreator extends DataSelectorCreator { +public abstract class AnnotationDataSelCreator> extends DataSelectorCreator { private DataAnnotationType dataAnnotationType; diff --git a/src/annotation/dataselect/AnnotationDataSelector.java b/src/annotation/dataselect/AnnotationDataSelector.java index 0c0a0320..3cc6cf34 100644 --- a/src/annotation/dataselect/AnnotationDataSelector.java +++ b/src/annotation/dataselect/AnnotationDataSelector.java @@ -7,7 +7,7 @@ import PamguardMVC.dataSelector.DataSelector; import annotation.DataAnnotation; import annotation.DataAnnotationType; -public abstract class AnnotationDataSelector extends DataSelector { +public abstract class AnnotationDataSelector> extends DataSelector { private DataAnnotationType annotationType; diff --git a/src/annotation/dataselect/ScalarDataSelector.java b/src/annotation/dataselect/ScalarDataSelector.java index 7e1566dd..e8c1a313 100644 --- a/src/annotation/dataselect/ScalarDataSelector.java +++ b/src/annotation/dataselect/ScalarDataSelector.java @@ -8,7 +8,7 @@ import annotation.DataAnnotation; import annotation.DataAnnotationType; import pamViewFX.fxSettingsPanes.DynamicSettingsPane; -public abstract class ScalarDataSelector extends AnnotationDataSelector { +public abstract class ScalarDataSelector> extends AnnotationDataSelector { /** * @return the scalarDataParams diff --git a/src/annotation/string/StringAnnotation.java b/src/annotation/string/StringAnnotation.java index e0613c86..31d99396 100644 --- a/src/annotation/string/StringAnnotation.java +++ b/src/annotation/string/StringAnnotation.java @@ -3,11 +3,11 @@ package annotation.string; import annotation.DataAnnotation; import annotation.DataAnnotationType; -public class StringAnnotation extends DataAnnotation { +public class StringAnnotation> extends DataAnnotation { private String string; - public StringAnnotation(DataAnnotationType dataAnnotationType) { + public StringAnnotation(T dataAnnotationType) { super(dataAnnotationType); } diff --git a/src/annotation/string/StringAnnotationType.java b/src/annotation/string/StringAnnotationType.java index 2dfd19d8..d9ec1e44 100644 --- a/src/annotation/string/StringAnnotationType.java +++ b/src/annotation/string/StringAnnotationType.java @@ -13,7 +13,7 @@ import annotation.handler.AnnotationOptions; * @author Doug Gillespie * */ -public class StringAnnotationType extends DataAnnotationType { +public class StringAnnotationType extends DataAnnotationType> { private String annotationName; private StringSQLLogging sqlAddon; diff --git a/src/annotation/timestamp/TimestampAnnotation.java b/src/annotation/timestamp/TimestampAnnotation.java index 9960a013..07e5d6e8 100644 --- a/src/annotation/timestamp/TimestampAnnotation.java +++ b/src/annotation/timestamp/TimestampAnnotation.java @@ -4,11 +4,11 @@ import PamUtils.PamCalendar; import annotation.DataAnnotation; import annotation.DataAnnotationType; -public class TimestampAnnotation extends DataAnnotation { +public class TimestampAnnotation> extends DataAnnotation { private long timestamp; - public TimestampAnnotation(DataAnnotationType dataAnnotationType) { + public TimestampAnnotation(T dataAnnotationType) { super(dataAnnotationType); } diff --git a/src/annotation/timestamp/TimestampAnnotationType.java b/src/annotation/timestamp/TimestampAnnotationType.java index ab90ad0c..8f49378a 100644 --- a/src/annotation/timestamp/TimestampAnnotationType.java +++ b/src/annotation/timestamp/TimestampAnnotationType.java @@ -12,7 +12,7 @@ import annotation.DataAnnotationType; * @author Doug Gillespie * */ -public class TimestampAnnotationType extends DataAnnotationType { +public class TimestampAnnotationType extends DataAnnotationType> { private String annotationName; private TimestampSQLLogging sqlAddon; diff --git a/src/annotation/userforms/UserFormAnnotation.java b/src/annotation/userforms/UserFormAnnotation.java index 362a29ad..187b5286 100644 --- a/src/annotation/userforms/UserFormAnnotation.java +++ b/src/annotation/userforms/UserFormAnnotation.java @@ -3,14 +3,14 @@ package annotation.userforms; import annotation.DataAnnotation; import annotation.DataAnnotationType; -public class UserFormAnnotation extends DataAnnotation { +public class UserFormAnnotation> extends DataAnnotation { /** * Data extracted from the logger form. */ private Object[] loggerFormData; - public UserFormAnnotation(DataAnnotationType dataAnnotationType, Object[] loggerFormData) { + public UserFormAnnotation(T dataAnnotationType, Object[] loggerFormData) { super(dataAnnotationType); this.setLoggerFormData(loggerFormData); } diff --git a/src/annotation/userforms/UserFormAnnotationType.java b/src/annotation/userforms/UserFormAnnotationType.java index 1cfe5573..61a15a05 100644 --- a/src/annotation/userforms/UserFormAnnotationType.java +++ b/src/annotation/userforms/UserFormAnnotationType.java @@ -17,7 +17,7 @@ import loggerForms.FormDescription; import loggerForms.FormsControl; import loggerForms.LoggerForm; -public class UserFormAnnotationType extends DataAnnotationType { +public class UserFormAnnotationType extends DataAnnotationType> { private UserFormAnnotationOptions userFormAnnotationOptions; @@ -201,7 +201,7 @@ public class UserFormAnnotationType extends DataAnnotationType getBinaryHandler() { + public AnnotationBinaryHandler> getBinaryHandler() { if (userFormBinaryHandler == null) { synchronized (this) { if (userFormBinaryHandler == null) { diff --git a/src/dbht/DbHtDisplayDialog.java b/src/dbht/DbHtDisplayDialog.java index b7178542..36d8204f 100644 --- a/src/dbht/DbHtDisplayDialog.java +++ b/src/dbht/DbHtDisplayDialog.java @@ -42,7 +42,7 @@ public class DbHtDisplayDialog extends PamDialog { mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); JPanel scalePanel = new JPanel(new GridBagLayout()); - scalePanel.setBorder(new TitledBorder("Amlitude Scale")); + scalePanel.setBorder(new TitledBorder("Amplitude Scale")); GridBagConstraints c = new PamGridBagContraints(); c.gridwidth = 3; addComponent(scalePanel, showGrid = new JCheckBox("Show Grid"), c); diff --git a/src/export/MLExport/MLCPODExport.java b/src/export/MLExport/MLCPODExport.java index b2f84757..44b69bb6 100644 --- a/src/export/MLExport/MLCPODExport.java +++ b/src/export/MLExport/MLCPODExport.java @@ -16,7 +16,7 @@ import us.hebi.matlab.mat.types.Struct; * @author Jamie Macaulay * */ -public class MLCPODExport extends MLDataUnitExport{ +public class MLCPODExport extends MLDataUnitExport>{ @Override public Struct addDetectionSpecificFields(Struct mlStruct, int index, PamDataUnit dataUnit) { diff --git a/src/export/MLExport/MLRawExport.java b/src/export/MLExport/MLRawExport.java index bdc3df72..f03d2769 100644 --- a/src/export/MLExport/MLRawExport.java +++ b/src/export/MLExport/MLRawExport.java @@ -14,7 +14,7 @@ import us.hebi.matlab.mat.types.Struct; * @author Jamie Macaulay * */ -public class MLRawExport extends MLDataUnitExport{ +public class MLRawExport extends MLDataUnitExport>{ @Override public Struct addDetectionSpecificFields(Struct mlStruct, int index, PamDataUnit dataUnit) { diff --git a/src/export/RExport/RCPODExport.java b/src/export/RExport/RCPODExport.java index 8501007c..1a1ba850 100644 --- a/src/export/RExport/RCPODExport.java +++ b/src/export/RExport/RCPODExport.java @@ -10,7 +10,7 @@ import cpod.CPODClick; import export.MLExport.MLCPODExport; -public class RCPODExport extends RDataUnitExport { +public class RCPODExport extends RDataUnitExport> { @Override public NamedBuilder addDetectionSpecificFields(NamedBuilder rData, PamDataUnit dataUnit, int index) { diff --git a/src/export/RExport/RRawExport.java b/src/export/RExport/RRawExport.java index e099abe1..9d9e1b1b 100644 --- a/src/export/RExport/RRawExport.java +++ b/src/export/RExport/RRawExport.java @@ -10,7 +10,7 @@ import org.renjin.sexp.ListVector.NamedBuilder; import clickDetector.ClickDetection; -public class RRawExport extends RDataUnitExport { +public class RRawExport extends RDataUnitExport> { @Override public NamedBuilder addDetectionSpecificFields(NamedBuilder rData, PamDataUnit dataUnit, int index) { diff --git a/src/export/wavExport/RawHolderWavExport.java b/src/export/wavExport/RawHolderWavExport.java index 181aee3a..a9fbe31e 100644 --- a/src/export/wavExport/RawHolderWavExport.java +++ b/src/export/wavExport/RawHolderWavExport.java @@ -9,7 +9,7 @@ import clickDetector.ClickDetection; * @author Jamie Macaulay * */ -public class RawHolderWavExport extends WavDataUnitExport { +public class RawHolderWavExport extends WavDataUnitExport> { @Override public double[][] getWavClip(PamDataUnit dataUnit) { diff --git a/src/fftManager/FFTPluginPanelProvider.java b/src/fftManager/FFTPluginPanelProvider.java index 66dc07a4..2c0daa1b 100644 --- a/src/fftManager/FFTPluginPanelProvider.java +++ b/src/fftManager/FFTPluginPanelProvider.java @@ -136,7 +136,8 @@ public class FFTPluginPanelProvider implements DisplayPanelProvider { isViewer = PamController.getInstance().getRunMode() == PamController.RUN_PAMVIEW; setupPanel(); - westAxis = new PamAxis(0, 0, 1, 1, getScaleMin(), getScaleMax(), true, "dB", "%.0f"); + String label = String.format("PSD (%s)", PamController.getInstance().getGlobalMediumManager().getdBPSDString()); + westAxis = new PamAxis(0, 0, 1, 1, getScaleMin(), getScaleMax(), true, label, "%.0f"); westAxis.setInterval(20); //southAxis = new PamAxis(0, 0, 10, 10, 0, pamFFTProcess.getSampleRate()/2/1000, true, "kHz", "%.0f"); southAxis = new PamAxis(0, 0, 1, 1, 0, fftDataBlock.getSampleRate()/2/1000, false, "kHz", "%.0f"); diff --git a/src/noiseOneBand/OneBandControl.java b/src/noiseOneBand/OneBandControl.java index c4082534..2a7ec3e3 100644 --- a/src/noiseOneBand/OneBandControl.java +++ b/src/noiseOneBand/OneBandControl.java @@ -10,11 +10,8 @@ import javax.swing.JButton; import javax.swing.JMenuItem; import javax.swing.JPanel; -import PamController.PamControlledUnit; -import PamController.PamControlledUnitSettings; -import PamController.PamControllerInterface; -import PamController.PamSettingManager; -import PamController.PamSettings; +import PamController.*; +import PamController.soundMedium.GlobalMediumManager; import PamView.PamTabPanel; import noiseOneBand.offline.OneBandSummaryTask; import offlineProcessing.DataCopyTask; @@ -22,13 +19,16 @@ import offlineProcessing.OLProcessDialog; import offlineProcessing.OfflineTaskGroup; public class OneBandControl extends PamControlledUnit implements PamSettings { - + /** + * The number of measures taken by {@link OneBandControl}. + * See {@link OneBandControl#getMeasurementName(int)} for description and units of each measure. + */ public static final int NMEASURES = 4; - public static final String[] measureNames = {"RMS", "0-Peak", "Peak-Peak", "Integrated SEL"}; - private OneBandProcess oneBandProcess; - private OneBandPulseProcess pulseProcess; + + private final OneBandProcess oneBandProcess; + private final OneBandPulseProcess pulseProcess; protected OneBandParameters oneBandParameters = new OneBandParameters(); - private OneBandTabPanel dBHtTabPanel; + private final OneBandTabPanel dBHtTabPanel; private OfflineTaskGroup offlineTaskGroup; private OLProcessDialog olProcessDialog; @@ -66,6 +66,32 @@ public class OneBandControl extends PamControlledUnit implements PamSettings { return dBHtTabPanel; } + /** + * Gets the measurement name for a given index (0 <= index < {@link OneBandControl#NMEASURES}). + * This requires access to the Global Medium Manager to report on the correct units. + * + * @param index The index of the measure. + * @return The text representation of the relevant measure, including units. + */ + public static String getMeasurementName(int index) { + GlobalMediumManager gmm = PamController.getInstance().getGlobalMediumManager(); + String dbRef = gmm.getdBRefString(); + String selDbRef = gmm.getdBSELString(); + + switch (index) { + case 0: + return String.format("RMS (%s)", dbRef); + case 1: + return String.format("0-Peak (%s)", dbRef); + case 2: + return String.format("Peak-Peak (%s)", dbRef); + case 3: + return String.format("Integrated SEL (%s)", selDbRef); + default: + throw new IllegalStateException("Unexpected value: " + index); + } + } + /* (non-Javadoc) * @see PamController.PamControlledUnit#createDetectionMenu(java.awt.Frame) */ diff --git a/src/noiseOneBand/OneBandDisplayDialog.java b/src/noiseOneBand/OneBandDisplayDialog.java index 03b19cca..7d972aa2 100644 --- a/src/noiseOneBand/OneBandDisplayDialog.java +++ b/src/noiseOneBand/OneBandDisplayDialog.java @@ -48,7 +48,7 @@ public class OneBandDisplayDialog extends PamDialog { mainPanel.add(tabPane); JPanel scalePanel = new JPanel(new GridBagLayout()); - scalePanel.setBorder(new TitledBorder("Amlitude Scale")); + scalePanel.setBorder(new TitledBorder("Amplitude Scale")); GridBagConstraints c = new PamGridBagContraints(); c.gridwidth = 3; addComponent(scalePanel, showGrid = new JCheckBox("Show Grid"), c); @@ -62,14 +62,14 @@ public class OneBandDisplayDialog extends PamDialog { c.gridx++; addComponent(scalePanel, minAmp = new JTextField(5), c); c.gridx++; - addComponent(scalePanel, new JLabel(" dB re 1\u03BCPa ", SwingConstants.LEFT), c); + addComponent(scalePanel, new JLabel(" dB", SwingConstants.LEFT), c); c.gridx = 0; c.gridy++; addComponent(scalePanel, new JLabel("Max ", SwingConstants.RIGHT), c); c.gridx++; addComponent(scalePanel, maxAmp = new JTextField(5), c); c.gridx++; - addComponent(scalePanel, new JLabel(" dB re 1\u03BCPa ", SwingConstants.LEFT), c); + addComponent(scalePanel, new JLabel(" dB", SwingConstants.LEFT), c); tabPane.add(scalePanel, "Scale"); @@ -91,7 +91,7 @@ public class OneBandDisplayDialog extends PamDialog { for (int i = 0; i < OneBandControl.NMEASURES; i++) { c.gridx = 0; c.gridy++; - addComponent(symPanel, showMeasure[i] = new JCheckBox("Show " + OneBandControl.measureNames[i]), c); + addComponent(symPanel, showMeasure[i] = new JCheckBox("Show " + OneBandControl.getMeasurementName(i)), c); } tabPane.add(symPanel, "Symbols"); diff --git a/src/noiseOneBand/OneBandDisplayPanel.java b/src/noiseOneBand/OneBandDisplayPanel.java index 85441bdb..b4bab28d 100644 --- a/src/noiseOneBand/OneBandDisplayPanel.java +++ b/src/noiseOneBand/OneBandDisplayPanel.java @@ -508,7 +508,7 @@ public class OneBandDisplayPanel { OneBandDisplayParams params = getDisplayParams(panelType); for (int i = OneBandControl.NMEASURES-1; i >= 0; i--) { if ((params.showWhat & 1< OneBandControl.getMeasurementName(4)); + + PamController.getInstance().getGlobalMediumManager().setCurrentMedium(GlobalMedium.SoundMedium.Water, false); + assertEquals("RMS (dB re 1\u00B5Pa)", OneBandControl.getMeasurementName(0)); + assertEquals("0-Peak (dB re 1\u00B5Pa)", OneBandControl.getMeasurementName(1)); + assertEquals("Peak-Peak (dB re 1\u00B5Pa)", OneBandControl.getMeasurementName(2)); + assertEquals("Integrated SEL (dB re 1\u00B5Pa\u00B2s)", OneBandControl.getMeasurementName(3)); + + PamController.getInstance().getGlobalMediumManager().setCurrentMedium(GlobalMedium.SoundMedium.Air, false); + assertEquals("RMS (dB re 20\u00B5Pa)", OneBandControl.getMeasurementName(0)); + assertEquals("0-Peak (dB re 20\u00B5Pa)", OneBandControl.getMeasurementName(1)); + assertEquals("Peak-Peak (dB re 20\u00B5Pa)", OneBandControl.getMeasurementName(2)); + assertEquals("Integrated SEL (dB re 400\u00B5Pa\u00B2s)", OneBandControl.getMeasurementName(3)); + } finally { + PamController.getInstance().getGlobalMediumManager().setCurrentMedium(GlobalMedium.SoundMedium.Water, false); + } + } +} \ No newline at end of file diff --git a/src/test/resources/rawDeepLearningClassifier/PamZip/blue_whale_24.zip b/src/test/resources/rawDeepLearningClassifier/PamZip/blue_whale_24.zip new file mode 100644 index 00000000..1265875f Binary files /dev/null and b/src/test/resources/rawDeepLearningClassifier/PamZip/blue_whale_24.zip differ