def spacecraft_vel(deltaw, deltan, deltar, dij, vmap):
    """
    function to calculate pixel-wise spacecraft velocities for Sunpy map

    Based on Haywood et al. (2016) and described in Ervin et al. (2021) - In Prep.

    Parameters
    ----------
    deltaw: float, array
        relative westward position of pixel
    deltan: float, array
        relative northward position of pixel
    deltar: float, array
        relative radial position of pixel
    dij: float
        distance between pixel ij and spacecraft
    vmap: map
        Sunpy map object (Dopplergram)

    Returns
    -------
    vsc: float, array
        array of spacecraft velocities
   """

    # velocity of spacecraft relative to sun
    vscw = vmap.meta['obs_vw']
    vscn = vmap.meta['obs_vn']
    vscr = vmap.meta['obs_vr']

    # pixel-wise magnitude of spacecraft velocity
    vsc = - (deltaw * vscw + deltan * vscn + deltar * vscr) / dij

    return vsc