from typing import OrderedDict


def fits_header_to_meta_dict(header):
    """Convert `astropy.io.fits.Header` to `~collections.OrderedDict`.

    This is a lossy conversion, only key, value is stored
    (and not e.g. comments for each FITS "card").
    Also, "COMMENT" and "HISTORY" cards are completely removed.
    """
    meta = OrderedDict(header)

    # Drop problematic header content, i.e. values of type
    # `astropy.io.fits.header._HeaderCommentaryCards`
    # Handling this well and preserving it is a bit complicated, see
    # See https://github.com/astropy/astropy/blob/master/astropy/io/fits/connect.py
    # for how `astropy.table.Table.read` does it
    # and see https://github.com/gammapy/gammapy/issues/701
    meta.pop("COMMENT", None)
    meta.pop("HISTORY", None)

    return meta