# Path: wildfind/harrier/collar.py
# CW, AM = range(2)
# MOD_DESC = ['CW', 'AM']
# class Collar(object):
#     def __init__(self, count, rate, level, width):
#     def get_modulation(self):
#     def get_description(self):
#     def get_dict(self, timeStamp):
# 
# Path: wildfind/harrier/constants.py
# SAMPLE_TIME = 4
# 
# Path: wildfind/harrier/utils.py
# class Utils(object):
#     # Print error and exit
#     @staticmethod
#     def error(error, fatal=True):
#         if fatal:
#             sys.exit(error)
# 
#         sys.stderr.write(error + '\n')
# 
#     # Return ranges based on tolerance
#     @staticmethod
#     def calc_tolerances(values, tolerance):
#         valuesMin = [value * (100 - tolerance) / 100. for value in values]
#         valuesMax = [value * (100 + tolerance) / 100. for value in values]
#         return zip(valuesMax, valuesMin)


import itertools
import operator
import numpy
from scipy import fftpack
from wildfind.harrier import collar
from wildfind.harrier.constants import SAMPLE_TIME
from wildfind.harrier.utils import Utils
            bins = numpy.searchsorted(freqBins[freqInds],
                                      self._frequencies)
            levels = mags[freqInds][bins]
            signals[chunkNum] = levels

            if self._timing is not None:
                self._timing.stop()

        signals = signals.T
        self.__smooth(signals, 4)

        return signals

    def __correlate(self, a, v):
        # Normalise
        if self._timing is not None:
            self._timing.start('Correl')
        a = (a - numpy.mean(a)) / (numpy.std(a, dtype=numpy.float32) * len(a))
        v = (v - numpy.mean(v)) / numpy.std(v, dtype=numpy.float32)
        corr = numpy.correlate(a, v)
        if self._timing is not None:
            self._timing.stop()

        return corr[0] > (GHOST_CORR / 100.)

    def __remove_ghosts(self, signals, detected):
        if len(detected) < 2:
            return

        # Split into groups based on rate

# Path: wildfind/harrier/collar.py
# CW, AM = range(2)
# MOD_DESC = ['CW', 'AM']
# class Collar(object):
#     def __init__(self, count, rate, level, width):
#     def get_modulation(self):
#     def get_description(self):
#     def get_dict(self, timeStamp):
# 
# Path: wildfind/harrier/constants.py
# SAMPLE_TIME = 4
# 
# Path: wildfind/harrier/utils.py
# class Utils(object):
#     # Print error and exit
#     @staticmethod
#     def error(error, fatal=True):
#         if fatal:
#             sys.exit(error)
# 
#         sys.stderr.write(error + '\n')
# 
#     # Return ranges based on tolerance
#     @staticmethod
#     def calc_tolerances(values, tolerance):
#         valuesMin = [value * (100 - tolerance) / 100. for value in values]
#         valuesMax = [value * (100 + tolerance) / 100. for value in values]
#         return zip(valuesMax, valuesMin)


# Path: wildfind/harrier/detect.py
import itertools
import operator
import numpy
from scipy import fftpack
from wildfind.harrier import collar
from wildfind.harrier.constants import SAMPLE_TIME
from wildfind.harrier.utils import Utils

            bins = numpy.searchsorted(freqBins[freqInds],
                                      self._frequencies)
            levels = mags[freqInds][bins]
            signals[chunkNum] = levels

            if self._timing is not None:
                self._timing.stop()

        signals = signals.T
        self.__smooth(signals, 4)

        return signals

    def __correlate(self, a, v):
        # Normalise
        if self._timing is not None:
            self._timing.start('Correl')
        a = (a - numpy.mean(a)) / (numpy.std(a, dtype=numpy.float32) * len(a))
        v = (v - numpy.mean(v)) / numpy.std(v, dtype=numpy.float32)
        corr = numpy.correlate(a, v)
        if self._timing is not None:
            self._timing.stop()

        return corr[0] > (GHOST_CORR / 100.)

    def __remove_ghosts(self, signals, detected):
        if len(detected) < 2:
            return

        # Split into groups based on rate

        rates = [collar.rate for collar in detected]