Package tethys.detection
Class GranularityHandler
java.lang.Object
tethys.detection.GranularityHandler
- Direct Known Subclasses:
BinnedGranularityHandler
,CallGranularityHandler
,EncounterGranularityHandler
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected PamDataBlock
protected StreamExportParams
protected TethysControl
protected TethysExportParams
-
Constructor Summary
ConstructorsConstructorDescriptionGranularityHandler
(TethysControl tethysControl, PamDataBlock dataBlock, TethysExportParams tethysExportParams, StreamExportParams streamExportParams) -
Method Summary
Modifier and TypeMethodDescriptionprotected int
addChannelsToMap
(nilus.Detection detection, int channelMap) Function used when creating encounter and binned level detections.abstract nilus.Detection[]
addDataUnit
(PamDataUnit dataUnit) Put a data unit into a Detection object.protected abstract boolean
autoEffortFix
(nilus.Detections detections, nilus.Detection det) Automatically fix mismatches between effort and detections.abstract nilus.Detection[]
cleanup
(long timeMillis) Called after end end of all data units to get the last bin / encounter.protected boolean
contractDetection
(nilus.Detections detections, nilus.Detection det) Fix effort / detection problem but contracting the start / end times of the detectionprotected boolean
effortOverlap
(nilus.Detections detections, nilus.Detection det) Check that the detection at least overlaps the effort period.protected boolean
expandEffort
(nilus.Detections detections, nilus.Detection det) Fix effort / detection problem but expanding the start / end times of the effortprotected 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.getCallGroupName
(PamDataUnit dataUnit) Get a grouping name for the call.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.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.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.
-
Field Details
-
Constructor Details
-
GranularityHandler
public GranularityHandler(TethysControl tethysControl, PamDataBlock dataBlock, TethysExportParams tethysExportParams, StreamExportParams streamExportParams) - Parameters:
tethysControl
-dataBlock
-tethysExportParams
-streamExportParams
-
-
-
Method Details
-
prepare
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
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
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
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
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
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
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 objectdet
- a single detection- Returns:
- true if it was fixed automatically. False otherwise.
-
effortOverlap
protected boolean effortOverlap(nilus.Detections detections, nilus.Detection det) Check that the detection at least overlaps the effort period.- Parameters:
detections
- nilus Detections objectdet
- a single detection- Returns:
- true if the overlap
-
addChannelsToMap
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
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
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 objectdet
- a single detection- Returns:
- true if fixed automatically
-
expandEffort
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 objectdet
- a single detection- Returns:
- true if fixed automatically
-