def update_primary(hdu_in, hdu=None):
    """ 'Update' a primary HDU

    This checks hdu exists and creates it from hdu_in if it does not.
    If hdu does exist, this adds the data in hdu_in to hdu
    """
    if hdu is None:
        hdu = fits.PrimaryHDU(data=hdu_in.data, header=hdu_in.header)
    else:
        hdu.data += hdu_in.data
    return hdu