def initialize_forecast_exporter_kineros(
    outpath,
    outfnprefix,
    startdate,
    timestep,
    n_timesteps,
    shape,
    metadata,
    n_ens_members=1,
    incremental=None,
    **kwargs,
):
    """
    Initialize a KINEROS2 format exporter for the rainfall ".pre" files
    specified in https://www.tucson.ars.ag.gov/kineros/.

    Grid points are treated as individual rain gauges and a separate file is
    produced for each ensemble member. The output files are named as
    <outfnprefix>_N<n>.pre, where <n> is the index of ensemble member starting
    from zero.

    Parameters
    ----------
    outpath: str
        Output path.

    outfnprefix: str
        Prefix for output file names.

    startdate: datetime.datetime
        Start date of the forecast.

    timestep: int
        Time step of the forecast (minutes).

    n_timesteps: int
        Number of time steps in the forecast this argument is ignored if
        incremental is set to 'timestep'.

    shape: tuple of int
        Two-element tuple defining the shape (height,width) of the forecast
        grids.

    metadata: dict
        Metadata dictionary containing the projection,x1,x2,y1,y2 and unit
        attributes described in the documentation of
        :py:mod:`pysteps.io.importers`.

    n_ens_members: int
        Number of ensemble members in the forecast. This argument is ignored if
        incremental is set to 'member'.

    incremental: {None}, optional
        Currently not implemented for this method.

    Returns
    -------
    exporter: dict
        The return value is a dictionary containing an exporter object. This c
        an be used with :py:func:`pysteps.io.exporters.export_forecast_dataset`
        to write datasets into the given file format.

    """

    if incremental is not None:
        raise ValueError(
            "unknown option %s: " + "incremental writing is not supported" % incremental
        )

    exporter = {}

    # one file for each member
    n_ens_members = np.min((99, n_ens_members))
    fns = []
    for i in range(n_ens_members):
        outfn = "%s_N%02d%s" % (outfnprefix, i, ".pre")
        outfn = os.path.join(outpath, outfn)
        with open(outfn, "w") as fd:
            # write header
            fd.writelines("! pysteps-generated nowcast.\n")
            fd.writelines("! created the %s.\n" % datetime.now().strftime("%c"))
            # TODO(exporters): Add pySTEPS version here
            fd.writelines("! Member = %02d.\n" % i)
            fd.writelines("! Startdate = %s.\n" % startdate.strftime("%c"))
            fns.append(outfn)
        fd.close()

    h, w = shape

    if metadata["unit"] == "mm/h":
        var_name = "Intensity"
        var_long_name = "Intensity in mm/hr"
        var_unit = "mm/hr"
    elif metadata["unit"] == "mm":
        var_name = "Depth"
        var_long_name = "Accumulated depth in mm"
        var_unit = "mm"
    else:
        raise ValueError("unsupported unit %s" % metadata["unit"])

    xr = np.linspace(metadata["x1"], metadata["x2"], w + 1)[:-1]
    xr += 0.5 * (xr[1] - xr[0])
    yr = np.linspace(metadata["y1"], metadata["y2"], h + 1)[:-1]
    yr += 0.5 * (yr[1] - yr[0])

    xy_coords = np.stack(np.meshgrid(xr, yr))

    exporter["method"] = "kineros"
    exporter["ncfile"] = fns
    exporter["XY_coords"] = xy_coords
    exporter["var_name"] = var_name
    exporter["var_long_name"] = var_long_name
    exporter["var_unit"] = var_unit
    exporter["startdate"] = startdate
    exporter["timestep"] = timestep
    exporter["metadata"] = metadata
    exporter["incremental"] = incremental
    exporter["num_timesteps"] = n_timesteps
    exporter["num_ens_members"] = n_ens_members
    exporter["shape"] = shape

    return exporter
Initialize a KINEROS2 format exporter for the rainfall ".pre" files
specified in https://www.tucson.ars.ag.gov/kineros/.

Grid points are treated as individual rain gauges and a separate file is
produced for each ensemble member. The output files are named as
<outfnprefix>_N<n>.pre, where <n> is the index of ensemble member starting
from zero.

Parameters
----------
outpath: str
Output path.

outfnprefix: str
Prefix for output file names.

startdate: datetime.datetime
Start date of the forecast.

timestep: int
Time step of the forecast (minutes).

n_timesteps: int
Number of time steps in the forecast this argument is ignored if
incremental is set to 'timestep'.

shape: tuple of int
Two-element tuple defining the shape (height,width) of the forecast
grids.

metadata: dict
Metadata dictionary containing the projection,x1,x2,y1,y2 and unit
attributes described in the documentation of
:py:mod:`pysteps.io.importers`.

n_ens_members: int
Number of ensemble members in the forecast. This argument is ignored if
incremental is set to 'member'.

incremental: {None}, optional
Currently not implemented for this method.

Returns
-------
exporter: dict
The return value is a dictionary containing an exporter object. This c
an be used with :py:func:`pysteps.io.exporters.export_forecast_dataset`
to write datasets into the given file format.
pysteps/io/exporters.py