def import_saf_crri(filename, extent=None, **kwargs):
    """
    Import a NetCDF radar rainfall product from the Convective Rainfall Rate
    Intensity (CRRI) product from the Satellite Application Facilities (SAF).

    Product description available on http://www.nwcsaf.org/crr_description
    (last visited Jan 26, 2020).

    Parameters
    ----------
    filename: str
        Name of the file to import.
    extent: scalars (left, right, bottom, top), optional
        The spatial extent specified in data coordinates.
        If None, the full extent is imported.

    {extra_kwargs_doc}

    Returns
    -------
    out: tuple
        A three-element tuple containing the rainfall field in mm/h, the quality
        field and the metadata imported from the CRRI SAF netcdf file.
        The quality field includes values [1, 2, 4, 8, 16, 24, 32] meaning
        "nodata", "internal_consistency", "temporal_consistency", "good",
        "questionable", "bad", and "interpolated", respectively.
    """
    if not NETCDF4_IMPORTED:
        raise MissingOptionalDependency(
            "netCDF4 package is required to import CRRI SAF products "
            "but it is not installed"
        )

    geodata = _import_saf_crri_geodata(filename)
    metadata = geodata

    if extent:
        xcoord = (
            np.arange(metadata["x1"], metadata["x2"], metadata["xpixelsize"])
            + metadata["xpixelsize"] / 2
        )
        ycoord = (
            np.arange(metadata["y1"], metadata["y2"], metadata["ypixelsize"])
            + metadata["ypixelsize"] / 2
        )
        ycoord = ycoord[::-1]  # yorigin = "upper"
        idx_x = np.logical_and(xcoord < extent[1], xcoord > extent[0])
        idx_y = np.logical_and(ycoord < extent[3], ycoord > extent[2])

        # update geodata
        metadata["x1"] = xcoord[idx_x].min() - metadata["xpixelsize"] / 2
        metadata["x2"] = xcoord[idx_x].max() + metadata["xpixelsize"] / 2
        metadata["y1"] = ycoord[idx_y].min() - metadata["ypixelsize"] / 2
        metadata["y2"] = ycoord[idx_y].max() + metadata["ypixelsize"] / 2

    else:
        idx_x = None
        idx_y = None

    precip, quality = _import_saf_crri_data(filename, idx_x, idx_y)

    metadata["transform"] = None
    metadata["zerovalue"] = np.nanmin(precip)
    metadata["threshold"] = _get_threshold_value(precip)

    return precip, quality, metadata
Import a NetCDF radar rainfall product from the Convective Rainfall Rate
Intensity (CRRI) product from the Satellite Application Facilities (SAF).

Product description available on http://www.nwcsaf.org/crr_description
(last visited Jan 26, 2020).

Parameters
----------
filename: str
Name of the file to import.
extent: scalars (left, right, bottom, top), optional
The spatial extent specified in data coordinates.
If None, the full extent is imported.

{extra_kwargs_doc}

Returns
-------
out: tuple
A three-element tuple containing the rainfall field in mm/h, the quality
field and the metadata imported from the CRRI SAF netcdf file.
The quality field includes values [1, 2, 4, 8, 16, 24, 32] meaning
"nodata", "internal_consistency", "temporal_consistency", "good",
"questionable", "bad", and "interpolated", respectively.
pysteps/io/importers.py