def mag2irr(mag, use_attn=False):
    """
    This function converts the apparent magnitude to the corresponding
    irradiance value given in [W/m^2].

    Parameters
    ----------
    mag : float
        The astronomical magnitude.
    use_attn : bool, optional
        Boolean value. If True, a constant factor will be applied that
        represents a simple atmospheric attenuation. The default is False.

    Returns
    -------
    irr : float
        The resulting irradiance given in [W/m^2].
    """

    # If the user wants the atmospheric attenuation, a constant value of 0.4
    # is set ...
    if use_attn:
        attn = 0.4

    # ... otherwise a value of 0 is set
    else:
        attn = 0.0

    # Compute the irradiance
    irr = 10.0 ** (0.4 * (-mag - 19.0 + attn))

    # Return the irradiance
    return irr