diff --git a/.classpath b/.classpath index 507f6d76..188c7291 100644 --- a/.classpath +++ b/.classpath @@ -6,7 +6,7 @@ - + diff --git a/.gitignore b/.gitignore index 28c40451..e875dc34 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,5 @@ target/WMM.COF settings.xml .classpath +.classpath +.classpath diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 41b74bc8..e8c450c0 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,11 +1,11 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=16 -org.eclipse.jdt.core.compiler.compliance=16 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 +org.eclipse.jdt.core.compiler.compliance=11 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=16 +org.eclipse.jdt.core.compiler.source=11 diff --git a/src/PamUtils/PamUtils.java b/src/PamUtils/PamUtils.java index 2886e527..85ce33ba 100644 --- a/src/PamUtils/PamUtils.java +++ b/src/PamUtils/PamUtils.java @@ -397,7 +397,7 @@ public class PamUtils { /** * Force an angle to sit within some range. * @param angle input angle (radians) - * @param maxAngle maximum angle in degrees + * @param maxAngle maximum angle in radians * @return output angle (radians) */ static public double constrainedAngleR(double angle, double maxAngle) { diff --git a/src/PamguardMVC/RawDataUtils.java b/src/PamguardMVC/RawDataUtils.java index b11d55cb..3bdf954d 100644 --- a/src/PamguardMVC/RawDataUtils.java +++ b/src/PamguardMVC/RawDataUtils.java @@ -19,14 +19,23 @@ import java.io.IOException; public class RawDataUtils { /** - * Write the wave clip in scaled int8 format into a data output stream. + * Write the wave clip in scaled int8 format into a data output stream. If rawData is null + * or empty, it will still write the header consisting of nChan, nSamp and a scale, but no + * data. * @param dos Data output stream * @param rawData raw data * @throws IOException */ public void writeWaveClipInt8(DataOutputStream dos, double[][] rawData) throws IOException { - int nChan = rawData.length; - int nSamps = rawData[0].length; + int nChan, nSamps; + if (rawData == null || rawData.length == 0 || rawData[0] == null) { + nChan = 0; + nSamps = 0; + } + else { + nChan = rawData.length; + nSamps = rawData[0].length; + } double minVal = 0, maxVal = 0; for (int iC = 0; iC < nChan; iC++) { double[] chanData = rawData[iC]; @@ -36,7 +45,13 @@ public class RawDataUtils { } } maxVal = Math.max(maxVal, -minVal); - float scale = (float) (127./maxVal); + float scale; + if (maxVal == 0) { + scale = 1.f; + } + else { + scale = (float) (127./maxVal); + } dos.writeShort(nChan); dos.writeInt(nSamps); dos.writeFloat(scale); @@ -51,13 +66,17 @@ public class RawDataUtils { /** * Read a waveform clip in scaled int8 format from a data input stream * @param dis data input stream - * @return waveform double array + * @return waveform double array or null if nChan or nSamps was zero (implying an empty array + * was written in the fist place) * @throws IOException */ public double[][] readWavClipInt8(DataInputStream dis) throws IOException { int nChan = dis.readShort(); int nSamps = dis.readInt(); double scale = 1./dis.readFloat(); + if (nChan == 0 || nSamps == 0) { + return null; + } double[][] rawData = new double[nChan][nSamps]; for (int iC = 0; iC < nChan; iC++) { double[] chanData = rawData[iC];