def measure(self, segment, threshold=-20, location='center'):
        if segment.peaks_values is None:
            segment.compute_peaks()

        if location is None:
            return self.__measure_spectrum(segment, threshold)
        j = get_location(segment, location)
        i = segment.peaks_indexes[j]

        value = apply_threshold(segment.spec[i, j], threshold)

        if self.total:
            min_freq = np.argwhere(segment.spec[:, j] >= value).min()
            max_freq = np.argwhere(segment.spec[:, j] >= value).max()
        else:
            below = segment.spec[:, j] < value
            below[i:] = False
            min_freq = np.argwhere(below).max()

            below = segment.spec[:, j] < value
            below[:i] = False
            max_freq = np.argwhere(below).min()

        segment.measures_dict[self.name + '(' + location + ')'] = np.round(
            segment.freqs[max_freq] - segment.freqs[min_freq],
            DECIMAL_PLACES)
        return True
Beispiel #2
0
    def measure(self, segment, location='center'):
        if location is None:
            return self.__measure_spectrum(segment)

        j = get_location(segment, location)
        i = segment.peaks_indexes[j]

        segment.measures_dict[self.name + '(' + location + ')'] = np.round(
            segment.freqs[i], DECIMAL_PLACES)
        return True
Beispiel #3
0
    def measure(self, segment, location='center'):
        if location is None:
            return self.__measure_spectrum(segment)

        j = get_location(segment, location)

        data = np.array(segment.spec[:, j], np.float64)
        value = np.sqrt(energy(data) / len(segment.data))

        segment.measures_dict[self.name + '(' + location + ')'] = value
        return True
Beispiel #4
0
    def measure(self, segment, location='center'):
        j = get_location(segment, location)

        flux = 0.
        for i in range(segment.spec.shape[0]):
            flux += (segment.spec[i, j] - segment.spec[i, j - 1]) ** 2

        value = np.sqrt(flux)

        segment.measures_dict[self.name + '(' + location + ')'] = value
        return True
    def measure(self, segment, location='center'):
        if location is None:
            return self.__measure_spectrum(segment)

        j = get_location(segment, location)

        data = np.array(segment.spec[:, j], np.float64)
        g_mean = geometric_mean(data)
        a_mean = np.mean(data)
        value = g_mean / a_mean

        segment.measures_dict[self.name + '(' + location + ')'] = value
        return True
Beispiel #6
0
    def measure(self, segment, location='center'):
        if segment.peaks_values is None:
            segment.compute_peaks()

        if location is None:
            return self.__measure_spectrum(segment)

        index_frame = get_location(segment, location)
        j = segment.peaks_values[index_frame]
        db_reference = segment.signal.db_reference
        segment.measures_dict[self.name + '(' + location + ')'] = to_db(
            j, db_reference)
        return True
Beispiel #7
0
    def measure(self, segment, location='center'):
        if location is None:
            return self.__measure_spectrum(segment)

        j = get_location(segment, location)

        data = np.array(segment.spec[:, j], np.float64)
        entropy = 0.0
        for i in range(len(data)):
            if data[i] == 0.0:
                entropy -= np.log2(1)
            else:
                entropy -= np.log2(data[i]) * data[i]

        segment.measures_dict[self.name + '(' + location + ')'] = entropy
        return True
    def measure(self, segment, location='center'):
        if location is None:
            return self.__measure_spectrum(segment)

        j = get_location(segment, location)
        data = segment.spec[:, j]

        indexes = np.array(range(1, len(data) + 1))
        weights = np.sum(data)
        if weights != 0.0:
            value = ((np.sum(indexes * data) + segment.IndexFrom) / weights)
        else:
            value = 0.0
        value *= segment.freqs[-1] / len(segment.freqs)

        segment.measures_dict[self.name + '(' + location + ')'] = np.round(
            value, DECIMAL_PLACES)
        return True
Beispiel #9
0
    def measure(self, segment, location='center', cutoff=0.95):
        if location is None:
            return self.__measure_spectrum(segment, cutoff)

        j = get_location(segment, location)
        data = segment.spec[:, j]

        energy = np.sum(np.square(data))
        cutoff *= energy

        energy_sum = 0.
        roll_off = None

        for i in range(len(data)):
            energy_sum += data[i]**2
            if energy_sum >= cutoff:
                roll_off = i
                break

        segment.measures_dict[self.name + '(' + location + ')'] = np.round(
            segment.freqs[roll_off], DECIMAL_PLACES)
        return True