def getgain(image):
    """ Get the gain from the header."""

    gain = 1.0  # default
    
    # check if there's a header
    if hasattr(image,'meta'):
        if image.meta is not None:
            # Try all versions of gain
            for f in ['gain','egain','gaina']:
                hgain = image.meta.get(f)
                if hgain is not None:
                    gain = hgain
                    break
    return gain