Package rocca

Class RoccaSightingDataUnit

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

public class RoccaSightingDataUnit extends PamDataUnit<PamDataUnit,PamDataUnit> implements PamDetection
Container holding information about the current sighting, including pointers to the contours already measured
Author:
Michael Oswald
  • Field Details

  • Constructor Details

    • RoccaSightingDataUnit

      public RoccaSightingDataUnit(long timeMilliseconds, int channelBitmap, long startSample, long duration, String sNum, JLabel[] speciesList, RoccaControl roccaControl)
      Create a new RoccaSightingDataUnit serialVersionUID=22 2015/06/13 added roccaControl serialVersionUID=24 2016/08/10 added call to setLatLong
      Parameters:
      timeMilliseconds -
      channelBitmap -
      startSample -
      duration -
      sNum - the current sighting number
      speciesList - a JLabel array containing the species list.
      roccaControl -
    • RoccaSightingDataUnit

      public RoccaSightingDataUnit(long timeMilliseconds, int channelBitmap, long startSample, long duration, String sNum, String[] speciesList, RoccaControl roccaControl)
      Create a new RoccaSightingDataUnit serialVersionUID=22 2015/06/13 added roccaControl serialVersionUID=24 2016/08/10 added call to setLatLong
      Parameters:
      timeMilliseconds -
      channelBitmap -
      startSample -
      duration -
      sNum - the current sighting number
      speciesList - a String array containing the species list.
      roccaControl -
    • RoccaSightingDataUnit

      public RoccaSightingDataUnit(long timeMilliseconds, int channelBitmap, long startSample, long duration, RoccaControl roccaControl)
      Create a new RoccaSightingDataUnit. This constructor is used primarily when the sidePanel is created and the user loads the classifier, but no sighting number exists yet. serialVersionUID=22 2015/06/13 added roccaControl serialVersionUID=24 2016/08/10 added call to setLatLong
      Parameters:
      timeMilliseconds -
      channelBitmap -
      startSample -
      duration -
      roccaControl -
  • Method Details

    • setLatLong

      public void setLatLong()
      Calls the GPS routines to set latitude and longitude, if the user has set it up
    • getSightNum

      public String getSightNum()
    • setSightNum

      public void setSightNum(String sightNum)
    • setSpecies

      public void setSpecies(String[] speciesAsString)
      Creates a new list of species and sets the counts to 0. This method will add 'Ambig' to the species list, if it isn't already included.
      Parameters:
      speciesAsString - a string array of species names (max 5 characters).
    • validateSpeciesList

      public static String[] validateSpeciesList(String[] speciesAsString)
      Checks the passed String array for 'Ambig' (RoccaClassifier.AMBIG). If it's there, the array is returned without any changes. If it's not there, it is added to the beginning of the array and the new array is returned.

      Note that this method is static, so calls to it do not need a specific RoccaSightingDataUnit instance. This was done to make it easier to call from the RoccaSpecPopUp object, which does not see any instances. 2021/05/11 renamed method and added check for no classifier

      Parameters:
      speciesAsString -
      Returns:
    • clearCounts

      public void clearCounts()
      clear the counts for the species list
    • getSpecies

      public JLabel[] getSpecies()
      returns the species list as a JLabel array
      Returns:
      a JLabel array containing the species list
    • getSpeciesAsString

      public String[] getSpeciesAsString()
      returns the species list as a String array
      Returns:
      a String array containing the species list
    • getSpeciesClassCount

      public int[] getSpeciesClassCount()
      Returns the classification counts for the current species list
      Returns:
      an int array containing the classification counts
    • getClassCount

      public int getClassCount(int speciesNum)
      Returns the classification count for a single species
      Parameters:
      speciesNum - the index of the desired species count
      Returns:
      the classification count
    • setSpeciesClassCount

      public void setSpeciesClassCount(int[] speciesClassCount)
      Sets all the species counts.
      Parameters:
      speciesClassCount - an int array with the counts for each species. The length of the array must match the length of the species list
    • incSpeciesCount

      public void incSpeciesCount(int speciesToInc)
      Increments a specific species classification count. DO NOT USE THIS METHOD - use incSpeciesCount(int, double, double, boolean) method instead
      Parameters:
      speciesToInc - the index of the species to increment
    • incSpeciesCount

      public void incSpeciesCount(int speciesToInc, double startTime)
      Increment a specific species classification count, and save the starting time. Note that the starting time is passed in milliseconds, but converted to seconds before saving. serialVersionUID=15 2014/11/12 DO NOT USE THIS METHOD - use incSpeciesCount(int, double, double , boolean) method instead
      Parameters:
      speciesToInc -
      startTime - the starting time of the whistle, in milliseconds
    • incSpeciesCount

      public void incSpeciesCount(int speciesToInc, double startTime, double dur, boolean isClick)
      Increment a specific species classification count, and save the starting time and duration. Note that both the starting time and duration are passed in milliseconds, but converted to seconds before saving. serialVersionUID=22 2015/06/13 added duration and isClick flag, and separated into whistles and clicks
      Parameters:
      speciesToInc -
      startTime - the starting time of the whistle, in milliseconds
      dur - the duration of the whistle, in milliseconds
      isClick - a flag indicating whether or not this is a click
    • incSpeciesCount

      public void incSpeciesCount(String speciesToInc)
      Increments a specific species classification count
      Parameters:
      speciesToInc - the index of the species to increment DO NOT USE THIS METHOD - use incSpeciesCount(String, double, double, bool) method instead
    • incSpeciesCount

      public void incSpeciesCount(String speciesToInc, double startTime)
      Increments a specific species classification count and save the starting time. This is a copy of method incSpeciesCount(String speciesToInc), with the addition of the startTime variable. Note that the starting time is passed in milliseconds, but converted to seconds before saving. serialVersionUID=15 2014/11/12 DO NOT USE THIS METHOD - use incSpeciesCount(String, double, double, bool) method instead
      Parameters:
      speciesToInc - the index of the species to increment
      startTime - the starting time of the whistle, in milliseconds
    • incSpeciesCount

      public void incSpeciesCount(String speciesToInc, double startTime, double dur, boolean isClick)
      Increments a specific species classification count and save the starting time and duration. This is a copy of method incSpeciesCount(String speciesToInc, double startTime), with the addition of the dur variable. Note that the starting time and duration are passed in milliseconds, but converted to seconds before saving. serialVersionUID=22 2015/06/13 added duration, isClick flag and break statement, and separated into whistles and clicks
      Parameters:
      speciesToInc - the index of the species to increment
      startTime - the starting time of the whistle, in milliseconds
      dur - the duration of the whistle, in milliseconds
      isClick - a flag indicating whether or not this is a click
    • getSightClass

      public String getSightClass()
    • setSightClass

      public void setSightClass(String sightClass)
      Sets the sighting classification to the passed string
      Parameters:
      sightClass - a string containing the class
    • classifySighting

      public void classifySighting(int threshold)
      classify the sighting, based on the tree votes. Divide the total number of tree votes for each species by the overall whistle count, to get an average for that species. The sighting threshold is passed, and used to evaluate the vote. If the vote is less than the threshold, the class is set to Ambiguous.
      Parameters:
      threshold - the threshold to compare the tree votes against
    • classifySighting

      public double classifySighting()
      classify the sighting, based on the tree votes. Divide the total number of tree votes for each species by the overall whistle count, to get an average for that species (note that Ambig is not included in this calc).
      Returns:
      The tree vote of the classified species
    • countWhistles

      public int countWhistles()
    • getSpeciesTreeVotes

      public double[] getSpeciesTreeVotes()
      returns the array of tree votes
      Returns:
      a double array of tree votes
    • addSpeciesTreeVotes

      public void addSpeciesTreeVotes(double[] newTreeVotes)
      Adds the passed array of tree votes to the current array. Note that the passed array may not include an 'Ambig' class, so the size will be one smaller than the current array. If that is the case, make sure to skip the first position (the Ambig position) when adding.
      Parameters:
      newTreeVotes - a double array of tree votes
    • isSightingSaved

      public boolean isSightingSaved()
    • setSightingSaved

      public void setSightingSaved(boolean sightingSaved)
    • isWhistleClassified

      public boolean isWhistleClassified()
      checks to see if any whistles have been classified yet
      Returns:
      boolean indicating whether or not a whistle has been classified yet
    • createSpList

      public String createSpList()
      Create a single string containing the species, using the '-' character separating the values
    • parseAndSetSpList

      public void parseAndSetSpList(String spListSingleString)
      Reads the species from the passed string and sets the species list. The string starts with '(' and ends with '-)', so drop the first character and last two characters. Each species name is separated from the other by a '-', so parse on that delimiter.
      Parameters:
      spListSingleString - the String to parse. See method description for the String format required
    • createClassCountList

      public String createClassCountList()
      Create a single string containing the species class counts, using the '-' character separating the values
    • parseAndSetClassCountList

      public void parseAndSetClassCountList(String classCountListSingleString)
      Reads the class counts from the passed string and sets the tally. The string starts with '(' and ends with '-)', so drop the first character and last two characters. Each tally count is separated from the other by a '-', so parse on that delimiter.
      Parameters:
      classCountListSingleString - the String to parse. See method description for the String format required
    • createVoteList

      public String createVoteList()
      Create a single string containing the tree votes, using the '-' character separating the values. Note that the votes are rounded to 5 decimal places to stop the string from getting too long.
    • parseAndSetVoteList

      public void parseAndSetVoteList(String voteListSingleString)
      Reads the class counts from the passed string and sets the tally. The string starts with '(' and ends with '-)', so drop the first character and last two characters. Each tally count is separated from the other by a '-', so parse on that delimiter.
      Parameters:
      voteListSingleString - the String to parse. See method description for the String format required
    • calculateWhistleTimeParams

      public double[] calculateWhistleTimeParams()
      Calculate sighting parameters based on time data. Calculations are returned in the double array in this order: timeParams[0] = duration of whistles in sighting (end of the last whistle - start of the first whistle) [ms] timeParams[1] = minimum time between whistles [ms] timeParams[2] = maximum time between whistles [ms] timeParams[3] = average time between whistles [ms] timeParams[4] = whistles/second serialVersionUID=22 2015/06/23 separated whistles and clicks, and added timeParams[5]-[9]: timeParams[5] = whistle density (sum of durations / encounter length) timeParams[6] = start time of first whistle [ms] timeParams[7] = end time of last whistle [ms] timeParams[8] = whistle overlap (sum of overlap / encounter length) timeParams[9] = number of whistles
    • calculateClickTimeParams

      public double[] calculateClickTimeParams()
      serialVersionUID=22 2015/06/23 added function to calculate time params on clicks Calculate sighting parameters based on time data. Calculations are returned in the double array in this order: timeParams[0] = duration of clicks in sighting (end of last click - start of first click) timeParams[1] = minimum time between clicks timeParams[2] = maximum time between clicks timeParams[3] = average time between clicks timeParams[4] = clicks/second timeParams[5] = click density (sum of durations / encounter length) timeParams[6] = start time of first click timeParams[7] = end time of last click timeParams[8] = average click overlap (sum of overlap / encounter length) timeParams[9] = number of clicks
    • getNumWhistles

      public int getNumWhistles()
    • getNumClicks

      public int getNumClicks()
    • getDetectionStats

      public String getDetectionStats()
    • setDetectionStats

      public void setDetectionStats(String detectionStats)
    • isSightingDataLost

      public boolean isSightingDataLost()
    • setSightingDataLost

      public void setSightingDataLost(boolean sightingDataLost)
    • wasNewDataAdded

      public boolean wasNewDataAdded()
    • setNewDataAdded

      public void setNewDataAdded(boolean newDataAdded)
    • getLongitude

      public double getLongitude()
    • getLatitude

      public double getLatitude()
    • setLatitude

      public void setLatitude(double latitude)
    • setLongitude

      public void setLongitude(double longitude)