def mag_to_flux(catalog, mag_col, zeropoint=27.0, update=True):
    """
    Convert AB magnitude into HSC image flux unit.
    """
    flux = 10.0 ** ((zeropoint - catalog[mag_col]) / 2.5)
    if update:
        flux_col = mag_col.replace('mag', 'flux')
        if flux_col in catalog.colnames:
            catalog.remove_column(flux_col)
        catalog.add_column(data=flux, name=flux_col)
        return catalog
    return flux