def ps(data, p0=0.0, p1=0.0, inv=False):
    """
    Linear phase correction
    Parameters
    ----------
    data : ndarray
        Array of NMR data.
    p0 : float
        Zero order phase in degrees.
    p1 : float
        First order phase in degrees.
    inv : bool, optional
        True for inverse phase correction
    Returns
    -------
    ndata : ndarray
        Phased NMR data.
    """
    import numpy as np
    p0 = p0 * np.pi / 180.0
    p1 = p1 * np.pi / 180.0
    size = data.shape[-1]
    apod = np.exp(1.0j * (p0 + p1 * np.arange(size) / size)).astype(data.dtype)
    if inv:
        apod = 1 / apod
    return apod * data
