def det_cat_fct_merge(contab_1, contab_2):
    """
    Merge two contingency table objects.

    Parameters
    ----------
    contab_1: dict
      A contingency table object initialized with
      :py:func:`pysteps.verification.detcatscores.det_cat_fct_init`
      and populated with
      :py:func:`pysteps.verification.detcatscores.det_cat_fct_accum`.
    contab_2: dict
      Another contingency table object initialized with
      :py:func:`pysteps.verification.detcatscores.det_cat_fct_init`
      and populated with
      :py:func:`pysteps.verification.detcatscores.det_cat_fct_accum`.

    Returns
    -------
    out: dict
      The merged contingency table object.
    """

    # checks
    if contab_1["thr"] != contab_2["thr"]:
        raise ValueError(
            "cannot merge: the thresholds are not same %s!=%s"
            % (contab_1["thr"], contab_2["thr"])
        )
    if contab_1["axis"] != contab_2["axis"]:
        raise ValueError(
            "cannot merge: the axis are not same %s!=%s"
            % (contab_1["axis"], contab_2["axis"])
        )
    if contab_1["hits"] is None or contab_2["hits"] is None:
        raise ValueError("cannot merge: no data found")

    # merge the contingency tables
    contab = contab_1.copy()
    contab["hits"] += contab_2["hits"]
    contab["misses"] += contab_2["misses"]
    contab["false_alarms"] += contab_2["false_alarms"]
    contab["correct_negatives"] += contab_2["correct_negatives"]

    return contab
Merge two contingency table objects.

Parameters
----------
contab_1: dict
A contingency table object initialized with
:py:func:`pysteps.verification.detcatscores.det_cat_fct_init`
and populated with
:py:func:`pysteps.verification.detcatscores.det_cat_fct_accum`.
contab_2: dict
Another contingency table object initialized with
:py:func:`pysteps.verification.detcatscores.det_cat_fct_init`
and populated with
:py:func:`pysteps.verification.detcatscores.det_cat_fct_accum`.

Returns
-------
out: dict
The merged contingency table object.
pysteps/verification/detcatscores.py