import torch


def get_alpha(z):
    """Calculates the waves dissipation profile, :math:`\\alpha(z)` as defined
    in (9) of Holton and Lindzen.

    Parameters
    ----------
    z : tensor
        Height [m]

    Returns
    -------
    tensor
        :math:`\\alpha (z)` [:math:`\mathrm{s^{-1}}`]
    """

    alpha = torch.zeros(z.shape)
    idx = (17e3 <= z) & (z <= 30e3)

    alpha[idx] = (1 / 21) + (2 / 21) * (z[idx] - 17e3) / 13e3
    alpha[~idx] = 1 / 7

    return alpha / (60 * 60 * 24)