def correct_mag(m0, X, k):
    """Correct magnitude for airmass and extinction.

    Parameters
    ----------
    m0 : float
        Apparent magnitude.
    X : float
        Airmass.
    k : float
        Extinction coefficient.

    Returns
    -------
    m : float
        The corrected apparent magnitude.

    """
    m = m0 + k * X
    return m