Package difar

Class DifarProcess

All Implemented Interfaces:
PamObserver, ProcessAnnotator

public class DifarProcess extends PamProcess
  • Constructor Details

    • DifarProcess

      public DifarProcess(DifarControl difarControl)
  • Method Details

    • newData

      public void newData(PamObservable o, PamDataUnit arg)
      Overrides:
      newData in class PamProcess
    • queueDemuxProcess

      public void queueDemuxProcess(DifarDataUnit difarDataUnit)
      Send a difar unit off for processing in a worker thread. For now, only allow one of these, but may consider having more in the future.
      Parameters:
      difarDataUnit -
    • processDifarUnit

      public void processDifarUnit(DifarDataUnit difarDataUnit, difar.DifarProcess.DifarDemuxWorker demuxWorker)
      Process a queued data unit - in normal operation, this involves first demuxing and decimating the data in order to get the waveforms for the three sensors, then calculating the difargram.
      In viewer mode the demux stage can be skipped since only teh decimated demuxed data were stored in the first place.

      This is called from within a SwingWorker thread, and can call back through that SwingWorker to update on progress.

      Parameters:
      difarDataUnit -
      demuxWorker -
    • estimateTrackedGroup

      public void estimateTrackedGroup(DifarDataUnit difarDataUnit)
      Match the selected bearing to the nearest mean-bearing to a group, and Make sure that the matching group is highlighted in the groups panel.
      Parameters:
      difarDataUnit -
    • difarGridToDegrees

      public double difarGridToDegrees(DifarDataUnit difarDataUnit, double difarGridPos)
      Convert a point on the difar grid to an angle in degrees.
      Parameters:
      difarGridPos - position on Grid (double since may interpolate)
      difarDataUnit2 -
      Returns:
      angle in degrees
    • difarGridToFrequency

      public double difarGridToFrequency(DifarDataUnit difarDataUnit, double gridPos)
      Parameters:
      difarDataUnit - difar data unit.
      gridPos - grid position
      Returns:
      Frequency in Hz.
    • difarGridToFrequency

      public double difarGridToFrequency(int nFreqPoints, double niquist, double gridPos)
      convert a difar grid position to a freqeuncy.
      Parameters:
      nFreqPoints - number of frequency points in the grid
      niquist - niquist frequency for the decimated data
      gridPos - grid position
      Returns:
      Frequency in Hz.
    • createSummaryLine

      public double[] createSummaryLine(DifarDataUnit difarDataUnit, double[] freqRange)
      Create a single line summary of DIFAR level against angle within a selected frequency range
      Parameters:
      difarDataUnit -
      freqRange -
      Returns:
    • createMaxAngleSummary

      public double[] createMaxAngleSummary(DifarDataUnit difarDataUnit, double[] freqRange)
      Create a summary of angles with maximum DIFAR level for each frequency
      Parameters:
      difarDataUnit -
      freqRange -
      Returns:
    • getRequiredDataHistory

      public long getRequiredDataHistory(PamObservable o, Object arg)
      Specified by:
      getRequiredDataHistory in interface PamObserver
      Overrides:
      getRequiredDataHistory in class PamProcess
      Parameters:
      arg - optional argument from PamObservable
      Returns:
      time in milliseconds required by data held in PamObservable
    • startBuoyCalibration

      public void startBuoyCalibration(int channel)
      Start a buoy calibration on a specified channel
      Parameters:
      channel - channel number
    • doBuoyCalibration

      public Long doBuoyCalibration(int buoyCalibrationChannel, long endSample)
      Grab a clip for the latest buoy calibration data.
      Parameters:
      buoyCalibrationChannel2 -
    • setupProcess

      public void setupProcess()
      Description copied from class: PamProcess
      called for every process once the systemmodel has been created. this is a good time to check out and find input data blocks and similar tasks.
      Overrides:
      setupProcess in class PamProcess
    • subscribeDataBlocks

      public void subscribeDataBlocks()
      Look through the list of data blocks that could contain DIFAR detections, and subscribe to them according to the difarParameters
    • getNumTriggers

      public int getNumTriggers()
      Returns:
      the total number of Detectors usable by the DIFAR module.
    • pamStart

      public void pamStart()
      Description copied from class: PamProcess
      Called for each process to tell it to start (may not be necessary for processes which are listening for data anyway).
      Specified by:
      pamStart in class PamProcess
    • pamStop

      public void pamStop()
      Description copied from class: PamProcess
      Stops the process.
      Specified by:
      pamStop in class PamProcess
    • getAutoSaveTimer

      public Timer getAutoSaveTimer()
      Returns:
      the autoSaveTimer
    • setDataKeepTimes

      public void setDataKeepTimes()
    • clearOldData

      public void clearOldData()
      Description copied from class: PamProcess
      Clears all data from all output data blocks of this process.
      This gets called from the main controller at the start of operations. Can be overridden in some classes which don't want to delete existing data or they can set the clearAtStart flag in any data block.
      Overrides:
      clearOldData in class PamProcess
    • difarTrigger

      public void difarTrigger(int channelMap, long signalStartMillis, long durationMillis, double[] f, PamDataUnit pamDetection, double displaySampleRate, String triggerSpeciesName, String triggerDataBlockName)
      Called when there is a trigger caused whether by a detection or by a mark being made on the spectrogram.
      Parameters:
      signalStartMillis - start time in milliseconds
      durationMillis - duration in milliseconds
      triggerSpeciesName -
      triggerDataBlockName -
      channel - (for detections)
      f1 - min frequency
      f2 - max frequency
      PamDataUnit - associated detection (null for spectrogram marks).
      upperFreq -
    • getQueuedDifarData

      public DifarDataBlock getQueuedDifarData()
    • getProcessedDifarData

      public DifarDataBlock getProcessedDifarData()
    • notifyModelChanged

      public void notifyModelChanged(int changeType)
      Overrides:
      notifyModelChanged in class PamProcess
    • finalProcessing

      public void finalProcessing(DifarDataUnit difarDataUnit)
      Do any final processing of the DIFAR data unit and add it to the datablock.
      Save the data unit - but depending on the type of unit (whale or vessel) if it's a vessel data unit, will work out where the boats prop was when that unit was created and work out how much angle correction to apply to the array manager for the corresponding offset.
      Parameters:
      difarDataUnit - DIFAR data unit
    • getDifarRangeInfo

      public DIFARCrossingInfo getDifarRangeInfo(DifarDataUnit difarDataUnit)
      Called just before a difar unit is stored. Looks at other channels that have recently had a data unit stored and decides whether or not they are likely to be the same vocalisation. If they are, calculate a crossed bearing to them both. If > 2 channels do some kind of optimised fit.
      Parameters:
      difarDataUnit -
      Returns:
      information about the range (will already have been put into affected units)
    • rangeForDataType

      public double rangeForDataType(DifarDataUnit difarDataUnit)
      Get a display range for a particular data unit, as will be used by the map. Currently there is only one value which is fixed in the parameters.
      Parameters:
      difarDataUnit -
      Returns:
      a range in metres.
    • getWhaleRange

      public double getWhaleRange(DifarDataUnit difarDataUnit, double nominalSourceLevel)
    • getDisplayFFTLength

      public int getDisplayFFTLength(DifarDataUnit difarDataUnit)
      Get the display FFT length, which may depend on the type of data unit.
      Returns:
      FFT length for data display.
    • getDisplayFFTHop

      public int getDisplayFFTHop(DifarDataUnit difarDataUnit)
    • getCalibrationProcess

      public CalibrationProcess getCalibrationProcess(int channel)
      Get the calibration sub-process for a specific channel.
      Parameters:
      channel -
      Returns:
      calibration process.
    • getCalTrueBearingHistogram

      public CalibrationHistogram getCalTrueBearingHistogram(int channel)
      Get the calibration true bearing histogram for a channel.
      Parameters:
      channel - channel number (0 - 31)
      Returns:
      calibration histogram.
    • getCalCorrectionHistogram

      public CalibrationHistogram getCalCorrectionHistogram(int channel)
      Get the calibration true bearing histogram for a channel.
      Parameters:
      channel - channel number (0 - 31)
      Returns:
      calibration histogram.
    • cancelAutoSaveTimer

      public void cancelAutoSaveTimer()
    • setAutoSaveTimer

      public void setAutoSaveTimer(difar.DifarProcess.AutoSaveTimer autoSaveTimer)
    • getCalibrationDataBlock

      public CalibrationDataBlock getCalibrationDataBlock()
    • setCalibrationDataBlock

      public void setCalibrationDataBlock(CalibrationDataBlock calibrationData)