def magerr2Ivar(flux, magErr):
    """
    Estimate the inverse variance given flux and magnitude error.
    The reason for this is that we need to correct the magnitude or
    flux for Galactic extinction.

    Parameters
    ----------

    flux : scalar or array of float
        Flux of the obejct.
    magErr : scalar or array of float
        Error of magnitude measurements.
    """
    fluxErr = flux * ((10.0 ** (magErr/2.5)) - 1.0)

    return 1.0 / (fluxErr ** 2.0)