mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-21 22:52:22 +00:00
noise output
This commit is contained in:
parent
158eedce8c
commit
415ec87938
@ -2872,8 +2872,6 @@ public class PamDataBlock<Tunit extends PamDataUnit> extends PamObservable {
|
||||
private Vector<OfflineDataMap> offlineDataMaps = null;
|
||||
|
||||
private SQLLogging logging;
|
||||
|
||||
private TethysDataProvider tethysDataProvider;
|
||||
|
||||
private JSONObjectDataSource jsonDataSource;
|
||||
|
||||
@ -3093,10 +3091,7 @@ public class PamDataBlock<Tunit extends PamDataUnit> extends PamObservable {
|
||||
* @return the tethysDataProvider
|
||||
*/
|
||||
public TethysDataProvider getTethysDataProvider(TethysControl tethysControl) {
|
||||
if (tethysDataProvider == null && PamDetection.class.isAssignableFrom(unitClass) && getLogging() != null) {
|
||||
tethysDataProvider = new AutoTethysProvider(tethysControl, this);
|
||||
}
|
||||
return tethysDataProvider;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2,11 +2,18 @@ package noiseMonitor;
|
||||
|
||||
import noiseMonitor.alarm.NoiseAlarmCounter;
|
||||
import noiseMonitor.alarm.NoiseAlarmProvider;
|
||||
import noiseMonitor.species.TethysNoiseDataProvider;
|
||||
import tethys.TethysControl;
|
||||
import tethys.pamdata.TethysDataProvider;
|
||||
import tethys.species.DataBlockSpeciesManager;
|
||||
import tethys.species.FixedSpeciesManager;
|
||||
import alarm.AlarmCounter;
|
||||
import alarm.AlarmCounterProvider;
|
||||
import alarm.AlarmDataSource;
|
||||
import PamUtils.FrequencyFormat;
|
||||
import PamUtils.PamUtils;
|
||||
import PamguardMVC.DataAutomation;
|
||||
import PamguardMVC.DataAutomationInfo;
|
||||
import PamguardMVC.PamDataBlock;
|
||||
import PamguardMVC.PamProcess;
|
||||
|
||||
@ -32,13 +39,15 @@ public class NoiseDataBlock extends PamDataBlock<NoiseDataUnit> implements Alarm
|
||||
|
||||
private NoiseAlarmProvider noiseAlarmCounter;
|
||||
/**
|
||||
* These are the names used in the database columns, so dont' change them on pain of
|
||||
* These are the names used in the database columns, so don't change them on pain of
|
||||
* nothing ever working ever again !
|
||||
*/
|
||||
public static final String[] measureNames = {"mean", "median", "low95", "high95", "Min", "Max", "Peak"};
|
||||
public static final String[] displayNames = {"Mean", "Median", "Lower 95%", "Upper 95%", "Minimum", "Maximim", "Peak"};
|
||||
|
||||
private int statisticTypes;
|
||||
private TethysNoiseDataProvider tethysNoiseDataProvider;
|
||||
private FixedSpeciesManager fixedSpeciesManager;
|
||||
|
||||
public NoiseDataBlock(String dataName,
|
||||
PamProcess parentProcess, int channelMap) {
|
||||
@ -244,6 +253,27 @@ public class NoiseDataBlock extends PamDataBlock<NoiseDataUnit> implements Alarm
|
||||
}
|
||||
return noiseAlarmCounter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataAutomationInfo getDataAutomationInfo() {
|
||||
return new DataAutomationInfo(DataAutomation.AUTOMATIC);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TethysDataProvider getTethysDataProvider(TethysControl tethysControl) {
|
||||
if (tethysNoiseDataProvider == null) {
|
||||
tethysNoiseDataProvider = new TethysNoiseDataProvider(tethysControl, this);
|
||||
}
|
||||
return tethysNoiseDataProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataBlockSpeciesManager<NoiseDataUnit> getDatablockSpeciesManager() {
|
||||
if (fixedSpeciesManager == null) {
|
||||
fixedSpeciesManager = new FixedSpeciesManager<NoiseDataUnit>(this, -10, "anthropogenic", "noise");
|
||||
}
|
||||
return fixedSpeciesManager;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
95
src/noiseMonitor/species/TethysNoiseDataProvider.java
Normal file
95
src/noiseMonitor/species/TethysNoiseDataProvider.java
Normal file
@ -0,0 +1,95 @@
|
||||
package noiseMonitor.species;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import PamUtils.PamUtils;
|
||||
import PamguardMVC.PamDataBlock;
|
||||
import PamguardMVC.PamDataUnit;
|
||||
import nilus.Detection;
|
||||
import nilus.Detection.Parameters;
|
||||
import nilus.DetectionEffortKind;
|
||||
import nilus.GranularityEnumType;
|
||||
import nilus.Helper;
|
||||
import noiseMonitor.NoiseDataBlock;
|
||||
import noiseMonitor.NoiseDataUnit;
|
||||
import tethys.TethysControl;
|
||||
import tethys.niluswraps.PDeployment;
|
||||
import tethys.output.StreamExportParams;
|
||||
import tethys.output.TethysExportParams;
|
||||
import tethys.pamdata.AutoTethysProvider;
|
||||
|
||||
public class TethysNoiseDataProvider extends AutoTethysProvider {
|
||||
|
||||
private NoiseDataBlock noiseDataBlock;
|
||||
|
||||
public TethysNoiseDataProvider(TethysControl tethysControl, NoiseDataBlock noiseDataBlock) {
|
||||
super(tethysControl, noiseDataBlock);
|
||||
this.noiseDataBlock = noiseDataBlock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GranularityEnumType[] getAllowedGranularities() {
|
||||
GranularityEnumType[] allowed = {GranularityEnumType.CALL};
|
||||
return allowed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Detection createDetection(PamDataUnit dataUnit, TethysExportParams tethysExportParams,
|
||||
StreamExportParams streamExportParams) {
|
||||
Detection detection = super.createDetection(dataUnit, tethysExportParams, streamExportParams);
|
||||
NoiseDataUnit noiseDataUnit = (NoiseDataUnit) dataUnit;
|
||||
/*
|
||||
* Now all the noise measurements, noting thre may be several types.
|
||||
*/
|
||||
int statTypes = noiseDataBlock.getStatisticTypes();
|
||||
int nTypes = PamUtils.getNumChannels(statTypes);
|
||||
Parameters params = detection.getParameters();
|
||||
List<Double> measurements = params.getFrequencyMeasurementsDB();
|
||||
double[][] noiseData = noiseDataUnit.getNoiseBandData();
|
||||
int meanIndex = -1;
|
||||
for (int i = 0; i < nTypes; i++) {
|
||||
int type = PamUtils.getNthChannel(i, statTypes);
|
||||
String name = noiseDataBlock.getMeasureName(type);
|
||||
if (1<<type == NoiseDataBlock.NOISE_MEAN) {
|
||||
meanIndex = i;
|
||||
}
|
||||
}
|
||||
if (meanIndex < 0) {
|
||||
meanIndex = 0;
|
||||
}
|
||||
int nMeasures = noiseData.length;
|
||||
// int meanIndex = PamUtils.getChannelPos(NoiseDataBlock.NOISE_MEAN, statTypes);
|
||||
// double[] meanData = noiseData[meanIndex];
|
||||
for (int i = 0; i < nMeasures; i++) {
|
||||
measurements.add(roundDecimalPlaces(noiseData[i][meanIndex],1));
|
||||
}
|
||||
|
||||
return detection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getEffortKinds(PDeployment pDeployment, List<DetectionEffortKind> effortKinds,
|
||||
StreamExportParams exportParams) {
|
||||
super.getEffortKinds(pDeployment, effortKinds, exportParams);
|
||||
DetectionEffortKind kind = effortKinds.get(0);
|
||||
nilus.DetectionEffortKind.Parameters params = kind.getParameters();
|
||||
if (params == null) {
|
||||
params = new nilus.DetectionEffortKind.Parameters();
|
||||
try {
|
||||
Helper.createRequiredElements(params);
|
||||
} catch (IllegalArgumentException | IllegalAccessException | InstantiationException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
kind.setParameters(params);
|
||||
}
|
||||
List<Double> fMeasures = params.getFrequencyMeasurementsHz();
|
||||
double[] loEdges = noiseDataBlock.getBandLoEdges();
|
||||
double[] hiEdges = noiseDataBlock.getBandHiEdges();
|
||||
// put lot mean into the array
|
||||
for (int i = 0; i < loEdges.length; i++) {
|
||||
fMeasures.add(roundSignificantFigures(Math.sqrt(loEdges[i]*hiEdges[i]), 4));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -66,7 +66,7 @@ import java.net.URISyntaxException;
|
||||
* @author dg50
|
||||
*
|
||||
*/
|
||||
public class AutoTethysProvider implements TethysDataProvider {
|
||||
abstract public class AutoTethysProvider implements TethysDataProvider {
|
||||
|
||||
private PamDataBlock pamDataBlock;
|
||||
private PamProcess pamProcess;
|
||||
@ -92,11 +92,11 @@ public class AutoTethysProvider implements TethysDataProvider {
|
||||
return schema;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public TethysDataPoint getDataPoint(PamDataUnit pamDataUnit) {
|
||||
// // TODO Auto-generated method stub
|
||||
// return null;
|
||||
// }
|
||||
// @Override
|
||||
// public TethysDataPoint getDataPoint(PamDataUnit pamDataUnit) {
|
||||
// // TODO Auto-generated method stub
|
||||
// return null;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public DescriptionType getDescription(Deployment deployment, TethysExportParams tethysExportParams) {
|
||||
@ -124,14 +124,14 @@ public class AutoTethysProvider implements TethysDataProvider {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
// algorithm.setMethod(this.getAlgorithmMethod());
|
||||
// algorithm.setSoftware("PAMGuard");
|
||||
// algorithm.setVersion(PamguardVersionInfo.version);
|
||||
// algorithm.setMethod(this.getAlgorithmMethod());
|
||||
// algorithm.setSoftware("PAMGuard");
|
||||
// algorithm.setVersion(PamguardVersionInfo.version);
|
||||
nilus.AlgorithmType.Parameters algoParameters = this.getAlgorithmParameters();
|
||||
if (algoParameters != null) {
|
||||
algorithm.setParameters(algoParameters);
|
||||
}
|
||||
|
||||
|
||||
return algorithm;
|
||||
}
|
||||
|
||||
@ -156,67 +156,67 @@ public class AutoTethysProvider implements TethysDataProvider {
|
||||
return null;
|
||||
}
|
||||
paramList.addAll(genList);
|
||||
|
||||
// Document doc = XMLUtils.createBlankDoc();
|
||||
// PamguardXMLWriter pamXMLWriter = PamguardXMLWriter.getXMLWriter();
|
||||
// Element dummyEl = doc.createElement("MODULES");
|
||||
// doc.appendChild(dummyEl);
|
||||
// PamSettings[] settingsObjs = getSettingsObjects();
|
||||
// if (settingsObjs == null) {
|
||||
// return null;
|
||||
// }
|
||||
//// pamXMLWriter.setStaticNameSpace(TethysControl.xmlNameSpace);
|
||||
// Element settingsEl = pamXMLWriter.writeUnitSettings(doc, dummyEl, pamSettings, settingsObjs);
|
||||
// if (settingsEl == null) {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
//// settingsEl = addNameSpaceToElements(doc, settingsEl, TethysControl.xmlNameSpace);
|
||||
//
|
||||
//
|
||||
// dummyEl.appendChild(settingsEl);
|
||||
// NodeList childs = settingsEl.getChildNodes();
|
||||
// for (int i = 0; i < childs.getLength(); i++) {
|
||||
// Node el = childs.item(i);
|
||||
// // System.out.println(el.getNodeName());
|
||||
// if (el instanceof Element) {
|
||||
// paramList.add((Element) el);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Document doc = pamXMLWriter.writeOneModule((PamSettings) pamControlledUnit, System.currentTimeMillis());
|
||||
// // String moduleXML = null;
|
||||
// if (doc != null) {
|
||||
// // this string should be XML of all the settings for the module controlling this
|
||||
// // datablock.
|
||||
// // moduleXML = pamXMLWriter.getAsString(doc, true); // change to false to get smaller xml
|
||||
// // System.out.printf("Module settings for datablock %s are:\n", moduleXML);
|
||||
// // System.out.println(moduleXML);
|
||||
// // Element pamguard = doc.get("PAMGUARD");
|
||||
// // Element modules = (Element) pamguard.getElementsByTagName("MODULES");
|
||||
// // doc.get
|
||||
// // NodeList childs = doc.getChildNodes();
|
||||
// // for (int i = 0; i < childs.getLength(); i++) {
|
||||
// // Node el = childs.item(i);
|
||||
// // System.out.println(el.getNodeName());
|
||||
// // if (el instanceof Element) {
|
||||
// // paramList.add((Element) el);
|
||||
// // }
|
||||
// // }
|
||||
// // String moduleXML = pamXMLWriter.getAsString(doc, true); // change to false to get smaller xml
|
||||
// // System.out.printf("Module settings for datablock %s are:\n%s", this.pamDataBlock.getDataName(), moduleXML);
|
||||
// }
|
||||
//
|
||||
// // // try the old say
|
||||
// // Document doc2 = pamXMLWriter.writeOneModule((PamSettings) pamControlledUnit, System.currentTimeMillis());
|
||||
// // String moduleXML = null;
|
||||
// // if (doc2 != null) {
|
||||
// // // this string should be XML of all the settings for the module controlling this
|
||||
// // // datablock.
|
||||
// // moduleXML = pamXMLWriter.getAsString(doc2, true); // change to false to get smaller xml
|
||||
// // System.out.printf("Module settings for datablock %s are:\n%s", pamDataBlock.getDataName(),moduleXML);
|
||||
// // }
|
||||
// //
|
||||
|
||||
// Document doc = XMLUtils.createBlankDoc();
|
||||
// PamguardXMLWriter pamXMLWriter = PamguardXMLWriter.getXMLWriter();
|
||||
// Element dummyEl = doc.createElement("MODULES");
|
||||
// doc.appendChild(dummyEl);
|
||||
// PamSettings[] settingsObjs = getSettingsObjects();
|
||||
// if (settingsObjs == null) {
|
||||
// return null;
|
||||
// }
|
||||
//// pamXMLWriter.setStaticNameSpace(TethysControl.xmlNameSpace);
|
||||
// Element settingsEl = pamXMLWriter.writeUnitSettings(doc, dummyEl, pamSettings, settingsObjs);
|
||||
// if (settingsEl == null) {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
//// settingsEl = addNameSpaceToElements(doc, settingsEl, TethysControl.xmlNameSpace);
|
||||
//
|
||||
//
|
||||
// dummyEl.appendChild(settingsEl);
|
||||
// NodeList childs = settingsEl.getChildNodes();
|
||||
// for (int i = 0; i < childs.getLength(); i++) {
|
||||
// Node el = childs.item(i);
|
||||
// // System.out.println(el.getNodeName());
|
||||
// if (el instanceof Element) {
|
||||
// paramList.add((Element) el);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Document doc = pamXMLWriter.writeOneModule((PamSettings) pamControlledUnit, System.currentTimeMillis());
|
||||
// // String moduleXML = null;
|
||||
// if (doc != null) {
|
||||
// // this string should be XML of all the settings for the module controlling this
|
||||
// // datablock.
|
||||
// // moduleXML = pamXMLWriter.getAsString(doc, true); // change to false to get smaller xml
|
||||
// // System.out.printf("Module settings for datablock %s are:\n", moduleXML);
|
||||
// // System.out.println(moduleXML);
|
||||
// // Element pamguard = doc.get("PAMGUARD");
|
||||
// // Element modules = (Element) pamguard.getElementsByTagName("MODULES");
|
||||
// // doc.get
|
||||
// // NodeList childs = doc.getChildNodes();
|
||||
// // for (int i = 0; i < childs.getLength(); i++) {
|
||||
// // Node el = childs.item(i);
|
||||
// // System.out.println(el.getNodeName());
|
||||
// // if (el instanceof Element) {
|
||||
// // paramList.add((Element) el);
|
||||
// // }
|
||||
// // }
|
||||
// // String moduleXML = pamXMLWriter.getAsString(doc, true); // change to false to get smaller xml
|
||||
// // System.out.printf("Module settings for datablock %s are:\n%s", this.pamDataBlock.getDataName(), moduleXML);
|
||||
// }
|
||||
//
|
||||
// // // try the old say
|
||||
// // Document doc2 = pamXMLWriter.writeOneModule((PamSettings) pamControlledUnit, System.currentTimeMillis());
|
||||
// // String moduleXML = null;
|
||||
// // if (doc2 != null) {
|
||||
// // // this string should be XML of all the settings for the module controlling this
|
||||
// // // datablock.
|
||||
// // moduleXML = pamXMLWriter.getAsString(doc2, true); // change to false to get smaller xml
|
||||
// // System.out.printf("Module settings for datablock %s are:\n%s", pamDataBlock.getDataName(),moduleXML);
|
||||
// // }
|
||||
// //
|
||||
|
||||
return parameters;
|
||||
}
|
||||
@ -224,26 +224,26 @@ public class AutoTethysProvider implements TethysDataProvider {
|
||||
private Element addNameSpaceToElements(Document doc, Element settingsEl, String xmlNameSpace) {
|
||||
|
||||
|
||||
// String xsltString = "<xsl:stylesheet version=\"1.0\" \r\n"
|
||||
// + " xmlns:xsl=http://www.w3.org/1999/XSL/Transform\r\n"
|
||||
// + " xmlns:ns0=http://mydata.com/H2H/Automation\r\n"
|
||||
// + " exclude-result-prefixes=\"ns0\">\r\n"
|
||||
// + " <xsl:output method=\"xml\" version=\"1.0\" encoding=\"UTF-8\" indent=\"yes\"/>\r\n"
|
||||
// + " <xsl:strip-space elements=\"*\"/>\r\n"
|
||||
// + " \r\n"
|
||||
// + " <xsl:template match=\"*\">\r\n"
|
||||
// + " <xsl:element name=\"{local-name()}\" namespace=http://tethys.sdsu.edu/schema/1.0>\r\n"
|
||||
// + " <xsl:apply-templates/>\r\n"
|
||||
// + " </xsl:element>\r\n"
|
||||
// + " </xsl:template>\r\n"
|
||||
// + " \r\n"
|
||||
// + " <xsl:template match=\"/ns0:Document\">\r\n"
|
||||
// + " <Document xmlns=http://tethys.sdsu.edu/schema/1.0 xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance> \r\n"
|
||||
// + " <xsl:apply-templates/>\r\n"
|
||||
// + " </Document>\r\n"
|
||||
// + " </xsl:template>\r\n"
|
||||
// + " \r\n"
|
||||
// + "</xsl:stylesheet>\r\n";
|
||||
// String xsltString = "<xsl:stylesheet version=\"1.0\" \r\n"
|
||||
// + " xmlns:xsl=http://www.w3.org/1999/XSL/Transform\r\n"
|
||||
// + " xmlns:ns0=http://mydata.com/H2H/Automation\r\n"
|
||||
// + " exclude-result-prefixes=\"ns0\">\r\n"
|
||||
// + " <xsl:output method=\"xml\" version=\"1.0\" encoding=\"UTF-8\" indent=\"yes\"/>\r\n"
|
||||
// + " <xsl:strip-space elements=\"*\"/>\r\n"
|
||||
// + " \r\n"
|
||||
// + " <xsl:template match=\"*\">\r\n"
|
||||
// + " <xsl:element name=\"{local-name()}\" namespace=http://tethys.sdsu.edu/schema/1.0>\r\n"
|
||||
// + " <xsl:apply-templates/>\r\n"
|
||||
// + " </xsl:element>\r\n"
|
||||
// + " </xsl:template>\r\n"
|
||||
// + " \r\n"
|
||||
// + " <xsl:template match=\"/ns0:Document\">\r\n"
|
||||
// + " <Document xmlns=http://tethys.sdsu.edu/schema/1.0 xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance> \r\n"
|
||||
// + " <xsl:apply-templates/>\r\n"
|
||||
// + " </Document>\r\n"
|
||||
// + " </xsl:template>\r\n"
|
||||
// + " \r\n"
|
||||
// + "</xsl:stylesheet>\r\n";
|
||||
String xsltString = "<xsl:stylesheet version=\"1.0\" \n"
|
||||
+ " xmlns:xsl=http://www.w3.org/1999/XSL/Transform\n"
|
||||
+ " xmlns:ns0=http://mydata.com/H2H/Automation\n"
|
||||
@ -266,19 +266,19 @@ public class AutoTethysProvider implements TethysDataProvider {
|
||||
+ "</xsl:stylesheet>\n";
|
||||
try {
|
||||
TransformerFactory factory = TransformerFactory.newInstance();
|
||||
// Source xslt = new StreamSource(new File("transform.xslt"));
|
||||
// Source xslt = new StreamSource(new File("transform.xslt"));
|
||||
StringReader reader = new StringReader(xmlNameSpace);
|
||||
Source xslt = new StreamSource(reader);
|
||||
|
||||
|
||||
Transformer transformer = factory.newTransformer(xslt);
|
||||
|
||||
DOMSource source = new DOMSource(doc);
|
||||
|
||||
// Result
|
||||
// Source text = new StreamSource(new File("input.xml"));
|
||||
DOMResult result = new DOMResult();
|
||||
DOMSource source = new DOMSource(doc);
|
||||
|
||||
// Result
|
||||
// Source text = new StreamSource(new File("input.xml"));
|
||||
DOMResult result = new DOMResult();
|
||||
transformer.transform(source, result);
|
||||
|
||||
|
||||
System.out.println(result.toString());
|
||||
}
|
||||
catch (Exception e) {
|
||||
@ -312,13 +312,13 @@ public class AutoTethysProvider implements TethysDataProvider {
|
||||
Detection detection = new Detection();
|
||||
detection.setStart(TethysTimeFuncs.xmlGregCalFromMillis(dataUnit.getTimeMilliseconds()));
|
||||
detection.setEnd(TethysTimeFuncs.xmlGregCalFromMillis(dataUnit.getEndTimeInMilliseconds()));
|
||||
|
||||
|
||||
DataBlockSpeciesManager speciesManager = pamDataBlock.getDatablockSpeciesManager();
|
||||
SpeciesMapItem speciesItem = null;
|
||||
if (speciesManager != null) {
|
||||
speciesItem = speciesManager.getSpeciesItem(dataUnit);
|
||||
// detection.setSpeciesId(new Species);
|
||||
// detection.setSpeciesId(getSpeciesIdType());
|
||||
// detection.setSpeciesId(new Species);
|
||||
// detection.setSpeciesId(getSpeciesIdType());
|
||||
}
|
||||
else {
|
||||
}
|
||||
@ -351,7 +351,7 @@ public class AutoTethysProvider implements TethysDataProvider {
|
||||
detParams.setReceivedLevelDB(ampli);
|
||||
// DataUnitBaseData basicData = dataUnit.getBasicData();
|
||||
gotTonalContour(dataUnit, detParams);
|
||||
|
||||
|
||||
String uid = BigInteger.valueOf(dataUnit.getUID()).toString();
|
||||
Element el = addUserDefined(detParams,"PAMGuardUID", uid);
|
||||
DataUnitFileInformation fileInf = dataUnit.getDataUnitFileInformation();
|
||||
@ -362,7 +362,7 @@ public class AutoTethysProvider implements TethysDataProvider {
|
||||
|
||||
return detection;
|
||||
}
|
||||
|
||||
|
||||
private Element addUserDefined(Parameters parameters, String parameterName, String parameterValue) {
|
||||
UserDefined userDefined = parameters.getUserDefined();
|
||||
if (userDefined == null) {
|
||||
@ -465,7 +465,7 @@ public class AutoTethysProvider implements TethysDataProvider {
|
||||
|
||||
kind.getSpeciesId().setValue(BigInteger.valueOf(mapItem.getItisCode()));
|
||||
kind.getGranularity().setValue(exportParams.granularity);
|
||||
// nilus.DetectionEffortKind.Parameters granularityParams = kind.getParameters();
|
||||
// nilus.DetectionEffortKind.Parameters granularityParams = kind.getParameters();
|
||||
switch (exportParams.granularity) {
|
||||
case BINNED:
|
||||
kind.getGranularity().setBinSizeM(exportParams.binDurationS/60.);
|
||||
@ -479,7 +479,7 @@ public class AutoTethysProvider implements TethysDataProvider {
|
||||
break;
|
||||
case GROUPED:
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
kind.setCall(mapItem.getCallType());
|
||||
|
||||
@ -487,7 +487,7 @@ public class AutoTethysProvider implements TethysDataProvider {
|
||||
effortKinds.add(kind);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -505,7 +505,7 @@ public class AutoTethysProvider implements TethysDataProvider {
|
||||
else {
|
||||
method = String.format("%s processing using the PAMGuard %s", dataAutomation.getAutomation(), pcu.getUnitType());
|
||||
}
|
||||
|
||||
|
||||
return method;
|
||||
}
|
||||
|
||||
@ -535,4 +535,23 @@ public class AutoTethysProvider implements TethysDataProvider {
|
||||
return documentName;
|
||||
}
|
||||
|
||||
public static double roundDecimalPlaces(double value, int decPlaces) {
|
||||
double scale = Math.pow(10, decPlaces);
|
||||
long longVal = Math.round(value*scale);
|
||||
return (double) longVal/scale;
|
||||
}
|
||||
|
||||
public static double roundSignificantFigures(double value, int sigFigs) {
|
||||
if (value == 0) {
|
||||
return 0;
|
||||
}
|
||||
double sign = Math.signum(value);
|
||||
value = Math.abs(value);
|
||||
double scale = sigFigs-Math.floor(Math.log10(value));
|
||||
scale = Math.pow(10, scale);
|
||||
long longVal = Math.round(value*scale);
|
||||
return sign*(double) longVal/scale;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -69,6 +69,8 @@ public interface TethysDataProvider {
|
||||
*/
|
||||
public GranularityEnumType[] getAllowedGranularities();
|
||||
|
||||
// public String getGranularityName GranularityEnumType);
|
||||
|
||||
/**
|
||||
* Get a name for the detections documents. This will be appended
|
||||
* to the Deployment name and may also have a number after it. <br>
|
||||
|
23
src/tethys/species/FixedSpeciesManager.java
Normal file
23
src/tethys/species/FixedSpeciesManager.java
Normal file
@ -0,0 +1,23 @@
|
||||
package tethys.species;
|
||||
|
||||
import PamguardMVC.PamDataBlock;
|
||||
import PamguardMVC.PamDataUnit;
|
||||
|
||||
public class FixedSpeciesManager<T extends PamDataUnit> extends DataBlockSpeciesManager<T> {
|
||||
|
||||
|
||||
public FixedSpeciesManager(PamDataBlock dataBlock, int itisCode, String name, String callType) {
|
||||
super(dataBlock);
|
||||
setDefaultDefaultSpecies(new SpeciesMapItem(itisCode, name, callType));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataBlockSpeciesCodes getSpeciesCodes() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSpeciesCode(T dataunit) {
|
||||
return getDefaultSpeciesCode();
|
||||
}
|
||||
}
|
@ -64,6 +64,10 @@ public class GranularityCard extends ExportWizardCard {
|
||||
granPanel.setBorder(new TitledBorder("Granularity"));
|
||||
ButtonGroup granGroup = new ButtonGroup();
|
||||
GranularityChange gc = new GranularityChange();
|
||||
binLength = new JTextField(5);
|
||||
minBinnedCalls = new JTextField(5);
|
||||
encounterGap = new JTextField(5);
|
||||
minEncounterCalls = new JTextField(5);
|
||||
for (int i = 0; i < allowedGranularities.length; i++) {
|
||||
c.gridx = 0;
|
||||
granularities[i] = new JRadioButton(PGranularityType.prettyString(allowedGranularities[i]));
|
||||
@ -76,11 +80,11 @@ public class GranularityCard extends ExportWizardCard {
|
||||
c.gridx++;
|
||||
granPanel.add(new JLabel(" Bin duration ", JLabel.RIGHT), c);
|
||||
c.gridx++;
|
||||
granPanel.add(binLength = new JTextField(5), c);
|
||||
granPanel.add(binLength, c);
|
||||
c.gridx++;
|
||||
granPanel.add(new JLabel("(s), Min Calls", JLabel.LEFT), c);
|
||||
c.gridx++;
|
||||
granPanel.add(minBinnedCalls = new JTextField(5), c);
|
||||
granPanel.add(minBinnedCalls, c);
|
||||
binLength.setToolTipText("Time bin duration in seconds");
|
||||
minBinnedCalls.setToolTipText("Minimum number of calls for a bin to be output");
|
||||
}
|
||||
@ -89,11 +93,11 @@ public class GranularityCard extends ExportWizardCard {
|
||||
c.gridx++;
|
||||
granPanel.add(new JLabel(" Minimum gap ", JLabel.RIGHT), c);
|
||||
c.gridx++;
|
||||
granPanel.add(encounterGap = new JTextField(5), c);
|
||||
granPanel.add(encounterGap, c);
|
||||
c.gridx++;
|
||||
granPanel.add(new JLabel("(s), Min Calls", JLabel.LEFT), c);
|
||||
c.gridx++;
|
||||
granPanel.add(minEncounterCalls = new JTextField(5), c);
|
||||
granPanel.add(minEncounterCalls, c);
|
||||
encounterGap.setToolTipText("Minimum gap between separate encounters");
|
||||
minEncounterCalls.setToolTipText("Minimum number of calls for an encounter to be output");
|
||||
}
|
||||
|
@ -2,15 +2,20 @@ package whistlesAndMoans;
|
||||
|
||||
import whistlesAndMoans.alarm.WMAlarmCounterProvider;
|
||||
import whistlesAndMoans.dataSelector.WMDDataSelectCreator;
|
||||
import whistlesAndMoans.species.WhistleMoanTethysProvider;
|
||||
import whistlesAndMoans.species.WhistleSpeciesManager;
|
||||
import whistlesAndMoans.toad.WSLToadCalculator;
|
||||
import PamView.GroupedDataSource;
|
||||
import PamView.GroupedSourceParameters;
|
||||
import PamguardMVC.DataAutomation;
|
||||
import PamguardMVC.DataAutomationInfo;
|
||||
import PamguardMVC.FFTDataHolderBlock;
|
||||
import PamguardMVC.dataSelector.DataSelectorCreator;
|
||||
import PamguardMVC.toad.TOADCalculator;
|
||||
import alarm.AlarmCounterProvider;
|
||||
import alarm.AlarmDataSource;
|
||||
import tethys.TethysControl;
|
||||
import tethys.pamdata.TethysDataProvider;
|
||||
import tethys.species.DataBlockSpeciesManager;
|
||||
|
||||
public class ConnectedRegionDataBlock extends AbstractWhistleDataBlock<ConnectedRegionDataUnit> implements AlarmDataSource, GroupedDataSource, FFTDataHolderBlock {
|
||||
@ -21,6 +26,7 @@ public class ConnectedRegionDataBlock extends AbstractWhistleDataBlock<Connected
|
||||
private WMDDataSelectCreator dataSelectCreator;
|
||||
private WSLToadCalculator wslToadCalculator;
|
||||
private WhistleSpeciesManager whistleSpeciesManager;
|
||||
private WhistleMoanTethysProvider whistleTethysProvider;
|
||||
|
||||
public ConnectedRegionDataBlock(String dataName,
|
||||
WhistleMoanControl whistleMoanControl, WhistleToneConnectProcess parentProcess, int channelMap) {
|
||||
@ -97,6 +103,19 @@ public class ConnectedRegionDataBlock extends AbstractWhistleDataBlock<Connected
|
||||
return whistleSpeciesManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TethysDataProvider getTethysDataProvider(TethysControl tethysControl) {
|
||||
if (whistleTethysProvider == null) {
|
||||
whistleTethysProvider = new WhistleMoanTethysProvider(tethysControl, this);
|
||||
}
|
||||
return whistleTethysProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataAutomationInfo getDataAutomationInfo() {
|
||||
return new DataAutomationInfo(DataAutomation.AUTOMATIC);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
13
src/whistlesAndMoans/species/WhistleMoanTethysProvider.java
Normal file
13
src/whistlesAndMoans/species/WhistleMoanTethysProvider.java
Normal file
@ -0,0 +1,13 @@
|
||||
package whistlesAndMoans.species;
|
||||
|
||||
import PamguardMVC.PamDataBlock;
|
||||
import tethys.TethysControl;
|
||||
import tethys.pamdata.AutoTethysProvider;
|
||||
|
||||
public class WhistleMoanTethysProvider extends AutoTethysProvider {
|
||||
|
||||
public WhistleMoanTethysProvider(TethysControl tethysControl, PamDataBlock pamDataBlock) {
|
||||
super(tethysControl, pamDataBlock);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user