Ejemplo n.º 1
0
def generate_speed_profile(fwhm=0.2, center=0.5, n_bins=200):
    '''Generates base values for a ballistic movement.

    Parameters
    ----------
    fwhm : float
      curve parameter for speed profile
    center : float
      position of peak speed in profile
    n_pts : int, default=200
      number of points to generate
    
    Returns
    -------
    time : ndarray, shape (n_pts,)
      time co-ordinates
    disp : ndarray, shape (n_pts,)
      displacement through movement
    speed : ndarray, shape (n_pts,)
      speed during movement
    acc : ndarray, shape (n_pts - 1,)
      acceleration during movement

    Notes
    -----    
    '''
    assert type(fwhm) == type(center) == float
    assert type(n_bins) == int

    #n_pts = n_bins + 1
    points = np.linspace(0, 1., n_bins, endpoint=True)
    speed = gauss1d(points, 1., fwhm, center)
    
    return speed#, speed_mid
Ejemplo n.º 2
0
def generate_ballistic_profiles(fwhm=0.2, center=0.5, n_pts=200):
    '''
    Generates base values for a ballistic movement.

    Parameters
    ----------
    fwhm : float
      curve parameter for speed profile
    center : float
      position of peak speed in profile
    n_pts : int, default=200
      number of points to generate
    
    Returns
    -------
    time : ndarray, shape (n_pts,)
      time co-ordinates
    disp : ndarray, shape (n_pts,)
      displacement through movement
    speed : ndarray, shape (n_pts,)
      speed during movement
    acc : ndarray, shape (n_pts - 1,)
      acceleration during movement

    Notes
    -----    
    '''
    assert type(0.) == type(fwhm) == type(center)
    assert type(0) == type(n_pts)
    time = np.linspace(0, 1., n_pts, endpoint=True)
    speed = curves.gauss1d(time, 1., fwhm, center)
    disp = np.cumsum(speed)
    disp /= disp.max()
    acc = np.diff(speed)
    warn("acc should be calculated using a divide by time")
    return time, disp, speed, acc