def ROC_curve_compute(ROC, compute_area=False):
    """
    Compute the ROC curve and its area from the given ROC object.

    Parameters
    ----------
    ROC: dict
      A ROC curve object created with ROC_curve_init.
    compute_area: bool
      If True, compute the area under the ROC curve (between 0.5 and 1).

    Returns
    -------
    out: tuple
      A two-element tuple containing the probability of detection (POD) and
      probability of false detection (POFD) for the probability thresholds
      specified in the ROC curve object. If compute_area is True, return the
      area under the ROC curve as the third element of the tuple.
    """
    POD_vals = []
    POFD_vals = []

    for i in range(len(ROC["prob_thrs"])):
        POD_vals.append(1.0 * ROC["hits"][i] / (ROC["hits"][i] + ROC["misses"][i]))
        POFD_vals.append(
            1.0 * ROC["false_alarms"][i] / (ROC["corr_neg"][i] + ROC["false_alarms"][i])
        )

    if compute_area:
        # Compute the total area of parallelepipeds under the ROC curve.
        area = (1.0 - POFD_vals[0]) * (1.0 + POD_vals[0]) / 2.0
        for i in range(len(ROC["prob_thrs"]) - 1):
            area += (
                (POFD_vals[i] - POFD_vals[i + 1])
                * (POD_vals[i + 1] + POD_vals[i])
                / 2.0
            )
        area += POFD_vals[-1] * POD_vals[-1] / 2.0

        return POFD_vals, POD_vals, area
    else:
        return POFD_vals, POD_vals
Compute the ROC curve and its area from the given ROC object.

Parameters
----------
ROC: dict
A ROC curve object created with ROC_curve_init.
compute_area: bool
If True, compute the area under the ROC curve (between 0.5 and 1).

Returns
-------
out: tuple
A two-element tuple containing the probability of detection (POD) and
probability of false detection (POFD) for the probability thresholds
specified in the ROC curve object. If compute_area is True, return the
area under the ROC curve as the third element of the tuple.
pysteps/verification/probscores.py