def test_blending_skill_scores(
    obs,
    mod,
    lt,
    PHI,
    cor_prev,
    clim_cor_values,
    regr_pars,
    n_cascade_levels,
    expected_cor_t0,
    expected_cor_nwp_lt,
    expected_cor_nowcast_lt,
    n_model,
    number_of_models,
):
    """Tests if the skill_score functions behave correctly. A dummy gridded
    model and observation field should be given for n_cascade_levels, which
    leads to a given spatial correlation per cascade level. Then, the function
    tests if the correlation regresses towards the climatological values given
    lead time lt for the NWP fields or given the PHI-values for the
    extrapolation field.

    """
    if number_of_models != None:
        skill_kwargs = {"n_models": number_of_models}
    else:
        skill_kwargs = None

    domain_mask = np.full(obs[0, :, :].shape, False, dtype=bool)

    # Calculate the spatial correlation of the given model field
    correlations_t0 = np.array(spatial_correlation(obs, mod, domain_mask))

    # Check if the field has the same number of cascade levels as the model
    # field and as the given n_cascade_levels
    assert (
        correlations_t0.shape[0] == mod.shape[0]
    ), "Number of cascade levels should be the same as in the model field"
    assert (
        correlations_t0.shape[0] == n_cascade_levels
    ), "Number of cascade levels should be the same as n_cascade_levels"

    # Check if the returned values are as expected
    assert_array_almost_equal(
        correlations_t0,
        expected_cor_t0,
        decimal=3,
        err_msg="Returned spatial correlation is not the same as the expected value",
    )

    # Test if the NWP correlation regresses towards the correct value given
    # a lead time in minutes
    # First, check if the climatological values are returned correctly
    correlations_clim, regr_clim = clim_regr_values(
        n_cascade_levels=n_cascade_levels,
        outdir_path="./tmp/",
        n_model=n_model,
        skill_kwargs=skill_kwargs,
    )
    assert (
        correlations_clim.shape[0] == n_cascade_levels
    ), "Number of cascade levels should be the same as n_cascade_levels"
    assert_array_almost_equal(
        correlations_clim,
        clim_cor_values,
        decimal=3,
        err_msg="Not the correct climatological correlations were returned",
    )
    assert_array_almost_equal(
        regr_clim,
        regr_pars,
        decimal=3,
        err_msg="Not the correct regression parameters were returned",
    )

    # Then, check the regression of the correlation values
    correlations_nwp_lt = lt_dependent_cor_nwp(
        lt=lt, correlations=correlations_t0, outdir_path="./tmp/"
    )
    assert (
        correlations_nwp_lt.shape[0] == mod.shape[0]
    ), "Number of cascade levels should be the same as in the model field"
    assert (
        correlations_nwp_lt.shape[0] == n_cascade_levels
    ), "Number of cascade levels should be the same as n_cascade_levels"
    assert_array_almost_equal(
        correlations_nwp_lt,
        expected_cor_nwp_lt,
        decimal=3,
        err_msg="Correlations of NWP not equal to the expected correlations",
    )

    # Finally, make sure nowcast correlation regresses towards the correct
    # value given some PHI-values.
    correlations_nowcast_lt, __ = lt_dependent_cor_extrapolation(
        PHI, correlations_t0, cor_prev
    )

    print(correlations_nowcast_lt)
    assert (
        correlations_nowcast_lt.shape[0] == mod.shape[0]
    ), "Number of cascade levels should be the same as in the model field"
    assert (
        correlations_nowcast_lt.shape[0] == n_cascade_levels
    ), "Number of cascade levels should be the same as n_cascade_levels"
    assert_array_almost_equal(
        correlations_nowcast_lt,
        expected_cor_nowcast_lt,
        decimal=3,
        err_msg="Correlations of nowcast not equal to the expected correlations",
    )
Tests if the skill_score functions behave correctly. A dummy gridded
model and observation field should be given for n_cascade_levels, which
leads to a given spatial correlation per cascade level. Then, the function
tests if the correlation regresses towards the climatological values given
lead time lt for the NWP fields or given the PHI-values for the
extrapolation field.
pysteps/tests/test_blending_skill_scores.py