Esempio n. 1
0
  /**
   * Determines if a power value is a peak at the spectrum. Compares it with the two frequency bins
   * above and below.
   *
   * @param index The index location to test inside the current list of valid frequencies.
   * @return True if it is a peak at that frequency, else false.
   * @throws IndexOutOfBoundsException If the given index forces a comparison out of bounds
   */
  private boolean isPeakAt(int index) throws IndexOutOfBoundsException {
    int frequency = validFrequencies.get(index); // get the frequency at the point.
    double power = freqPower[frequency];

    for (int i = (-3 + index); i <= (3 + index); i++) {
      if (i >= 0 && i < validFrequencies.size() && i != index) {
        int oFrequency = validFrequencies.get(i);
        double oPower = freqPower[oFrequency];
        double dp = power - oPower;
        if (dp < PEAK_THRESHOLD) return false;
      }
    }
    return true;
  }
Esempio n. 2
0
 /** Extracts the local peaks from the spectrum at this particular time interval. */
 private void getLocalPeaks() {
   for (int i = 0; i < validFrequencies.size(); i++) {
     try {
       if (isPeakAt(i)) {
         int frequency = validFrequencies.get(i); // get the frequency at the particular index
         Peak peak = new Peak(spectrumNumber, frequency, freqPower[frequency]);
         // System.out.println(spectrumNumber + " " + frequency);
         peaks.add(peak);
         // System.out.println(peak.getTime() + " " +  peak.getFrequency());
       }
     } catch (IndexOutOfBoundsException e) {
       // do nothing
     }
   }
 }
Esempio n. 3
0
 /**
  * Cycles through the array of power values and gets rid of all the values less than the average
  * power for the interval.
  */
 private void filterPeaks() {
   validFrequencies = new ArrayList<Integer>(); // list of frequencies with power > average power
   for (int frequency = 0; frequency < freqPower.length; frequency++) {
     double thisPower = freqPower[frequency];
     if (thisPower > averagePower) {
       validFrequencies.add(
           frequency); // add to the list of valid frequencies if greater than average power
     }
   }
   getLocalPeaks();
 }