Damp the movement of an animation curve I am quite new to Blender. I am writing a script for a scientific study. So I want to do it in the script change the angles of a motion in order to have quantifiable data. I have been struggling for few days to come up with a method to damp a motion of a predefined motion curve. For example:


The curves are in Quaternions. So far what I tried: Get a keyframe value w, x, y, z for the Arm and Forearm and generate a Quaternion. Then multiply each with a float value such as 0.5 (dividing by 2) to reduce the amplitude. Then update the Quaternion back.
Example:
newQat = 0.5 * (current_quat)

However, this did not quite for me. Working with Quaternion does not seem to give me the fully control the amplitude of a curve. That is at least my understanding.
Second attempt: Convert them to Euler and then multiply with a weight. For example, I want to damp the z angle of rotation of the Forearm. Then I simply, for all key frames of forearm, Get the w, x, y, z value, convert to Quaternion and then convert that to generate OldEuler. Then generate new Euler this way:
newEuler = (OldEuler.x ,OldEuler.y, 0.5 *OldEuler.z)

Then again convert back to newEuler.to_quaternion(), then update the curve. No great success on this method either.
I have found a solution to this.
#Retrieve the current roation

current_q = Quaternion((kf_w.co[1], kf_x.co[1], kf_y.co[1], kf_z.co[1]))

current_eulr = current_q.to_euler()
        
#Element-wise multiplication with a weight vector

new_euler = Euler((x * y for x, y in zip( weights,current_eulr )), 'XYZ')

new_q = new_euler.to_quaternion()