diff --git a/.classpath b/.classpath index 0eb3c4fb..576b210a 100644 --- a/.classpath +++ b/.classpath @@ -6,8 +6,9 @@ - + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs index a474f512..51bb81c3 100644 --- a/.settings/org.eclipse.core.resources.prefs +++ b/.settings/org.eclipse.core.resources.prefs @@ -1,6 +1,5 @@ eclipse.preferences.version=1 encoding//src/rawDeepLearningClassifer/segmenter/SegmenterProcess.java=UTF-8 -encoding//src/test=UTF-8 encoding//src/test/resources=UTF-8 encoding/=UTF-8 encoding/src=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 43939db6..5c924643 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,9 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=21 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=18 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=21 +org.eclipse.jdt.core.compiler.compliance=18 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -13,4 +13,4 @@ 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=21 +org.eclipse.jdt.core.compiler.source=18 diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml index 350f9de0..58a5bead 100644 --- a/dependency-reduced-pom.xml +++ b/dependency-reduced-pom.xml @@ -3,9 +3,9 @@ 4.0.0 org.pamguard Pamguard - Pamguard Java12+ - 2.02.09d - Pamguard for Java 12+, using Maven to control dependcies + Pamguard + 2.02.11a + Pamguard using Maven to control dependencies www.pamguard.org Sea Mammal Research Unit, University of St. Andrews @@ -13,6 +13,7 @@ ${basedir}/src + ${basedir}/src/test src @@ -62,7 +63,7 @@ - 17 + 21 jdt @@ -188,6 +189,7 @@ 11 11 - 16 + UTF-8 + 21 diff --git a/pom.xml b/pom.xml index 5e7b59ae..d6f7ddfd 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 org.pamguard Pamguard - 2.02.09d + 2.02.11a Pamguard Pamguard using Maven to control dependencies www.pamguard.org diff --git a/src/clickDetector/ClickTrainDetector.java b/src/clickDetector/ClickTrainDetector.java index a0141e03..8bfe6bb3 100644 --- a/src/clickDetector/ClickTrainDetector.java +++ b/src/clickDetector/ClickTrainDetector.java @@ -58,7 +58,6 @@ public class ClickTrainDetector extends PamProcess implements PamSettings { this.clickDataBlock = clickDataBlock; - PamSettingManager.getInstance().registerSettings(this); clickDataBlock.addObserver(this); diff --git a/src/cpod/CPODClick.java b/src/cpod/CPODClick.java index 7b60ef65..8cc9a535 100644 --- a/src/cpod/CPODClick.java +++ b/src/cpod/CPODClick.java @@ -27,8 +27,6 @@ public class CPODClick extends PamDataUnit implement private short[] rawData; - - /** * The amplitude in dB. */ @@ -38,6 +36,8 @@ public class CPODClick extends PamDataUnit implement * The raw data transforms for the CPOD click */ private RawDataTransforms rawDataTransforms = null; + + private CPODClassification cpodClassification; /** * Create a CPOD click. (This is used to load CPOD clicks from the binary store) @@ -147,7 +147,8 @@ public class CPODClick extends PamDataUnit implement public static CPODClick makeCPODClick(long tMillis, long fileSamples, short[] shortData) { short nCyc = shortData[3]; - short bw = shortData[4]; + short bw = shortData[4]; //bandwidth is an arbitary scale between 0 and 31; + bw = (short) ((255./31.) * (bw+1)); //make some attempt to convert to kHz short kHz = shortData[5]; short endF = shortData[6]; short spl = shortData[7]; @@ -326,6 +327,7 @@ public class CPODClick extends PamDataUnit implement } long tm = getTimeMilliseconds(); str += PamCalendar.formatDate(tm) + " " + PamCalendar.formatTime(tm, 3) + "

"; + str += String.format("UID: %dkHz

", this.getUID()); str += String.format("Start Freq: %dkHz

", getkHz()); str += String.format("N Cycles: %d

", getnCyc()); str += String.format("BandWidth: %dkHz

", getBw()); @@ -333,12 +335,12 @@ public class CPODClick extends PamDataUnit implement str += String.format("Slope: %d

", getSlope()); str += String.format("SPL: %d", getSpl()); if (rawData.length == 40) { - str += String.format("

QClass %d, SpClass %d", getBits(rawData[19], (short) 0x3), - getBits(rawData[19], (short) 0b11100)); + str += String.format("

QClass %d, SpClass %d", CPODUtils.getBits(rawData[19], (short) 0x3), + CPODUtils.getBits(rawData[19], (short) 0b11100)); str += String.format("

Train %d, %d click", rawData[20], rawData[23]); str += String.format("

Qn %d, RateGood %d, SpGood %d, SpClass %d", - getBits(rawData[36], (short)3), getBits(rawData[36], (short) 4), - getBits(rawData[36], (short)8), getBits(rawData[36], (short) 240)); + CPODUtils.getBits(rawData[36], (short)3), CPODUtils.getBits(rawData[36], (short) 4), + CPODUtils.getBits(rawData[36], (short)8), CPODUtils.getBits(rawData[36], (short) 240)); } if (rawData != null) { int nRaw = rawData.length; @@ -350,29 +352,18 @@ public class CPODClick extends PamDataUnit implement } } } - - if (this.getSuperDetection(0)!=null) { - str += String.format("I am part of a click train!!!:

"); + CPODClickTrainDataUnit clicktrain = getCPODClickTrain(); + if (clicktrain!=null) { + str += "

" + clicktrain.getStringInfo() + "

"; } else { - str += String.format("I am not part of a click train :-(:

"); + str += "

" + String.format("No click train info

"); } // str += "<\html>"; return str; } - short getBits(short data, short bitMap) { - short firstBit = 0; - for (int i = 0; i < 8; i++) { - if ((bitMap & (1<>firstBit); - } @Override public double[][] getWaveData() { @@ -405,5 +396,28 @@ public class CPODClick extends PamDataUnit implement } + /** + * Get the click train detection from the click detection + * @return the click train detection + */ + public CPODClickTrainDataUnit getCPODClickTrain() { + for (int i=0; i cpodData = null; - - try { - cpodData = CPODReader.importCPODFile(cpFile, from, maxNum); - } catch (Exception e) { - e.printStackTrace(); - return 0; - } - - - // fileStart + nMinutes * 60000L; - - - int nClicks = 0; - for (int i=0; i { - /** * List of files, either CP1 or CP3 */ @@ -308,10 +272,7 @@ public class CPODImporter { @Override protected Integer call() throws Exception { try { - - System.out.println(("HELLO IMPORT THREAD: " )); - - + BinaryDataSource binarySource = cpodDataBlock.getBinaryDataSource(); binaryStore = (BinaryStore) PamController.getInstance().findControlledUnit(BinaryStore.defUnitType); if (binaryStore == null) { @@ -332,7 +293,9 @@ public class CPODImporter { if (this.isCancelled()) return -1; final int ii = i; - this.updateMessage(("Importing CPOD file: " + (ii+1))); + + System.out.println(("Importing CPOD file: " + (ii+1)) + " " +cpxFile.get(i)); + this.updateMessage(("Importing CPOD file: " + (ii+1)) + " " +cpxFile.get(i).getName()); int nClicks = 0; int totalClicks = Integer.MAX_VALUE; @@ -340,9 +303,6 @@ public class CPODImporter { this.updateProgress(-1, 1); - CPODClickDataBlock tempCPODDataBlock = new CPODClickDataBlock("Temp CPOD Detections", - null, 0); - long[] fileStartEnd = getFileStartEnd(cpxFile.get(i)); while (importedClicks>0 || importedClicks==-1) { @@ -351,17 +311,20 @@ public class CPODImporter { CPODFileType fileType = CPODUtils.getFileType(cpxFile.get(i)); System.out.println(("Importing from " + fileType + " " + i + " of " + cpxFile.size() + " from detection " + nClicks)); - this.updateMessage(("Importing from " + fileType + " " + i + " of " + cpxFile.size() + " from detection " + nClicks)); //import the CPOD or FPOD data this.updateProgress(-1, 1); - importedClicks = importFile(cpxFile.get(i), tempCPODDataBlock, clickTrainDataBlock, nClicks, MAX_SAVE); + importedClicks = importFile(cpxFile.get(i), cpodDataBlock, clickTrainDataBlock, nClicks, MAX_SAVE); + this.updateProgress(-1, 1); - System.out.println("Number of CPOD data units in the data block: " + tempCPODDataBlock.getUnitsCount() + " progress: " + (i+1) + " " + cpxFile.size() ); - - ListIterator iterator = tempCPODDataBlock.getListIterator(0); + System.out.println("Number of CPOD data units in the data block: " + cpodDataBlock.getUnitsCount() + " progress: " + (i+1) + " " + cpxFile.size() ); + //need to make a copy of the data incase we clear the cp2 datablock to look for previously + //loaded detection. Not memory efficient but the easiest way to do and only occurs + //in the laoding process. + ListIterator iterator = cpodDataBlock.getDataCopy().listIterator(); + cpodDataBlock.clearAll(); //save the click trains to the database clickTrainDataBlock.saveViewerData(); @@ -375,8 +338,6 @@ public class CPODImporter { if (this.isCancelled()) return -1; click = iterator.next(); - System.out.println("Saving click: " + click.getUID()); - //new binary file every daya; cal.setTimeInMillis(click.getTimeMilliseconds()); int dayYear = cal.get(Calendar.DAY_OF_YEAR); @@ -397,7 +358,6 @@ public class CPODImporter { data = cpodDataBlock.getBinaryDataSource().getPackedData(cpodTrainList.get(j)); this.binaryStream.storeData(data.getObjectType(), click.getBasicData(), data); } - System.out.println("HAVE REMOVED " + count + " CP1 detections: " + cpodTrainList.size()); count = 0; } @@ -425,11 +385,15 @@ public class CPODImporter { //load the view from the data block for that day. long millisDayStart = roundToDay(click.getTimeMilliseconds()); cpodDataBlock.loadViewerData(millisDayStart, millisDayStart+24*60*60*1000L-1, null); + + System.out.println("Load viewer data from: " + PamCalendar.formatDBDateTime(millisDayStart) + + " to " +PamCalendar.formatDBDateTime(millisDayStart+24*60*60*1000L-1)); //now the tricky bit - if we are loading viewer files we want to save the data from the CP3 on top of the //CP1 file but we DO NOT want to add in duplicate clicks. if (cpodDataBlock.getUnitsCount()>0) { System.out.println("There are already data units from CP1 or FP1 files " + cpodDataBlock.getUnitsCount()); + cpodTrainList=null; cpodTrainList = cpodDataBlock.getDataCopy(); Collections.sort(cpodTrainList, new CPODClickOmparator()); cpodDataBlock.clearAll(); //just incase @@ -463,10 +427,7 @@ public class CPODImporter { this.binaryStream.storeData(data.getObjectType(), click.getBasicData(), data); } - cpodDataBlock.clearAll(); - tempCPODDataBlock.clearAll(); - - + cpodDataBlock.clearAll(); //update number of clicks. nClicks=nClicks+MAX_SAVE+1; @@ -484,29 +445,6 @@ public class CPODImporter { return 1; } - private long[] getFileStartEnd(File file) { - CPODFileType fileType = CPODUtils.getFileType(file); - - long[] timelims = null; - switch (fileType){ - case CP1: - case CP3: - //TODO - break; - case FP1: - case FP3: - FPODHeader header =FPODReader.readHeader(file); - if (header==null) return null; - timelims=new long[] {CPODUtils.podTimeToMillis(header.FirstLoggedMin), CPODUtils.podTimeToMillis(header.LastLoggedMin)}; - break; - default: - break; - - } - - return timelims; - } - /** @@ -524,6 +462,68 @@ public class CPODImporter { calendar.set(Calendar.MILLISECOND, 0); return calendar.getTimeInMillis(); } + + /** + * Import the CPOD file. + * @param cpFile2 - the cp1 file + * @param dataBlock - the datablock + * @param from - the click index to save from. e.g. 100 means that only click 100 + in the file is saved + * @param maxNum - the maximum number to import + * @return the total number of clicks in the file. + */ + private int importCPODFile(File cpFile2, CPODClickDataBlock dataBlock, CPODClickTrainDataBlock clickTrainDataBlock, int from, int maxNum) { + ArrayList cpodData = null; + + try { + cpodData = CPODReader.importCPODFile(cpFile2, from, maxNum); + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + + HashMap cpodClickTrains = new HashMap(); + + // fileStart + nMinutes * 60000L; + + int nClicks = 0; + for (int i=0; i fpodData = new ArrayList(); @@ -613,8 +618,33 @@ public class CPODImporter { } return 0; - } + + /** + * Get the start and end of a file from the header data. This opens and closes the file. + * @param file -a CP1, CP3 FP1 or FP3 file; + * @return the start and end time in Java millis in a long array (first element start, last element end) + */ + private long[] getFileStartEnd(File file) { + CPODFileType fileType = CPODUtils.getFileType(file); + long[] timelims = null; + switch (fileType){ + case CP1: + case CP3: + CPODHeader headerC =CPODReader.readHeader(file); + timelims=new long[] {headerC.fileStart, headerC.fileEnd}; + break; + case FP1: + case FP3: + FPODHeader header =FPODReader.readHeader(file); + if (header==null) return null; + timelims=new long[] {CPODUtils.podTimeToMillis(header.FirstLoggedMin), CPODUtils.podTimeToMillis(header.LastLoggedMin)}; + break; + default: + break; + } + return timelims; + } /** * Import a file. diff --git a/src/cpod/CPODReader.java b/src/cpod/CPODReader.java index 2d353ca6..657bf730 100644 --- a/src/cpod/CPODReader.java +++ b/src/cpod/CPODReader.java @@ -8,8 +8,11 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.util.ArrayList; +import java.util.HashMap; +import PamUtils.PamCalendar; import cpod.CPODUtils.CPODFileType; +import cpod.FPODReader.FPODdata; /** * Read CPOD data. @@ -21,8 +24,8 @@ import cpod.CPODUtils.CPODFileType; * */ public class CPODReader { - - + + /** * A new minute. Don;t think we need to do anything here.? * @param byteData @@ -32,7 +35,24 @@ public class CPODReader { } - + public static CPODHeader readHeader(File cpFile) { + + BufferedInputStream bis = null; + FileInputStream fileInputStream = null; + + try { + bis = new BufferedInputStream(fileInputStream = new FileInputStream(cpFile)); + } catch (FileNotFoundException e) { + e.printStackTrace(); + return null; + } + + return readHeader( bis, CPODUtils.getFileType(cpFile)); + + } + + + public static CPODHeader readHeader(BufferedInputStream bis, CPODFileType cpFileType) { int bytesRead; byte[] headData = new byte[getHeadSize(cpFileType)]; @@ -53,7 +73,7 @@ public class CPODReader { try { shortData[i] = dis.readShort(); if (shortData[i] == 414) { -// System.out.println("Found id at %d" + i); + // System.out.println("Found id at %d" + i); } } catch (IOException e) { e.printStackTrace(); @@ -79,19 +99,19 @@ public class CPODReader { intData[i] = dis.readInt(); int bOff = i*4; int sOff = i*2; -// if (intData[i] > 0) -// System.out.println(String.format("%d, Int = %d, Float = %3.5f, Short = %d,%d, bytes = %d,%d,%d,%d", i, intData[i], -// floatData[i], -// shortData[sOff], shortData[sOff+1], -// headData[bOff], headData[bOff+1], headData[bOff+2], headData[bOff+3])); + // if (intData[i] > 0) + // System.out.println(String.format("%d, Int = %d, Float = %3.5f, Short = %d,%d, bytes = %d,%d,%d,%d", i, intData[i], + // floatData[i], + // shortData[sOff], shortData[sOff+1], + // headData[bOff], headData[bOff+1], headData[bOff+2], headData[bOff+3])); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } - + CPODHeader header = new CPODHeader(); - + header.fileStart = CPODUtils.podTimeToMillis(intData[64]); header.fileEnd = CPODUtils.podTimeToMillis(intData[65]); // other times seem to be packed in ints 66 - 69. @@ -100,7 +120,7 @@ public class CPODReader { return header; } - + /** * Import a CPOD file. @@ -110,22 +130,27 @@ public class CPODReader { * @return the total number of clicks in the file. */ protected static ArrayList importCPODFile(File cpFile, int from, int maxNum) { - + + //holds a map of the click train detections. + HashMap clickTrains = new HashMap(); + //the current classification + CPODClassification cpodClassification; + ArrayList clicks = new ArrayList(); BufferedInputStream bis = null; int bytesRead; FileInputStream fileInputStream = null; long totalBytes = 0; - + CPODFileType cpFileType = CPODUtils.getFileType(cpFile); - + try { bis = new BufferedInputStream(fileInputStream = new FileInputStream(cpFile)); } catch (FileNotFoundException e) { e.printStackTrace(); return null; } - + CPODHeader header = readHeader(bis, cpFileType); if (header == null) { return null; @@ -158,24 +183,67 @@ public class CPODReader { isClick = byteData[dataSize-1] != -2; if (isClick) { - nClicks++; if (from<0 || (nClicks>from && nClicks<(from+maxNum))) { //System.out.println("Create a new CPOD click: "); CPODClick cpodClick = processCPODClick(nMinutes, shortData, header); + + if (cpFileType.equals(CPODFileType.CP3)) { + + short trainID = shortData[20]; + + short species = (short) (shortData[36] & (112 >> 4)); + + short quality = (short) (shortData[36] & 3); + + // short species = (short) ((shortData[19] >> 2) & 7); + // + // short quality = (short) (shortData[19] & 3); + + //generate a unique train ID within the file + int trainUID = Integer.valueOf(String.format("%06d", nMinutes) + String.format("%d", trainID)); + + //find the click train from the hash map - if it is not there, create a new one. + cpodClassification = clickTrains.get(trainUID); + + if (cpodClassification==null) { + cpodClassification = new CPODClassification(); + cpodClassification.isEcho = false; + cpodClassification.clicktrainID = trainUID; + cpodClassification.species = CPODUtils.getSpecies(species); + cpodClassification.qualitylevel = quality; + + clickTrains.put(trainUID, cpodClassification); + System.out.println("Click train ID: " + trainUID + " minutes: " + nMinutes + " species: " + species + " quality level: " + quality); + + } + + cpodClick.setClassification(cpodClassification); + + } + clicks.add(cpodClick); + if (nClicks%100000==0) { + System.out.println("CPOD data: " + nClicks + " " + PamCalendar.formatDateTime(cpodClick.getTimeMilliseconds()) + " " +cpodClick.getBw() + " " +shortData[4] ); +// if (nClicks>0)return clicks; //FIXME + } + + } -// // now remove the data unit from the data block in order to clear up memory. Note that the remove method + nClicks++; + + + // // now remove the data unit from the data block in order to clear up memory. Note that the remove method // // saves the data unit to the Deleted-Items list, so clear that as well (otherwise we'll just be using // // up all the memory with that one) // dataBlock.remove(cpodClick); // dataBlock.clearDeletedList(); - - + + } else { nMinutes ++; @@ -191,7 +259,7 @@ public class CPODReader { return clicks; } - + public static int getHeadSize(CPODFileType fileType) { switch (fileType) { case CP1: @@ -219,7 +287,7 @@ public class CPODReader { } return 0; } - + /** * Holds an CPOD header information *

@@ -231,9 +299,9 @@ public class CPODReader { public short podId; public long fileEnd; public long fileStart; - + } - + /** * Is it the end of the file ? * @param byteData @@ -250,7 +318,7 @@ public class CPODReader { } return true; } - + /** * Create a CPOD click object from CPOD data. * @param nMinutes @@ -259,25 +327,41 @@ public class CPODReader { * @return */ private static CPODClick processCPODClick(int nMinutes, short[] shortData, CPODHeader header) { - + long minuteMillis = header.fileStart + nMinutes * 60000L; - + int t = shortData[0]<<16 | shortData[1]<<8 | shortData[2]; // 5 microsec intervals ! long tMillis = minuteMillis + t/200; - - + + // do a sample number within the file as 5us intervals long fileSamples = t + minuteMillis * 200; - + /* * */ return CPODClick.makeCPODClick(tMillis, fileSamples, shortData); } - + /** + * Test the program + * @param args + */ + public static void main(String[] args) { + // String filePath = "/Users/au671271/Library/CloudStorage/GoogleDrive-macster110@gmail.com/My Drive/PAMGuard_dev/CPOD/FPOD_NunBank/0866 NunBankB 2023 06 27 FPOD_6480 file0.FP1"; + + String filePath = "D:\\Dropbox\\PAMGuard_dev\\tutorials\\CPOD_wav\\data\\Hyskeir\\CPOD\\0740 Hyskeir 2022 12 02 POD1655 file01.CP3"; + // String filePath = "D:\\DropBox\\PAMGuard_dev\\CPOD\\FPOD_NunBank\\0866 NunBankB 2023 06 27 FPOD_6480 file0.FP3"; + + File fpfile = new File(filePath); + + + importCPODFile( fpfile, 0, Integer.MAX_VALUE); + + + } } diff --git a/src/cpod/CPODSpeciesModifier.java b/src/cpod/CPODSpeciesModifier.java new file mode 100644 index 00000000..446d58b2 --- /dev/null +++ b/src/cpod/CPODSpeciesModifier.java @@ -0,0 +1,62 @@ +package cpod; + +import java.awt.Color; + +import PamView.GeneralProjector; +import PamView.PamSymbolType; +import PamView.symbol.PamSymbolChooser; +import PamView.symbol.SymbolData; +import PamView.symbol.modifier.SymbolModType; +import PamView.symbol.modifier.SymbolModifier; +import PamguardMVC.PamDataUnit; +import cpod.CPODClassification.CPODSpeciesType; + +public class CPODSpeciesModifier extends SymbolModifier { + + final Color porpColor = new Color(93,30,255); + + final Color dolphColor = new Color(255,160,0); + + private SymbolData symbolData = new SymbolData(PamSymbolType.SYMBOL_CIRCLE, 5, 5, true, java.awt.Color.BLACK, java.awt.Color.BLACK); + + public CPODSpeciesModifier(PamSymbolChooser symbolChooser) { + super("Species", symbolChooser, SymbolModType.FILLCOLOUR | SymbolModType.LINECOLOUR); + } + + @Override + public SymbolData getSymbolData(GeneralProjector projector, PamDataUnit dataUnit) { + + CPODClick cpodClick = (CPODClick) dataUnit; + + Color color = Color.BLACK; + + + if (cpodClick.getCPODClickTrain()!=null) { + + CPODSpeciesType species = cpodClick.getCPODClickTrain().getSpecies(); + + switch(species) { + case DOLPHIN: + color=dolphColor; + break; + case NBHF: + color=porpColor;; + break; + case SONAR: + color = Color.DARK_GRAY; + break; + case UNKNOWN: + break; + default: + break; + } + + } + + symbolData.setFillColor(color); + symbolData.setLineColor(color); + + return symbolData; + } + +} diff --git a/src/cpod/CPODSymbolManager.java b/src/cpod/CPODSymbolManager.java index 3939f6a9..db5ed447 100644 --- a/src/cpod/CPODSymbolManager.java +++ b/src/cpod/CPODSymbolManager.java @@ -51,9 +51,9 @@ public class CPODSymbolManager extends StandardSymbolManager { psc.addSymbolModifier(new PeakFreqModifier(psc)); //add the peak frequency modifier that allows clicks to be coloured by peak frequency. - psc.addSymbolModifier(new CPODClickTrainModifier(psc)); + psc.addSymbolModifier(new CPODSpeciesModifier(psc)); - // we can also add some default behaviour here to match the old behaviour + // we can also add some default behaviour here to match the old behaviourzz // these will get overridden once user options are set, but it's good to give defaults. // SymbolModifier eventMod = psc.hasSymbolModifier(SuperDetSymbolModifier.class); // if (eventMod != null) { diff --git a/src/cpod/CPODTrainSymbolManager.java b/src/cpod/CPODTrainSymbolManager.java index 6d25bf2e..599bec05 100644 --- a/src/cpod/CPODTrainSymbolManager.java +++ b/src/cpod/CPODTrainSymbolManager.java @@ -7,7 +7,7 @@ public class CPODTrainSymbolManager extends SuperDetectionSymbolManager { public CPODTrainSymbolManager(CPODClickTrainDataBlock pamDataBlock) { super(pamDataBlock, new SymbolData()); - super.setSpecialColourName("Event Colour"); + super.setSpecialColourName("Click Train"); } diff --git a/src/cpod/CPODUtils.java b/src/cpod/CPODUtils.java index 02339ffb..cd9b2736 100644 --- a/src/cpod/CPODUtils.java +++ b/src/cpod/CPODUtils.java @@ -111,5 +111,17 @@ public class CPODUtils { public static CPODSpeciesType getSpecies(String species) { return CPODSpeciesType.valueOf(species); } + + public static short getBits(short data, short bitMap) { + short firstBit = 0; + for (int i = 0; i < 8; i++) { + if ((bitMap & (1<>firstBit); + } } diff --git a/src/cpod/FPODReader.java b/src/cpod/FPODReader.java index 47813992..e9c14954 100644 --- a/src/cpod/FPODReader.java +++ b/src/cpod/FPODReader.java @@ -419,6 +419,7 @@ public class FPODReader { cpodClassification.isEcho = echo; cpodClassification.clicktrainID = trainUID; cpodClassification.species = CPODUtils.getSpecies(species); + cpodClassification.qualitylevel = qualitylevel; clickTrains.put(trainUID, cpodClassification); diff --git a/src/cpod/dataSelector/StandardCPODataFilter.java b/src/cpod/dataSelector/StandardCPODataFilter.java index a95ceea6..daa96706 100644 --- a/src/cpod/dataSelector/StandardCPODataFilter.java +++ b/src/cpod/dataSelector/StandardCPODataFilter.java @@ -44,6 +44,7 @@ public class StandardCPODataFilter implements CPODDataFilter { return 1; } else { + System.out.println("Do not plot data: " +cpodClick.getTimeMilliseconds()); return 0; } diff --git a/src/cpod/fx/CPODSettingsPane.java b/src/cpod/fx/CPODSettingsPane.java index e4a4a60d..7f334103 100644 --- a/src/cpod/fx/CPODSettingsPane.java +++ b/src/cpod/fx/CPODSettingsPane.java @@ -352,7 +352,6 @@ public class CPODSettingsPane extends SettingsPane { * Called whenever the importing is finished. */ private void importingFinished() { - System.out.println("IMPORT FINISHED: MEH~!"); if (PamGUIManager.isSwing()) //important to put this here or , if a swing dialog pop ups, then there is thread lock. @@ -450,7 +449,7 @@ public class CPODSettingsPane extends SettingsPane { @Override public CPODParams getParams(CPODParams currParams) { - currParams.offlineFolder = currentFolder.getAbsolutePath(); + currParams.offlineFolder = currentFolder==null? null:currentFolder.getAbsolutePath(); currParams.subFolders = subFolder.selectedProperty().get(); try { currParams.startOffset = startOffset.getValue(); diff --git a/src/decimator/layoutFX/DecimatorSettingsPane.java b/src/decimator/layoutFX/DecimatorSettingsPane.java index 62803e9e..a6f9e759 100644 --- a/src/decimator/layoutFX/DecimatorSettingsPane.java +++ b/src/decimator/layoutFX/DecimatorSettingsPane.java @@ -1,39 +1,17 @@ package decimator.layoutFX; -import java.awt.BorderLayout; import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; - -import javax.swing.AbstractButton; -import javax.swing.BoxLayout; -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JTabbedPane; -import javax.swing.JTextField; -import javax.swing.border.TitledBorder; - -import PamController.PamController; import PamController.SettingsPane; import PamDetection.RawDataUnit; import PamView.dialog.PamGridBagContraints; -import PamView.dialog.SourcePanel; -import PamView.panel.PamAlignmentPanel; import PamguardMVC.PamDataBlock; -import dataMap.filemaps.OfflineFileDialogPanel; import decimator.DecimatorControl; import decimator.DecimatorParams; -import decimator.DecimatorParamsDialog.DefaultFilterButton; -import decimator.DecimatorParamsDialog.FilterButton; -import decimator.DecimatorParamsDialog.SPMonitor; -import decimator.DecimatorParamsDialog.SPSelection; import javafx.scene.Node; import javafx.scene.control.Label; import javafx.scene.control.TextField; import javafx.scene.layout.Pane; import pamViewFX.fxNodes.PamBorderPane; -import pamViewFX.fxNodes.PamButton; import pamViewFX.fxNodes.PamGridPane; import pamViewFX.fxNodes.PamVBox; import pamViewFX.fxNodes.utilityPanes.SourcePaneFX; @@ -95,51 +73,53 @@ public class DecimatorSettingsPane extends SettingsPane { decimatorPanel.add(sourceSampleRate = new Label(" - Hz"), gridx, gridy); gridx = 0; gridy ++; - decimatorPanel.add(new JLabel("Output sample rate "), gridx, gridy); - gridx ++; - decimatorPanel.add(newSampleRate = new TextField(), gridx, gridy); - gridx ++; - decimatorPanel.add(new JLabel(" Hz"), gridx, gridy); - gridy ++; - gridx = 0; - gridwidth = 1; - decimatorPanel.add(filterButton = new PamButton("Filter settings"), gridx, gridy); - filterButton.addActionListener(new FilterButton()); - gridx = 1; - gridwidth = 2; - addComponent(decimatorPanel, defaultFilterButton = new PamButton("Default Filter"), gridx, gridy); - defaultFilterButton.addActionListener(new DefaultFilterButton()); - gridx = 0; - gridwidth = 3; - gridy++; - addComponent(decimatorPanel, filterInfo = new JLabel("Filter: "), gridx, gridy); - gridx = 0; - gridwidth = 1; - gridy++; - addComponent(decimatorPanel, new JLabel("Interpolation: ", JLabel.RIGHT), gridx, gridy); - gridx += gridwidth; - gridwidth = 2; - addComponent(decimatorPanel, interpolator = new JComboBox(), gridx, gridy); - interpolator.addItem("None"); - interpolator.addItem("Linear"); - interpolator.addItem("Quadratic"); - - isViewer = PamController.getInstance().getRunMode() == PamController.RUN_PAMVIEW; - if (isViewer) { - JTabbedPane tabbedPane = new JTabbedPane(); - offlineDAQDialogPanel = new OfflineFileDialogPanel(decimatorControl, this); - tabbedPane.add("Offline Files", offlineDAQDialogPanel.getComponent()); - tabbedPane.add("Runtime Settings", mainPanel); - setDialogComponent(tabbedPane); - } - else { - setDialogComponent(mainPanel); - } +// decimatorPanel.add(new JLabel("Output sample rate "), gridx, gridy); +// gridx ++; +// decimatorPanel.add(newSampleRate = new TextField(), gridx, gridy); +// gridx ++; +// decimatorPanel.add(new JLabel(" Hz"), gridx, gridy); +// gridy ++; +// gridx = 0; +// gridwidth = 1; +// decimatorPanel.add(filterButton = new PamButton("Filter settings"), gridx, gridy); +// filterButton.addActionListener(new FilterButton()); +// gridx = 1; +// gridwidth = 2; +// addComponent(decimatorPanel, defaultFilterButton = new PamButton("Default Filter"), gridx, gridy); +// defaultFilterButton.addActionListener(new DefaultFilterButton()); +// gridx = 0; +// gridwidth = 3; +// gridy++; +// addComponent(decimatorPanel, filterInfo = new JLabel("Filter: "), gridx, gridy); +// gridx = 0; +// gridwidth = 1; +// gridy++; +// addComponent(decimatorPanel, new JLabel("Interpolation: ", JLabel.RIGHT), gridx, gridy); +// gridx += gridwidth; +// gridwidth = 2; +// addComponent(decimatorPanel, interpolator = new JComboBox(), gridx, gridy); +// interpolator.addItem("None"); +// interpolator.addItem("Linear"); +// interpolator.addItem("Quadratic"); +// +// isViewer = PamController.getInstance().getRunMode() == PamController.RUN_PAMVIEW; +// if (isViewer) { +// JTabbedPane tabbedPane = new JTabbedPane(); +// offlineDAQDialogPanel = new OfflineFileDialogPanel(decimatorControl, this); +// tabbedPane.add("Offline Files", offlineDAQDialogPanel.getComponent()); +// tabbedPane.add("Runtime Settings", mainPanel); +// setDialogComponent(tabbedPane); +// } +// else { +// setDialogComponent(mainPanel); +// } +// +// setHelpPoint("sound_processing.decimatorHelp.docs.decimator_decimator"); +// filterButton.setToolTipText("Manual adjustment of filter settings"); +// defaultFilterButton.setToolTipText("Set a default filter (6th order Butterworth low pass at Decimator Nyquist frequency)"); +// interpolator.setToolTipText("If Decimation / upsampling is not by an integer value, you should use interpolation to improve waveform reconstruction"); - setHelpPoint("sound_processing.decimatorHelp.docs.decimator_decimator"); - filterButton.setToolTipText("Manual adjustment of filter settings"); - defaultFilterButton.setToolTipText("Set a default filter (6th order Butterworth low pass at Decimator Nyquist frequency)"); - interpolator.setToolTipText("If Decimation / upsampling is not by an integer value, you should use interpolation to improve waveform reconstruction"); + return mainPanel; }