Package difar

Class DifarDataUnit

All Implemented Interfaces:
Comparable<PamDataUnit>, PamDetection, AcousticDataUnit, RawDataHolder

public class DifarDataUnit extends ClipDataUnit
  • Constructor Details

    • DifarDataUnit

      public DifarDataUnit(long clipStartMillis, long triggerMilliseconds, long startSample, int durationSamples, int channelMap, String fileName, String triggerName, double[][] rawData, long signalStartMillis, PamDataUnit parentDetection, double[] frequencyRange, float sourceSampleRate, float displaySampleRate, double[] calFreqs, double[] calGains)
      Constructor to use if storing data into the binary system.
      Parameters:
      triggerMilliseconds -
      startSample -
      durationSamples -
      channelMap -
      fileName -
      triggerName -
      rawData -
      timeMilliseconds -
      upperFreq -
  • Method Details

    • decimateData

      public static double[] decimateData(double[] ds, float origSmp, float displaySampRate)
    • setFrequencyResponse

      public void setFrequencyResponse(double[] f, double[] gain)
    • getParentDetection

      public PamDataUnit getParentDetection()
    • setParentDetection

      public void setParentDetection(PamDataUnit parentDetection)
    • getMultiplexedData

      public double[] getMultiplexedData()
    • getSignalStart

      public long getSignalStart()
      Signal start time in milliseconds relative to start of sound.
      Returns:
      signal start time in milliseconds
    • getSurfaceData

      public double[][] getSurfaceData()
    • setSurfaceData

      public void setSurfaceData(double[][] surfaceData)
    • isVessel

      public boolean isVessel()
      Returns:
      the isVessel
    • setVessel

      public void setVessel(boolean isVessel)
      Parameters:
      isVessel - the isVessel to set
    • getLutSpeciesItem

      public LookupItem getLutSpeciesItem()
      Returns:
      the lutSpeciesItem
    • setLutSpeciesItem

      public void setLutSpeciesItem(LookupItem lutSpeciesItem)
      Parameters:
      lutSpeciesItem - the lutSpeciesItem to set
    • getDisplaySampleRate

      public float getDisplaySampleRate()
      Overrides:
      getDisplaySampleRate in class ClipDataUnit
      Returns:
      the displaySampleRate
    • setDisplaySampleRate

      public void setDisplaySampleRate(float displaySampleRate)
      Parameters:
      displaySampleRate - the displaySampleRate to set
    • getSelectedAngle

      public Double getSelectedAngle()
      Get the angle selectedfrom the DIFARGram. Note that this is the angle relative to the DIFAR buoy and is therefore a MAGNETIC angle. If you want an angle corrected for magnetic deviation, use getTrueAngle();
      Returns:
      the selectedAngle
    • getRange

      public Double getRange()
    • getTrueAngle

      public Double getTrueAngle()
      Get the true bearing relative to the DIFAR buoy. This is the selected angle (see getSelectedAngle() + the local magnetic deviation calulcated from the World Magnetic Model. For map display, this bearing may be further corrected for any offset in the buoy heading in the array manager. If there is no offset in the arraymanager, then return the magnetic bearing since returning null for the trueBearing may cause problems down the line.
      Returns:
      true angle (if the buoy is orientated right !)
    • getTrackedGroup

      public String getTrackedGroup()
    • setTrackedGroup

      public void setTrackedGroup(String newGroup)
    • setSelectedAngle

      public void setSelectedAngle(Double selectedAngle)
      Set the selected angle from the DIFARGram. Note that this is the angle relative to the DIFAR buoy and is therefore a MAGNETIC angle.
      Parameters:
      selectedAngle - the selectedAngle to set
    • calculateDifarGain

      public Double calculateDifarGain()
      Now also work out the DIFAR gain for that angle. This means taking the closest point in the summary line and seeing what it's value is for that angle
      Returns:
      gain.
    • calculateDifarGain

      public Double calculateDifarGain(Double selectedAngle, Double selectedFrequency)
      Calculate teh DIFAR gain for a given angle and frequency
      Parameters:
      selectedAngle - angle 0 - 360
      selectedFrequency - Frequency Hz
      Returns:
      gain
    • getSelectedFrequency

      public Double getSelectedFrequency()
      Returns:
      the selectedFrequency
    • setSelectedFrequency

      public void setSelectedFrequency(Double selectedFrequency)
      Parameters:
      selectedFrequency - the selectedFrequency to set
    • getSurfaceSummary

      public double[] getSurfaceSummary()
      Returns:
      the surfaceSummary
    • setSurfaceSummary

      public void setSurfaceSummary(double[] surfaceSummary)
      Parameters:
      surfaceSummary - the surfaceSummary to set
    • getMaximumAngleSummary

      public double[] getMaximumAngleSummary()
      Returns:
      the maximumAngleSummary
    • setMaximumAngleSummary

      public void setMaximumAngleSummary(double[] surfaceSummary)
      Parameters:
      surfaceSummary - the surfaceSummary to set
    • getMaximumAngle

      public Double getMaximumAngle()
      Returns:
      the maximumAngle
    • setMaximumAngle

      public void setMaximumAngle(Double maximumAngle)
      Parameters:
      maximumAngle - the maximumAngle to set
    • getMaximumFrequency

      public Double getMaximumFrequency()
      Returns:
      the maximumFrequency
    • setMaximumFrequency

      public void setMaximumFrequency(Double maximumFrequency)
      Parameters:
      maximumFrequency - the maximumFrequency to set
    • setSpectrogramSensor

      public void setSpectrogramSensor(int spectrogramSensor)
      Choice of data for spectrogram displays.
      0 = decimated original data.
      1 = Omni demuxed
      2 = EW demuxed
      3 = NS demuxed
      Parameters:
      spectrogramSensor - the spectrogramSensor to set
    • getDemuxedDecimatedData

      public double[][] getDemuxedDecimatedData()
      Returns:
      the demuxedDecimatedData
    • setDemuxedDecimatedData

      public void setDemuxedDecimatedData(double[][] demuxedDecimatedData)
      Parameters:
      demuxedDecimatedData - the demuxedDecimatedData to set
    • getClipImage

      public BufferedImage getClipImage(int spectrogramImageChoice, int iChannel, int fftLen, int fftHop, double scaleMin, double scaleMax, Color[] colours)
      Get a clip image for a particular wave type - decimated original, Om, EW, NS
      Parameters:
      spectrogramImageChoice -
      iChannel -
      fftLen -
      fftHop -
      scaleMin -
      scaleMax -
      colours -
      Returns:
    • getSpeciesName

      public String getSpeciesName()
      Returns:
      null, Vessel or the long name from the lookup
    • getSpeciesCode

      public String getSpeciesCode()
      Get a species code - mostly used by the database.
      Returns:
      a species code (the shorter bit from the lookup table) TODO: Store species parameters with each data unit
    • setSpeciesCode

      public void setSpeciesCode(LookupList speciesList, String speciesCode)
      Called in viewer when data are read back from binary store to sort out the species luukup item.
      Parameters:
      speciesList - list of programmed species codes
      speciesCode - data units code or "Vessel"
    • decimateLockArray

      public static boolean[] decimateLockArray(boolean[] lockInput, float origSmp, float displaySampRate)
      Parameters:
      lock_15 -
      sampleRate -
      displaySampleRate2 -
    • getDifarGain

      public Double getDifarGain()
      Returns:
      the difarGain
    • setDifarGain

      public void setDifarGain(double difarGain)
      Parameters:
      difarGain - the difarGain to set
    • setLockDecimatedData

      public void setLockDecimatedData(boolean[][] lockArrays)
      Set the lock array iformation in the data unit. This is a 2xn boolean array of the 7.5 and 15kHz locks, decimated to the same freqeuncy as the demuxed audio data.
      Parameters:
      lockArrays - TODO: Move all lock related code into the Greeneridge demux
    • getLockDecimatedData

      public boolean[][] getLockDecimatedData()
    • cleanUpData

      public void cleanUpData()
      Gets called just before unit is added to processed data. Some things are no longer needed at this point, so can clean them up.
    • getDurationInSeconds

      public double getDurationInSeconds()
      Used by some displays
      Returns:
    • getSummaryString

      public String getSummaryString()
      Description copied from class: PamDataUnit
      Return an html formatted summary string describing the detection which can be used in tooltips anywhere in PAMGuard.
      Overrides:
      getSummaryString in class ClipDataUnit
      Returns:
      summary string
    • getPreMarkSeconds

      public double getPreMarkSeconds()
      Returns:
      the Number of seconds added to the sound prior to the specrogram mark or detection.
    • setPreMarkSeconds

      public void setPreMarkSeconds(double preMarkSeconds)
      Parameters:
      the - Number of seconds added to the sound prior to the specrogram mark or detection
    • getClipStartMillis

      public long getClipStartMillis()
      Returns:
      the clipStartMillis. This is the start of the clip - which will generally have been put afew secs before the actual sound.
    • canAutoProcess

      public boolean canAutoProcess()
      Autoprocess everything except "Default" clips
      Returns:
    • cancelAutoSave

      public void cancelAutoSave()
      //this is a bit pointless now as action performed doesn't attempt save if timer is stopped
      Parameters:
      sets - canAutoSave false
    • canAutoSave

      public boolean canAutoSave()
      //this is a bit pointless now as action performed doesn't attempt save if timer is stopped whether the difar unit has been interacted with causing autosave to be inapropriate
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • saveCrossing

      public void saveCrossing(boolean save)
      Move the crossing info from it's temp position to a saved position. Called just at the point when the difar unit is saved and moved from the queue to the output data block.
      Parameters:
      save - - save it, or discard it (also from other units associated with this crossing
    • getDifarCrossing

      public DIFARCrossingInfo getDifarCrossing()
      Returns:
      the crossing point when multiple matching DIFAR bearings are crossed.
    • setDifarCrossing

      public void setDifarCrossing(DIFARCrossingInfo difarCrossing)
      Parameters:
      difarCrossing - the difarCrossing to set
    • getTempCrossing

      public DIFARCrossingInfo getTempCrossing()
      Returns:
      the tempCrossing
    • setTempCrossing

      public void setTempCrossing(DIFARCrossingInfo tempCrossing)
      Parameters:
      tempCrossing - the tempCrossing to set
    • getTempGroup

      public String getTempGroup()
      Returns:
      the tempCrossing
    • setTempGroup

      public void setTempGroup(String tempGroup)
      Parameters:
      tempCrossing - the tempCrossing to set
    • getOriginLatLong

      public GpsData getOriginLatLong(boolean recalculate)
      Description copied from class: PamDataUnit
      Get the latlong of the mean hydrophone position at the time of this detection. If the data unit has a channel bitmap of zero, then get the GPS position of the vessel at that time.
      Overrides:
      getOriginLatLong in class PamDataUnit<PamDataUnit,SuperDetection>
      Returns:
      Lat long of detection origin (usually the position of the reference hydrophone at time of detection)
    • saveGroup

      public void saveGroup()
    • getCalibratedSpectrogramData

      public double[][] getCalibratedSpectrogramData(int channel, int fftLength, int fftHop)
      Return a spectrogram clip that has calibrated intensity Intensity is "calibrated" using an arbitrary filter to correct for the DIFAR frequency response.
      Parameters:
      fftLength -
      fftHop -
      i -
      Returns:
    • updateDataUnit

      public void updateDataUnit(long updateTime)
      Overrides:
      updateDataUnit in class PamDataUnit<PamDataUnit,SuperDetection>