Class GranularityHandler

java.lang.Object
tethys.detection.GranularityHandler
Direct Known Subclasses:
BinnedGranularityHandler, CallGranularityHandler, EncounterGranularityHandler

public abstract class GranularityHandler extends Object
  • Field Details Link icon

  • Constructor Details Link icon

  • Method Details Link icon

    • prepare Link icon

      public abstract void prepare(long timeMillis)
      Prepare to start, passing the start time of the effort or of the first time bin for binned granularity types.
      Parameters:
      timeMillis -
    • addDataUnit Link icon

      public abstract nilus.Detection[] addDataUnit(PamDataUnit dataUnit)
      Put a data unit into a Detection object. for Call granularity this will probably return every time. For binned and encounter types this will only return at the end of a bin / encounter
      Parameters:
      dataUnit -
      Returns:
      Detection object, but only when ready to be added to Detections
    • getCallGroupName Link icon

      public String getCallGroupName(PamDataUnit dataUnit)
      Get a grouping name for the call. This may just be the calls species code, or it may be appended with the channel number. This is used to find bin and encounter data in HashMaps in
      Parameters:
      dataUnit -
      Returns:
    • cleanup Link icon

      public abstract nilus.Detection[] cleanup(long timeMillis)
      Called after end end of all data units to get the last bin / encounter.

      Parameters:
      timeMillis - end time of effort or last bin in milliseconds.
      Returns:
      null for Call granularity, otherwise may be non null for binned or encounter.
    • toDetectionArray Link icon

      protected nilus.Detection[] toDetectionArray(nilus.Detection det)
      Convert a single detection to a one element array since that's what' most functions need to return.
      Parameters:
      det -
      Returns:
    • getHandler Link icon

      public static GranularityHandler getHandler(nilus.GranularityEnumType granularity, TethysControl tethysControl, PamDataBlock dataBlock, TethysExportParams tethysExportParams, StreamExportParams streamExportParams)
      Create the correct type of granularity handler to put individual data units into Detection objects.
      Parameters:
      granularity -
      tethysControl -
      dataBlock -
      tethysExportParams -
      streamExportParams -
      Returns:
    • autoEffortFix Link icon

      protected abstract boolean autoEffortFix(nilus.Detections detections, nilus.Detection det)
      Automatically fix mismatches between effort and detections. This will be called if a detection or part of a detection is outside of the start and end defined by the effort. If it's a small difference, i.e. if the detection at least overlaps the effort then it can be automatically fixed by truncating the detection (for binned types) or by a small extension to the effort (for encounter and call types).
      Parameters:
      detections - nilus Detections object
      det - a single detection
      Returns:
      true if it was fixed automatically. False otherwise.
    • effortOverlap Link icon

      protected boolean effortOverlap(nilus.Detections detections, nilus.Detection det)
      Check that the detection at least overlaps the effort period.
      Parameters:
      detections - nilus Detections object
      det - a single detection
      Returns:
      true if the overlap
    • addChannelsToMap Link icon

      protected int addChannelsToMap(nilus.Detection detection, int channelMap)
      Function used when creating encounter and binned level detections. During the building of these, we need to accumulate a channel map. Then at the end of the encounter or bin, we're going to call a different function to change the channel number to the lowest and also set the channel map as a user field.
      Parameters:
      detection -
      channelMal -
      Returns:
    • finaliseChannels Link icon

      protected int finaliseChannels(nilus.Detection detection)
      Called to convert a channel map to a lowest channel and to add a user field for the channel map to the detection.
      Only use this if you're sure you've been accumulating channel maps, not setting channel numbers as you created detections.
      Returns:
      current overall map/
    • contractDetection Link icon

      protected boolean contractDetection(nilus.Detections detections, nilus.Detection det)
      Fix effort / detection problem but contracting the start / end times of the detection
      Parameters:
      detections - nilus Detections object
      det - a single detection
      Returns:
      true if fixed automatically
    • expandEffort Link icon

      protected boolean expandEffort(nilus.Detections detections, nilus.Detection det)
      Fix effort / detection problem but expanding the start / end times of the effort
      Parameters:
      detections - nilus Detections object
      det - a single detection
      Returns:
      true if fixed automatically