def import_mch_hdf5(filename, qty="RATE", **kwargs):
    """
    Import a precipitation field (and optionally the quality field) from a
    MeteoSwiss HDF5 file conforming to the ODIM specification.

    Parameters
    ----------
    filename: str
        Name of the file to import.
    qty: {'RATE', 'ACRR', 'DBZH'}
        The quantity to read from the file. The currently supported identitiers
        are: 'RATE'=instantaneous rain rate (mm/h), 'ACRR'=hourly rainfall
        accumulation (mm) and 'DBZH'=max-reflectivity (dBZ). The default value
        is 'RATE'.

    {extra_kwargs_doc}

    Returns
    -------
    out: tuple
        A three-element tuple containing the OPERA product for the requested
        quantity and the associated quality field and metadata. The quality
        field is read from the file if it contains a dataset whose quantity
        identifier is 'QIND'.
    """
    if not H5PY_IMPORTED:
        raise MissingOptionalDependency(
            "h5py package is required to import "
            "radar reflectivity composites using ODIM HDF5 specification "
            "but it is not installed"
        )

    if qty not in ["ACRR", "DBZH", "RATE"]:
        raise ValueError(
            "unknown quantity %s: the available options are 'ACRR', 'DBZH' and 'RATE'"
        )

    f = h5py.File(filename, "r")

    precip = None
    quality = None

    for dsg in f.items():
        if dsg[0].startswith("dataset"):
            what_grp_found = False
            # check if the "what" group is in the "dataset" group
            if "what" in list(dsg[1].keys()):
                qty_, gain, offset, nodata, undetect = _read_mch_hdf5_what_group(
                    dsg[1]["what"]
                )
                what_grp_found = True

            for dg in dsg[1].items():
                if dg[0][0:4] == "data":
                    # check if the "what" group is in the "data" group
                    if "what" in list(dg[1].keys()):
                        (
                            qty_,
                            gain,
                            offset,
                            nodata,
                            undetect,
                        ) = _read_mch_hdf5_what_group(dg[1]["what"])
                    elif not what_grp_found:
                        raise DataModelError(
                            "Non ODIM compliant file: "
                            "no what group found from {} "
                            "or its subgroups".format(dg[0])
                        )

                    if qty_.decode() in [qty, "QIND"]:
                        arr = dg[1]["data"][...]
                        mask_n = arr == nodata
                        mask_u = arr == undetect
                        mask = np.logical_and(~mask_u, ~mask_n)

                        if qty_.decode() == qty:
                            precip = np.empty(arr.shape)
                            precip[mask] = arr[mask] * gain + offset
                            precip[mask_u] = np.nan
                            precip[mask_n] = np.nan
                        elif qty_.decode() == "QIND":
                            quality = np.empty(arr.shape, dtype=float)
                            quality[mask] = arr[mask]
                            quality[~mask] = np.nan

    if precip is None:
        raise IOError("requested quantity %s not found" % qty)

    where = f["where"]

    geodata = _import_mch_geodata()
    metadata = geodata

    # TODO: use those from the hdf5 file instead
    # xpixelsize = where.attrs["xscale"] * 1000.0
    # ypixelsize = where.attrs["yscale"] * 1000.0
    # xsize = where.attrs["xsize"]
    # ysize = where.attrs["ysize"]

    if qty == "ACRR":
        unit = "mm"
        transform = None
    elif qty == "DBZH":
        unit = "dBZ"
        transform = "dB"
    else:
        unit = "mm/h"
        transform = None

    if np.any(np.isfinite(precip)):
        thr = np.nanmin(precip[precip > np.nanmin(precip)])
    else:
        thr = np.nan

    metadata.update(
        {
            "yorigin": "upper",
            "institution": "MeteoSwiss",
            "accutime": 5.0,
            "unit": unit,
            "transform": transform,
            "zerovalue": np.nanmin(precip),
            "threshold": thr,
            "zr_a": 316.0,
            "zr_b": 1.5,
        }
    )

    f.close()

    return precip, quality, metadata
Import a precipitation field (and optionally the quality field) from a
MeteoSwiss HDF5 file conforming to the ODIM specification.

Parameters
----------
filename: str
Name of the file to import.
qty: {'RATE', 'ACRR', 'DBZH'}
The quantity to read from the file. The currently supported identitiers
are: 'RATE'=instantaneous rain rate (mm/h), 'ACRR'=hourly rainfall
accumulation (mm) and 'DBZH'=max-reflectivity (dBZ). The default value
is 'RATE'.

{extra_kwargs_doc}

Returns
-------
out: tuple
A three-element tuple containing the OPERA product for the requested
quantity and the associated quality field and metadata. The quality
field is read from the file if it contains a dataset whose quantity
identifier is 'QIND'.
pysteps/io/importers.py