mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-21 22:52:22 +00:00
Added storage of thresholds, stats level and peak state to binary output (#1)
of GPL detector so that these can be displayed in viewer.
This commit is contained in:
parent
5aaedec235
commit
4ddf206b9b
@ -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/JavaSE-11">
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk-16.0.1">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
|
2
.project
2
.project
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>PamGuard Working</name>
|
||||
<name>PamGuard GPL</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
|
2
pom.xml
2
pom.xml
@ -4,7 +4,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.pamguard</groupId>
|
||||
<artifactId>PamguardBeta</artifactId>
|
||||
<version>2.02.02</version>
|
||||
<version>2.02.03a</version>
|
||||
<name>Pamguard Java12+</name>
|
||||
<description>Pamguard for Java 12+, using Maven to control dependcies</description>
|
||||
<url>www.pamguard.org</url>
|
||||
|
@ -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.03";
|
||||
static public final String version = "2.02.03a";
|
||||
|
||||
/**
|
||||
* Release date
|
||||
|
@ -87,6 +87,7 @@ public class GPLProcess extends PamBlockProcess {
|
||||
addOutputDataBlock(whitenedSpectrogram);
|
||||
|
||||
stateDataBlock = new GPLStateDataBlock(this, 0);
|
||||
stateDataBlock.setBinaryDataSource(new GPLStateDataSource(stateDataBlock));
|
||||
addOutputDataBlock(stateDataBlock);
|
||||
|
||||
gplDetectionBlock = new GPLDetectionBlock(this);
|
||||
@ -780,12 +781,13 @@ public class GPLProcess extends PamBlockProcess {
|
||||
|
||||
|
||||
// quiet.noise_floor = 1.;
|
||||
/**
|
||||
* This is the call to the detector, which is remembering state, will mostly return
|
||||
* null, but when there has been a detection, will return an object with time and
|
||||
* frequency information.
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* This is the call to the detector, which is remembering state, will mostly return
|
||||
* null, but when there has been a detection, will return an object with time and
|
||||
* frequency information.
|
||||
*/
|
||||
public void runDetector(FFTDataUnit fftDataUnit, double[] wData, double base_in, double ceilnoise, double threshfloor) {
|
||||
// DetectedPeak newPeak = peakDetector.detectPeaks(fftDataUnit, wData, base_in,
|
||||
// gplParams.noise_ceiling * noise_floor, gplParams.thresh * noise_floor);
|
||||
|
109
src/gpl/GPLStateDataSource.java
Normal file
109
src/gpl/GPLStateDataSource.java
Normal file
@ -0,0 +1,109 @@
|
||||
package gpl;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import PamguardMVC.PamDataBlock;
|
||||
import PamguardMVC.PamDataUnit;
|
||||
import binaryFileStorage.BinaryDataSource;
|
||||
import binaryFileStorage.BinaryHeader;
|
||||
import binaryFileStorage.BinaryObjectData;
|
||||
import binaryFileStorage.ModuleFooter;
|
||||
import binaryFileStorage.ModuleHeader;
|
||||
|
||||
public class GPLStateDataSource extends BinaryDataSource {
|
||||
|
||||
private GPLStateDataBlock gplStateDataBlock;
|
||||
private ByteArrayOutputStream bos;
|
||||
private DataOutputStream dos;
|
||||
|
||||
public GPLStateDataSource(GPLStateDataBlock gplStateDataBlock) {
|
||||
super(gplStateDataBlock);
|
||||
this.gplStateDataBlock = gplStateDataBlock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStreamName() {
|
||||
return "GPL State";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStreamVersion() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getModuleVersion() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getModuleHeaderData() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PamDataUnit sinkData(BinaryObjectData binaryObjectData, BinaryHeader bh, int moduleVersion) {
|
||||
DataInputStream dis = new DataInputStream(new ByteArrayInputStream(binaryObjectData.getData()));
|
||||
try {
|
||||
double baseline = dis.readFloat();
|
||||
double ceilnoise = dis.readFloat();
|
||||
double threshfloor = dis.readFloat();;
|
||||
int state = dis.readShort();
|
||||
GPLStateDataUnit stateData = new GPLStateDataUnit(binaryObjectData.getDataUnitBaseData(), baseline, ceilnoise, threshfloor, state);
|
||||
return stateData;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModuleHeader sinkModuleHeader(BinaryObjectData binaryObjectData, BinaryHeader bh) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModuleFooter sinkModuleFooter(BinaryObjectData binaryObjectData, BinaryHeader bh,
|
||||
ModuleHeader moduleHeader) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BinaryObjectData getPackedData(PamDataUnit pamDataUnit) {
|
||||
if (bos == null) {
|
||||
bos = new ByteArrayOutputStream(14);
|
||||
dos = new DataOutputStream(bos);
|
||||
}
|
||||
else {
|
||||
bos.reset();
|
||||
}
|
||||
GPLStateDataUnit stateData = (GPLStateDataUnit) pamDataUnit;
|
||||
try {
|
||||
dos.writeFloat((float) stateData.getBaseline());
|
||||
dos.writeFloat((float) stateData.getCeilnoise());
|
||||
dos.writeFloat((float) stateData.getThreshfloor());
|
||||
dos.writeShort((short) stateData.getPeakState());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
BinaryObjectData bod = new BinaryObjectData(1, bos.toByteArray());
|
||||
|
||||
return bod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void newFileOpened(File outputFile) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package gpl;
|
||||
|
||||
import PamguardMVC.DataUnitBaseData;
|
||||
import PamguardMVC.PamDataUnit;
|
||||
|
||||
public class GPLStateDataUnit extends PamDataUnit {
|
||||
@ -30,6 +31,23 @@ public class GPLStateDataUnit extends PamDataUnit {
|
||||
this.threshfloor = threshfloor;
|
||||
}
|
||||
|
||||
/**
|
||||
* constructor used reading back from binary files.
|
||||
* @param baseData
|
||||
* @param baseline
|
||||
* @param ceilnoise
|
||||
* @param threshfloor
|
||||
* @param peakState
|
||||
*/
|
||||
public GPLStateDataUnit(DataUnitBaseData baseData,double baseline,
|
||||
double ceilnoise, double threshfloor, int peakState) {
|
||||
super(baseData);
|
||||
this.baseline = baseline;
|
||||
this.peakState = peakState;
|
||||
this.ceilnoise = ceilnoise;
|
||||
this.threshfloor = threshfloor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ceilnoise
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user