def gen_goal(self, y_des): 
        """Generate the goal for path imitation. 
        For rhythmic DMPs the goal is the average of the 
        desired trajectory.
    
        y_des np.array: the desired trajectory to follow
        """

        goal = np.zeros(self.dmps)
        for n in range(self.dmps):
            num_idx = ~np.isnan(y_des[n]) # ignore nan's when calculating goal
            goal[n] = .5 * (y_des[n,num_idx].min() + \
                           y_des[n,num_idx].max()) 

        return goal
Generate the goal for path imitation. 
        For rhythmic DMPs the goal is the average of the 
        desired trajectory.
    
        y_des np.array: the desired trajectory to follow