示例#1
0
 def findAvgSlope(data):
     slopes = []
     newData = Rescale.rescaleX(
         data)  #Normalize x so it can be used to compare data sets
     y1 = newData[0, 1]
     x1 = newData[0, 0]
     y2 = 0.0
     x2 = 0.0
     for i in range(1, newData.shape[0]):
         x2 = newData[i, 0]
         y2 = newData[i, 1]
         if not ((x2 - x1) == 0):
             slopes.append(
                 abs((y2 - y1) / (x2 - x1))
             )  #Abs so the value doesn't even out - might change later, if there is a zero in denom - invalid - don't add
         y1 = y2
         x1 = x2
     return (float)(stats._sum(slopes)[1] / len(slopes))
示例#2
0
    def findPeakInfo(data):
        time = 0.0
        times = []
        min = 999999999.9
        max = 0.0
        average = 0.0
        newData = Rescale.rescaleX(
            data)  #When we subtract, we want a standard unit of time
        peaks = sig.find_peaks(newData[:, 1])[
            0]  #grab the indices of the peaks, which are located at index 0
        if len(peaks) > 0:
            for i in range(
                    0, len(peaks)
            ):  #The indices are in the array contained in element
                time = newData[peaks[i]][
                    0] - time  #Add the differences in time for each peak
                times.append(time)
                peakHeight = newData[peaks[i]][1]
                if (
                        peakHeight > max
                ):  #Designwise - should be in their own methods, but I really don't want to write this loop 4 times
                    max = peakHeight
                if (peakHeight < min):
                    min = peakHeight
                average += peakHeight
            timeToPeak = (float)(stats._sum(times)[1] / len(times))
            average /= len(peaks)
        else:
            min = 0
            max = 0.0
            timeToPeak = 0

        peakFeatures = {
            "ttp": timeToPeak,
            "min": min,
            "max": max,
            "avg": average
        }

        return peakFeatures  #Return the average time (in normalized x-axis units)
示例#3
0
 def findAverage(resultArray):
     numResults = len(resultArray)
     return (float)(stats._sum(resultArray)[1] / numResults)
示例#4
0
 def findSum(data):
     return (float)(stats._sum(data[:, 1])[1])
示例#5
0
 def findMode(data):
     return (float)(stats._sum(data[:, 1])[1] / data.shape[0])
示例#6
0
 def update_event(self, inp=-1):
     self.set_output_val(0, statistics._sum(self.input(0), self.input(1)))