From a89279ef81056cff5bfa5a68fa4aa97868586f2e Mon Sep 17 00:00:00 2001 From: Douglas Gillespie <50671166+douggillespie@users.noreply.github.com> Date: Wed, 18 Jan 2023 11:06:03 +0000 Subject: [PATCH] V2.02.07a dB levels bug fix Fixed bug in some level calculations where a channel map instead of a single channel was being passed to the function performing the calcs. Was OK if hydrophones had same gain, but got it wrong if they were different. --- README.html | 198 +++++++++--------- dependency-reduced-pom.xml | 2 +- pom.xml | 2 +- src/Acquisition/AcquisitionProcess.java | 21 +- .../pamAudio/PamAudioFileManager.java | 12 +- src/PamController/PamguardVersionInfo.java | 2 +- src/PamUtils/SelectFolder.java | 18 +- src/PamView/ColourScheme.java | 1 + src/PamguardMVC/PamDataUnit.java | 10 +- src/PamguardMVC/superdet/SuperDetection.java | 13 +- src/levelMeter/LevelMeterSidePanel.java | 33 +-- src/noiseBandMonitor/NoiseBandProcess.java | 3 +- src/rocca/RoccaSpecPopUp.java | 2 +- 13 files changed, 176 insertions(+), 141 deletions(-) diff --git a/README.html b/README.html index f994a5ee..80869b8a 100644 --- a/README.html +++ b/README.html @@ -451,13 +451,13 @@ Version 2.00.10 June 2017

Latest Version 2.02.07 November 2022

+lang=EN-US>Latest Version 2.02.07 January 2023

Bug Fixes

-

Use of localization sensor and orientation -data for static hydrophones had a bug whereby it would continually ‘forget’ -angle offsets applied to static hydrophones in viewer mode. This is now fixed.

+

Use of localization sensor and orientation data +for static hydrophones had a bug whereby it would continually ‘forget’ angle +offsets applied to static hydrophones in viewer mode. This is now fixed.

Click tool bar: Correctly shows event selection options even if no species classification options are in place.

@@ -467,8 +467,8 @@ selection options even if no species classification options are in place.

ROCCA: Fixed (another) memory leak which -caused PAMGuard to crash when processing large data sets with the ROCCA classifier. -

+caused PAMGuard to crash when processing large data sets with the ROCCA +classifier.

Ishmael Modules: Fixed bug which occasionally caused crashes when processing many files offline.

@@ -681,9 +681,9 @@ href="http://www.pamguard.org/downloads.php?cat_id=3">here.

lang=EN-US>

This module has been renamed “Detection Grouper”, so -as to avoid confusion with the Group 3D localizer. This is because the Detection -Grouper is more for organizing data into groups to be localized than it is for -doing localization.

+as to avoid confusion with the Group 3D localizer. This is because the +Detection Grouper is more for organizing data into groups to be localized than +it is for doing localization.

Minor Bug Fixes

@@ -932,11 +932,11 @@ understand the notes listed for Beta Version 2.00.10 before proceeding with installation and use of this version.

-

This version of PAMGuard has been bundled with Java 13 (release -13.0.1). PSFX files generated in previous beta releases (2.xx.xx) should be -compatible with this version, and vice-versa. PSF files generated in core -releases (1.15.xx) can be loaded in this version, but will be converted to PSFX -files when PAMGuard exits.

+

This version of PAMGuard has been bundled with Java 13 +(release 13.0.1). PSFX files generated in previous beta releases (2.xx.xx) +should be compatible with this version, and vice-versa. PSF files generated in +core releases (1.15.xx) can be loaded in this version, but will be converted to +PSFX files when PAMGuard exits.

Bug Fixes

@@ -1064,9 +1064,9 @@ lang=EN-US style='font-size:7.0pt;font-family:"Times New Roman",serif'> &nb Add 3D map for target motion module.

6.        -Add option to alarm module to attach screenshots of all frames to email alerts. -

+lang=EN-US style='font-size:7.0pt;font-family:"Times New Roman",serif'>       Add option to alarm module to attach screenshots of all +frames to email alerts.

7.        @@ -1100,9 +1100,9 @@ lang=EN-US> Added ctrl-p hotkey to print-screen button.

14.        Update simulated daq so that it generates new random noise correctly -on each call rather then recycling old data. Makes the output more spectrally -flat.

+lang=EN-US> Update simulated daq so that it generates new random noise +correctly on each call rather then recycling old data. Makes the output more +spectrally flat.

14.        @@ -1169,8 +1169,8 @@ Bug 441. Plot coordinate calculations incorrect in PamAxis.

10.        Bug 442. BT Display does not change click symbol color when -Colour By Superdetection is selected.

+lang=EN-US> Bug 442. BT Display does not change click symbol color when Colour +By Superdetection is selected.

11.       

15.        -Bug 447. Viewer mode throws exception when trying to load beamformer -localisations

+Bug 447. Viewer mode throws exception when trying to load beamformer localisations

16.       

18.        Bug 450. Ishmael Detectors subscribing to FFTDataBlock -twice, meaning they process each data unit 2x doubling the output.

+lang=EN-US> Bug 450. Ishmael Detectors subscribing to FFTDataBlock twice, +meaning they process each data unit 2x doubling the output.

Upgrades

@@ -1220,8 +1219,8 @@ classify clicks.

2.        Added option in Sound Acquisition settings dialog to override -filename time stamp and use PC local time instead.

+lang=EN-US> Added option in Sound Acquisition settings dialog to +override filename time stamp and use PC local time instead.

3.       

1.        Bug 427. Soundtrap import not closing binary files properly if -BCL files do not contain off-effort 'E' line

+lang=EN-US> Bug 427. Soundtrap import not closing binary files properly +if BCL files do not contain off-effort 'E' line

2.        @@ -1347,8 +1346,8 @@ lang=EN-US> Updates to the Ishmael detectors.

Beta Version 2.00.16 May 2019

-

PAMGuard Version 2 contains major updates. You -should read and understand the notes listed for PAMGuard Version 2 contains major updates. +You should read and understand the notes listed for Beta Version 2.00.10 before proceeding with installation and use of this version.

@@ -1597,9 +1596,9 @@ lang=EN-US> Added decimal degrees option to latitude/longitude dialog.

2.        Added option in the Click Delay parameters to restrict the -number of initial samples used in the calculation. This can be useful for -cleaning up delays in the presence of echoes and small time delays.

+lang=EN-US> Added option in the Click Delay parameters to restrict the number +of initial samples used in the calculation. This can be useful for cleaning up +delays in the presence of echoes and small time delays.

3.        @@ -1642,8 +1641,8 @@ dialog is opened and then closed with no classifiers specified.

5.        -Bug 386. Click Detector Sweep Classifier sometimes keeping changed settings -even when user tries to cancel or discard changes

+Bug 386. Click Detector Sweep Classifier sometimes keeping changed +settings even when user tries to cancel or discard changes

6.        @@ -1724,8 +1723,8 @@ not compatible wth earlier versions and all configuration data may be lost if an attempt is made to open newly created psf files with older versions. We have therefore changed the file extension of psf files to .psfx in new Beta releases. Beta releases will still load the older psf files, but when the -configuration is saved, the original psf file will remain untouched and data will -be written to a psfx file with the same directory and name.

+configuration is saved, the original psf file will remain untouched and data +will be written to a psfx file with the same directory and name.

@@ -1741,8 +1740,8 @@ with installation and use of this version.

1.        -Bug 367. When adding a click to an event that already contained that click, -the click was being duplicated in the subtable.

+Bug 367. When adding a click to an event that already contained that +click, the click was being duplicated in the subtable.

2.        @@ -1888,8 +1887,8 @@ Beta versions

11.        -Bug 366. Rocca manual whistle contour extraction throws error when trying -to classify a boxed whistle

+Bug 366. Rocca manual whistle contour extraction throws error when +trying to classify a boxed whistle

Upgrades

@@ -1972,8 +1971,8 @@ User is now able to specify Soundtrap date/time format

Beta Version 2.00.11 October 2017

-

PAMGuard Version 2 contains major updates. -You should read and understand the notes listed for PAMGuard Version 2 contains major updates. You +should read and understand the notes listed for Beta Version 2.00.10 before proceeding with installation and use of this version.

@@ -2127,8 +2126,8 @@ to colour them by the colour assigned to the group.

Using Old PAMGuard Configurations

-

Old PAMGuard configurations will work with -the new version. However please note the following:

+

Old PAMGuard configurations will work with the +new version. However please note the following:

1.                   @@ -2137,10 +2136,10 @@ so they will no longer work with older PAMGuard versions.

2.                   -Display colour options will be lost and most data -displayed on the map may default to black. This is due to the above changes to -how colours are managed. Changing back to the colours of your choice is -relatively simple through the PAMGuard GUI.

+Display colour options will be lost and most data displayed +on the map may default to black. This is due to the above changes to how +colours are managed. Changing back to the colours of your choice is relatively +simple through the PAMGuard GUI.

 

@@ -2182,8 +2181,8 @@ lang=EN-US style='font-size:7.0pt;font-family:"Times New Roman",serif'> &nb

3.       -Rocca Module: added StartHr, ProportionWhists and ProportionClicks parameters -to Event classifier

+Rocca Module: added StartHr, ProportionWhists and ProportionClicks +parameters to Event classifier

4.       @@ -3147,9 +3146,9 @@ correctly calculated in real world coordinates.

Wild ArcGIS Interface (Maps and Mapping group)

-

This module, developed by Michael Oswald / SWFSC, allows PAMGuard -to output data in a format suitable for display in the WILD ArcGIS marine -mammal survey package. See online help for details.

+

This module, developed by Michael Oswald / SWFSC, allows +PAMGuard to output data in a format suitable for display in the WILD ArcGIS +marine mammal survey package. See online help for details.

Alarms (Utilities Group)

@@ -3186,9 +3185,9 @@ help for details.

Echo Detector and Sperm Whale IPI Computation (Beta only, Sound Measurements Group)

-

These two modules, developed by Brian Miller of the Australian -Antarctic Division can be used to estimate the inter pulse interval of sperm -whale clicks. (No help available)

+

These two modules, developed by Brian Miller of the +Australian Antarctic Division can be used to estimate the inter pulse interval +of sperm whale clicks. (No help available)

 

@@ -3246,9 +3245,9 @@ horizon.

Improved Filter Options

Filter options (used as stand-alone filter modules and also -within many other modules, such as the click detector and the Filtered Noise Measurement -module) have been improved so that the user can specify arbitrarily shaped -Finite Impulse Response filters (see online help for details).

+within many other modules, such as the click detector and the Filtered Noise +Measurement module) have been improved so that the user can specify arbitrarily +shaped Finite Impulse Response filters (see online help for details).

Radar Display

@@ -3271,9 +3270,9 @@ whistle.

  • Click detector inter click interval display was not working in viewer mode. This has been rectified.
  • Configuration loading. This has - been rationalised since it was often confusing to users. It is now no longer - possible to change configurations once PAMGuard has been launched and - pressing 'Cancel' on the select dialog causes PAMGuard to exit.
  • + been rationalised since it was often confusing to users. It is now no + longer possible to change configurations once PAMGuard has been launched + and pressing 'Cancel' on the select dialog causes PAMGuard to exit.
  • Airgun display. If this was included in the PAMGuard model before the GPS module it would hang PAMGuard. This has been rectified.
  • @@ -3287,10 +3286,10 @@ whistle.

    device.
  • Fixed colour bugs in Logger forms which did not display correctly in 'night' mode.
  • -
  • Bug fix in simulator. No longer stops - or fails to start generating sounds.
  • -
  • Bug in calculated spectrum - levels if data were decimated (Bug fix in simulator. No longer + stops or fails to start generating sounds.
  • +
  • Bug in calculated spectrum levels + if data were decimated (http://sourceforge.net/p/pamguard/bugs/187/) . Did not affect band level calculations.
  • Bug in noise band monitor. @@ -3374,9 +3373,9 @@ databases.

    National Instruments cards: Added code in support of the new x-series devices.

    -

    ASIO sound cards: Added support -for a new open source ASIO driver system (jasiohost). The old system has been -left in place for now while we assess users response to the newer system.

    +

    ASIO sound cards: Added support for +a new open source ASIO driver system (jasiohost). The old system has been left +in place for now while we assess users response to the newer system.

    AIS

    @@ -3451,14 +3450,14 @@ have implemented database storage for output of these modules.

    '         -Radar Display: A bug which stopped the radar display from correctly displaying -bearings to whistles from arrays containing more than two hydrophone elements -has been fixed.

    +Radar Display: A bug which stopped the radar display from correctly +displaying bearings to whistles from arrays containing more than two hydrophone +elements has been fixed.

    '         -Database Speed: A substantial rewriting of some of the indexing methods -in the database module has led to a significant increase in the speed at which +Database Speed: A substantial rewriting of some of the indexing methods in +the database module has led to a significant increase in the speed at which data are written to the database (orders of magnitude for large databases). This is having a significant impact on the overall reliability of the software. Other changes have increased the speed (again by orders of magnitude) at which @@ -3565,8 +3564,8 @@ Symbol'>''         -Bearings can be calculated using the envelope of the waveform rather than -the full waveform. The waveform or envelope can also be filtered prior to +Bearings can be calculated using the envelope of the waveform rather +than the full waveform. The waveform or envelope can also be filtered prior to bearing calculation.

    ''         -Wigner time-frequency plot for the click detector. Clicks are NOT automatically -displayed in the Winger window as they are for the waveform and spectrum -windows since the Wigner transformation is very time consuming. Clicks will be -displayed if you select them with the mouse.

    +Wigner time-frequency plot for the click detector. Clicks are NOT +automatically displayed in the Winger window as they are for the waveform and +spectrum windows since the Wigner transformation is very time consuming. Clicks +will be displayed if you select them with the mouse.

    '         @@ -4393,9 +4392,9 @@ a serial port

    New Likelihood detector.

    -

    The likelihood detector module is an implementation of a -likelihood ratio test with flexible algorithms and configuration to estimate -likelihood. It is

    +

    The likelihood detector module is an implementation of a likelihood +ratio test with flexible algorithms and configuration to estimate likelihood. +It is

    suitable for detecting both short duration Odontocete clicks (Sperm, Beaked, etc.) as well as moderate duration Mysticete calls (Humpback, @@ -4677,7 +4676,8 @@ Symbol'>' 2 since it was only taking the number of the lowest set + * bit. So if a genuine channel was sent, rather than a channel map with a + * single set channel, it messed up. Have made this function redundant + * and we need to be 100% sure that all amplitude calculations are sent a + * channel number not a bitmap with a single set channel. * @param channel * @return single channel if it seemed to be a bitmap. */ private int checkSingleChannel(int channel) { - int bitCount = PamUtils.getNumChannels(channel); - if (bitCount > 1 || channel > 32) { - channel = PamUtils.getLowestChannel(channel); - } return channel; +// int bitCount = PamUtils.getNumChannels(channel); +// if (bitCount > 1 || channel > 32) { +// channel = PamUtils.getLowestChannel(channel); +// } +// return channel; } /** @@ -1022,7 +1029,7 @@ public class AcquisitionProcess extends PamProcess { /** * Prepares for fast amplitude calculations - * @param channel + * @param channel number i.e. 0 - 31, NOT a bitmap. */ public double prepareFastAmplitudeCalculation(int channel) { channel = checkSingleChannel(channel); @@ -1035,7 +1042,7 @@ public class AcquisitionProcess extends PamProcess { * for an array of double data * * @param rawAmplitude raw amplitude (should be -1 < rawAmplitude < 1) - * @param channel channel number (MUST be a channel, not a sequence number) + * @param channel channel number (MUST be a channel 0 - 31, not a sequence number) * @return amplitude in dB re 1 uPa. */ public double[] rawAmplitude2dB(double[] rawAmplitude, int channel){ @@ -1122,7 +1129,7 @@ public class AcquisitionProcess extends PamProcess { /** * Converts dB in micropascal to ADC counts on a 0 - 1 scale. - * @param channel channel number. + * @param channel channel number, i.e. channel index 0 - 31 NOT a bitmap. * @param dBMuPascal db in micropascal * @return ADC counts on a 0-1 scale. */ diff --git a/src/Acquisition/pamAudio/PamAudioFileManager.java b/src/Acquisition/pamAudio/PamAudioFileManager.java index 6774ee63..76fc6910 100644 --- a/src/Acquisition/pamAudio/PamAudioFileManager.java +++ b/src/Acquisition/pamAudio/PamAudioFileManager.java @@ -14,7 +14,7 @@ import org.codehaus.plexus.util.FileUtils; *

    * PamAudioFieManager holds a list of PamAudioFile classes. Each PamAudioFile * can open a certain type of sound file e.g. flac or raw wav files. - * PamAudioFieManager provides fucntions around the list to open files, provide + * PamAudioFieManager provides functions around the list to open files, provide * file filters etc. * * @author Jamie Macaulay @@ -81,8 +81,16 @@ public class PamAudioFileManager { } public boolean isSoundFile(File soundFile, String soundExtension) { + if (soundFile == null) { + return false; + } + String extension = FileUtils.getExtension(soundFile.getName()); - + if (extension == null) { + return false; + } + extension = extension.toLowerCase(); + soundExtension = soundExtension.toLowerCase(); //System.out.println("Sound Extension: " + soundExtension + " File extension: " + extension); return (soundExtension.equals(extension) || soundExtension.equals("." + extension)); } diff --git a/src/PamController/PamguardVersionInfo.java b/src/PamController/PamguardVersionInfo.java index f768b546..6e160078 100644 --- a/src/PamController/PamguardVersionInfo.java +++ b/src/PamController/PamguardVersionInfo.java @@ -31,7 +31,7 @@ public class PamguardVersionInfo { * Version number, major version.minorversion.sub-release. * Note: can't go higher than sub-release 'f' */ - static public final String version = "2.02.07"; + static public final String version = "2.02.07a"; /** * Release date diff --git a/src/PamUtils/SelectFolder.java b/src/PamUtils/SelectFolder.java index 9fa60ea3..45588708 100644 --- a/src/PamUtils/SelectFolder.java +++ b/src/PamUtils/SelectFolder.java @@ -247,15 +247,15 @@ public class SelectFolder { folderName.setColumns(textLength); } -// public boolean isShowSubFolderOption() { -// return showSubFolderOption; -// } -// -// -// public void setShowSubFolderOption(boolean showSubFolderOption) { -// this.showSubFolderOption = showSubFolderOption; -// setVisibleControls(); -// } + public boolean isShowSubFolderOption() { + return showSubFolderOption; + } + + + public void setShowSubFolderOption(boolean showSubFolderOption) { + this.showSubFolderOption = showSubFolderOption; + setVisibleControls(); + } private void setVisibleControls() { includeSubFoldersCheckBox.setVisible(showSubFolderOption); diff --git a/src/PamView/ColourScheme.java b/src/PamView/ColourScheme.java index 73590fd5..ffa787b8 100644 --- a/src/PamView/ColourScheme.java +++ b/src/PamView/ColourScheme.java @@ -91,6 +91,7 @@ public class ColourScheme implements Serializable, Cloneable { } // avoid overflows. int nCol = whaleColors.length - 1; +// iCol = Math.abs(iCol); iCol = ((iCol-1)%nCol) + 1; if (iCol < 0) { return whaleColors[0]; diff --git a/src/PamguardMVC/PamDataUnit.java b/src/PamguardMVC/PamDataUnit.java index 15460f4d..434abd97 100644 --- a/src/PamguardMVC/PamDataUnit.java +++ b/src/PamguardMVC/PamDataUnit.java @@ -1696,7 +1696,15 @@ abstract public class PamDataUnit * @return any integer. */ public int getColourIndex() { - return (int) getUID(); + /* + * This can go wrong when UID > 2^31 since the colour choser takes + * a mod WRT number of whale colours and it doesn't like negative numbers. + * So need to keep the value going in positive. + */ + long uid = getUID(); + uid -= uid/2^31; + return (int) uid; +// return (int) getUID(); } /** diff --git a/src/PamguardMVC/superdet/SuperDetection.java b/src/PamguardMVC/superdet/SuperDetection.java index 7d0a328d..e68bd64a 100644 --- a/src/PamguardMVC/superdet/SuperDetection.java +++ b/src/PamguardMVC/superdet/SuperDetection.java @@ -351,10 +351,15 @@ public class SuperDetection extends PamDataUnit= noiseBandControl.noiseBandSettings.outputIntervalSeconds*1000) { - daqProcess.prepareFastAmplitudeCalculation(iChan); + double ampTerm = daqProcess.prepareFastAmplitudeCalculation(iChan); +// System.out.printf("Amplitude term cahnnel %d is %3.1f\n", iChan, ampTerm); double[][] measurementStats = new double[bandOutputs.length][2]; for (int i = 0; i < bandOutputs.length; i++) { measurementStats[bandOutputs.length-i-1][0] = daqProcess.rawAmplitude2dB(bandOutputs[i].getRMS(), iChan, true); diff --git a/src/rocca/RoccaSpecPopUp.java b/src/rocca/RoccaSpecPopUp.java index ffd39d34..57dfa487 100644 --- a/src/rocca/RoccaSpecPopUp.java +++ b/src/rocca/RoccaSpecPopUp.java @@ -451,7 +451,7 @@ public class RoccaSpecPopUp extends javax.swing.JPanel { for(int currentFreqBin = 0; currentFreqBin < fftVals.length(); currentFreqBin++) { rawAmp = fftVals.magsq(currentFreqBin); dB = daq.fftAmplitude2dB(rawAmp, - channelMap, + PamUtils.getLowestChannel(channelMap), fftData.getSampleRate(), fftLength, true,