Exemple #1
0
    def getComAcceleration(self,pointFrequency,method = "spline", **options):
        """
            Get global linear acceleration of the centre of mass

            :Parameters:
                - `pointFrequency` (double) - point frequency
                - `method` (str) - derivation method (spline, spline fitting)
                - `**options` (kwargs) - options pass to method.

            :Return:
                - `values` (numpy.array(n,3)) - values of the com acceleration

            .. attention :: com trajectory can be smoothed  by calling fc and order, the cut-off frequency and the order of the low-pass filter respectively


            .. note ::

                if method doesnt recognize, numerical second order derivation is used


        """

        valueCom = self.getComTrajectory()
        if "fc" in options.keys() and  "order" in options.keys():
            valueCom = signal_processing.arrayLowPassFiltering(valueCom,pointFrequency,options["order"],options["fc"]  )

        if method == "spline":
            values = derivation.splineDerivation(valueCom,pointFrequency,order=2)
        elif method == "spline fitting":
            values = derivation.splineFittingDerivation(self.getComTrajectory(),pointFrequency,order=2)
        else:
            values = derivation.secondOrderFiniteDifference(valueCom,pointFrequency)

        return values
Exemple #2
0
    def detectValue(self, analysis):

        xlsData = self.m_xls.parse("data")

        # init new collumns
        xlsData["Value"] = "NA"
        xlsData["ValueStatus"] = "NA"

        for index in xlsData.index:
            row = xlsData.iloc[index, :]

            context = row["Context"]  # str
            variable = row["Variable"] + self.pointSuffix
            plan = int(row["Plan"])
            derivate = int(row["derivate"])
            cyclePeriod = row["CyclePeriod"]
            method = row["Method"]
            args = row["MethodArgument"]
            limits = row["Ranges"]
            status = row["status [lesser,within,greater]"]

            if row["Domain"] == "Kinematics":
                data = analysis.kinematicStats
            elif row["Domain"] == "Kinetics":
                data = analysis.kineticStats

            value = "NA"
            if data.data != {}:
                if (variable, context) in data.data:
                    dataArray = data.data[variable, context]["mean"]
                    frames = self._getFrameLimits(cyclePeriod, context, data)

                    if derivate == 0:
                        values = dataArray[frames[0]:frames[1] + 1, plan]
                    elif derivate == 1:
                        der = derivation.firstOrderFiniteDifference(
                            dataArray, 1)
                        values = der[frames[0]:frames[1] + 1, plan]
                    elif derivate == 2:
                        der = derivation.secondOrderFiniteDifference(
                            dataArray, 1)
                        values = der[frames[0]:frames[1] + 1, plan]

                    value = self._applyMethod(values, method, args, frames[0])
                else:
                    logging.warning(
                        "[pyGM2] :row (%i) -  key [%s,%s] not found in analysis data instance"
                        % (index, variable, context))

            if value is not "NA":
                if (value == "False" or value == "True"):
                    valueStatus = value
                else:
                    valueStatus = self._applyStatus(value, limits, status)
            else:
                valueStatus = "NA"

            xlsData.set_value(index, "Value", value)
            xlsData.set_value(index, "ValueStatus", valueStatus)

            self.data = xlsData

        return xlsData