def test_io_export_netcdf_one_member_one_time_step(
    n_ens_members, incremental, datatype, fill_value, scale_factor, offset, n_timesteps
):
    """
    Test the export netcdf.
    Also, test that the exported file can be read by the importer.
    """

    pytest.importorskip("pyproj")

    precip, metadata = get_precipitation_fields(
        num_prev_files=2, return_raw=True, metadata=True, source="fmi"
    )

    invalid_mask = get_invalid_mask(precip)

    with tempfile.TemporaryDirectory() as outpath:
        # save it back to disk
        outfnprefix = "test_netcdf_out"
        file_path = os.path.join(outpath, outfnprefix + ".nc")
        startdate = metadata["timestamps"][0]
        timestep = metadata["accutime"]
        shape = precip.shape[1:]

        exporter = initialize_forecast_exporter_netcdf(
            outpath,
            outfnprefix,
            startdate,
            timestep,
            n_timesteps,
            shape,
            metadata,
            n_ens_members=n_ens_members,
            datatype=datatype,
            incremental=incremental,
            fill_value=fill_value,
            scale_factor=scale_factor,
            offset=offset,
        )

        if n_ens_members > 1:
            precip = np.repeat(precip[np.newaxis, :, :, :], n_ens_members, axis=0)

        if incremental == None:
            export_forecast_dataset(precip, exporter)
        if incremental == "timestep":
            if isinstance(n_timesteps, list):
                timesteps = len(n_timesteps)
            else:
                timesteps = n_timesteps
            for t in range(timesteps):
                if n_ens_members > 1:
                    export_forecast_dataset(precip[:, t, :, :], exporter)
                else:
                    export_forecast_dataset(precip[t, :, :], exporter)
        if incremental == "member":
            for ens_mem in range(n_ens_members):
                export_forecast_dataset(precip[ens_mem, :, :, :], exporter)

        close_forecast_files(exporter)

        # assert if netcdf file was saved and file size is not zero
        assert os.path.exists(file_path) and os.path.getsize(file_path) > 0

        # Test that the file can be read by the nowcast_importer
        output_file_path = os.path.join(outpath, f"{outfnprefix}.nc")

        precip_new, _ = import_netcdf_pysteps(output_file_path)

        assert_array_almost_equal(precip.squeeze(), precip_new.data)
        assert precip_new.dtype == "single"

        precip_new, _ = import_netcdf_pysteps(output_file_path, dtype="double")
        assert_array_almost_equal(precip.squeeze(), precip_new.data)
        assert precip_new.dtype == "double"

        precip_new, _ = import_netcdf_pysteps(output_file_path, fillna=-1000)
        new_invalid_mask = precip_new == -1000
        assert (new_invalid_mask == invalid_mask).all()
Test the export netcdf.
Also, test that the exported file can be read by the importer.
pysteps/tests/test_exporters.py