Skip to content

Commit

Permalink
Probabilistic Compare #169
Browse files Browse the repository at this point in the history
- moved function level variables to global where applicable in `cases_load_xarray.py`
- updated comments for band level params to include (x, y) coords
- removed legacy commented lines
  • Loading branch information
fernando-aristizabal committed Dec 15, 2023
1 parent c39a4ed commit 3c09fcf
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 197 deletions.
70 changes: 33 additions & 37 deletions tests/cases_compute_probabilistic_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ def case_compute_prob_metrics_brier_score_success():
expected_df.loc[0, "brier_score"] = expected_xr

# Band parameters for candidate
# background value, circle value, circle center, and circle radius
# background value, circle value, circle center (x, y) , and circle radius
band_params_candidate = [
(0, 1, (7, 7), 3), # Band 1
(0, 0, (12, 12), 5), # Band 2
(1, 1, (17, 17), 7), # Band 3
]

# Band parameters for benchmark
# background value, circle value, circle center, and circle radius
# background value, circle value, circle center (x, y) , and circle radius
band_params_benchmark = [
(0, 1, (8, 8), 4), # Band 1
(0, 0, (13, 13), 6), # Band 2
Expand Down Expand Up @@ -91,20 +91,16 @@ def case_compute_prob_metrics_crps_ensemble_success():
expected_df.loc[0, "crps_ensemble"] = expected_xr

# Band parameters for candidate
# background value, circle value, circle center, and circle radius
# background value, circle value, circle center (x, y) , and circle radius
band_params_candidate = [
(100, 300, (20, 20), 7),
(150, 350, (30, 30), 10),
(200, 400, (40, 40), 8),
]

# Band parameters for benchmark
# background value, circle value, circle center, and circle radius
band_params_benchmark = [
(145, 360, (25, 25), 15),
# (160, 360, (2, 2), 3),
# (210, 410, (3, 3), 4)
]
# background value, circle value, circle center (x, y) , and circle radius
band_params_benchmark = [(145, 360, (25, 25), 15)]

# Generate the xarray pairs
candidate_map, benchmark_map = _create_xarray_pairs(
Expand Down Expand Up @@ -143,15 +139,15 @@ def case_compute_prob_metrics_crps_gaussian_success():
expected_df.loc[0, "crps_gaussian"] = expected_xr

# Band parameters for candidate
# background value, circle value, circle center, and circle radius
# background value, circle value, circle center (x, y) , and circle radius
band_params_candidate = [
(140, 340, (9, 9), 3), # Band 1
(190, 390, (14, 14), 5), # Band 2
(240, 440, (19, 19), 7), # Band 3
]

# Band parameters for benchmark
# background value, circle value, circle center, and circle radius
# background value, circle value, circle center (x, y) , and circle radius
band_params_benchmark = [
(150, 350, (10, 10), 4), # Band 1
(200, 400, (15, 15), 6), # Band 2
Expand Down Expand Up @@ -198,14 +194,14 @@ def case_compute_prob_metrics_crps_quadrature_success():
expected_df.loc[0, "crps_quadrature"] = expected_xr

# Band parameters for candidate
# background value, circle value, circle center, and circle radius
# background value, circle value, circle center (x, y) , and circle radius
band_params_candidate = [
(140, 340, (3, 3), 1), # Band 1
(190, 390, (2, 2), 1), # Band 2
]

# Band parameters for benchmark
# background value, circle value, circle center, and circle radius
# background value, circle value, circle center (x, y) , and circle radius
band_params_benchmark = [
(150, 350, (3, 3), 1), # Band 1
(200, 400, (2, 2), 1), # Band 2
Expand Down Expand Up @@ -253,15 +249,15 @@ def case_compute_prob_metrics_discrimination_success():
expected_df.loc[0, "discrimination"] = expected_xr

# Band parameters for candidate
# background value, circle value, circle center, and circle radius
# background value, circle value, circle center (x, y) , and circle radius
band_params_candidate = [
(140, 340, (9, 9), 3), # Band 1
(190, 390, (14, 14), 5), # Band 2
(240, 440, (19, 19), 7), # Band 3
]

# Band parameters for benchmark
# background value, circle value, circle center, and circle radius
# background value, circle value, circle center (x, y) , and circle radius
band_params_benchmark = [
(150, 350, (10, 10), 4), # Band 1
(200, 400, (15, 15), 6), # Band 2
Expand Down Expand Up @@ -305,15 +301,15 @@ def case_compute_prob_metrics_rank_histogram_success():
expected_df.loc[0, "rank_histogram"] = expected_xr

# Band parameters for candidate
# background value, circle value, circle center, and circle radius
# background value, circle value, circle center (x, y) , and circle radius
band_params_candidate = [
(140, 340, (9, 9), 3), # Band 1
(190, 390, (14, 14), 5), # Band 2
(240, 440, (19, 19), 7), # Band 3
]

# Band parameters for benchmark
# background value, circle value, circle center, and circle radius
# background value, circle value, circle center (x, y) , and circle radius
band_params_benchmark = [
(150, 350, (10, 10), 4), # Band 1
]
Expand Down Expand Up @@ -368,15 +364,15 @@ def case_compute_prob_metrics_reliability_success():
expected_df.loc[0, "reliability"] = expected_xr

# Band parameters for candidate
# background value, circle value, circle center, and circle radius
# background value, circle value, circle center (x, y) , and circle radius
band_params_candidate = [
(0.03, 0.76, (9, 9), 3), # Band 1
(0.89, 0.09, (14, 14), 5), # Band 2
(0.29, 0.63, (219, 19), 7), # Band 3
]

# Band parameters for benchmark
# background value, circle value, circle center, and circle radius
# background value, circle value, circle center (x, y) , and circle radius
band_params_benchmark = [
(0, 1, (10, 10), 4), # Band 1
(1, 0, (15, 15), 6), # Band 2
Expand Down Expand Up @@ -418,15 +414,15 @@ def case_compute_prob_metrics_roc_success():
expected_df.loc[0, "roc"] = expected_xr

# Band parameters for candidate
# background value, circle value, circle center, and circle radius
# background value, circle value, circle center (x, y) , and circle radius
band_params_candidate = [
(0, 1, (9, 9), 3), # Band 1
(1, 0, (14, 14), 5), # Band 2
(0, 1, (19, 19), 7), # Band 3
]

# Band parameters for benchmark
# background value, circle value, circle center, and circle radius
# background value, circle value, circle center (x, y) , and circle radius
band_params_benchmark = [
(0, 1, (10, 10), 4), # Band 1
(1, 0, (15, 15), 6), # Band 2
Expand Down Expand Up @@ -481,15 +477,15 @@ def case_compute_prob_metrics_rps_success():
expected_df.loc[0, "rps"] = expected_xr

# Band parameters for candidate
# background value, circle value, circle center, and circle radius
# background value, circle value, circle center (x, y) , and circle radius
band_params_candidate = [
(0.08, 0.92, (9, 9), 3), # Band 1
(0.76, 0.1, (14, 14), 5), # Band 2
(0.12, 0.88, (19, 19), 7), # Band 3
]

# Band parameters for benchmark
# background value, circle value, circle center, and circle radius
# background value, circle value, circle center (x, y) , and circle radius
band_params_benchmark = [
(0.2, 0.94, (10, 10), 4), # Band 1
(0.71, 0.13, (15, 15), 6), # Band 2
Expand Down Expand Up @@ -538,15 +534,15 @@ def case_compute_prob_metrics_threshold_brier_score_success():
expected_df.loc[0, "threshold_brier_score"] = expected_xr

# Band parameters for candidate
# background value, circle value, circle center, and circle radius
# background value, circle value, circle center (x, y) , and circle radius
band_params_candidate = [
(0, 0.85, (9, 9), 3), # Band 1
(0.75, 0, (14, 14), 5), # Band 2
(0, 0.78, (19, 19), 7), # Band 3
]

# Band parameters for benchmark
# background value, circle value, circle center, and circle radius
# background value, circle value, circle center (x, y) , and circle radius
band_params_benchmark = [
(0, 1, (10, 10), 4), # Band 1
]
Expand Down Expand Up @@ -586,13 +582,13 @@ def case_compute_prob_metrics_error_success():
expected_df.loc[0, "crps_gaussian"] = expected_error

# Band parameters for candidate
# background value, circle value, circle center, and circle radius
# background value, circle value, circle center (x, y) , and circle radius
band_params_candidate = [
(140, 340, (9, 9), 3), # Band 1
]

# Band parameters for benchmark
# background value, circle value, circle center, and circle radius
# background value, circle value, circle center (x, y) , and circle radius
band_params_benchmark = [
(150, 350, (10, 10), 4), # Band 1
]
Expand Down Expand Up @@ -621,15 +617,15 @@ def case_compute_prob_metrics_kwargs_required_fail():
compute_kwargs = {"metric_kwargs": {"crps_gaussian": None}, "return_on_error": None}

# Band parameters for candidate
# background value, circle value, circle center, and circle radius
# background value, circle value, circle center (x, y) , and circle radius
band_params_candidate = [
(0, 1, (7, 7), 3), # Band 1
(0, 0, (12, 12), 5), # Band 2
(1, 1, (17, 17), 7), # Band 3
]

# Band parameters for benchmark
# background value, circle value, circle center, and circle radius
# background value, circle value, circle center (x, y) , and circle radius
band_params_benchmark = [
(0, 1, (8, 8), 4), # Band 1
(0, 0, (13, 13), 6), # Band 2
Expand Down Expand Up @@ -663,15 +659,15 @@ def case_compute_prob_metrics_specific_kwargs_required_fail():
}

# Band parameters for candidate
# background value, circle value, circle center, and circle radius
# background value, circle value, circle center (x, y) , and circle radius
band_params_candidate = [
(0, 1, (7, 7), 3), # Band 1
(0, 0, (12, 12), 5), # Band 2
(1, 1, (17, 17), 7), # Band 3
]

# Band parameters for benchmark
# background value, circle value, circle center, and circle radius
# background value, circle value, circle center (x, y) , and circle radius
band_params_benchmark = [
(0, 1, (8, 8), 4), # Band 1
(0, 0, (13, 13), 6), # Band 2
Expand Down Expand Up @@ -705,15 +701,15 @@ def case_compute_prob_metrics_kwargs_extra_fail():
}

# Band parameters for candidate
# background value, circle value, circle center, and circle radius
# background value, circle value, circle center (x, y) , and circle radius
band_params_candidate = [
(0, 1, (7, 7), 3), # Band 1
(0, 0, (12, 12), 5), # Band 2
(1, 1, (17, 17), 7), # Band 3
]

# Band parameters for benchmark
# background value, circle value, circle center, and circle radius
# background value, circle value, circle center (x, y) , and circle radius
band_params_benchmark = [
(0, 1, (8, 8), 4), # Band 1
(0, 0, (13, 13), 6), # Band 2
Expand Down Expand Up @@ -747,15 +743,15 @@ def case_compute_prob_metrics_missing_metric_fail():
}

# Band parameters for candidate
# background value, circle value, circle center, and circle radius
# background value, circle value, circle center (x, y) , and circle radius
band_params_candidate = [
(0, 1, (7, 7), 3), # Band 1
(0, 0, (12, 12), 5), # Band 2
(1, 1, (17, 17), 7), # Band 3
]

# Band parameters for benchmark
# background value, circle value, circle center, and circle radius
# background value, circle value, circle center (x, y) , and circle radius
band_params_benchmark = [
(0, 1, (8, 8), 4), # Band 1
(0, 0, (13, 13), 6), # Band 2
Expand Down Expand Up @@ -789,15 +785,15 @@ def case_compute_prob_metrics_metric_func_warns():
}

# Band parameters for candidate
# background value, circle value, circle center, and circle radius
# background value, circle value, circle center (x, y) , and circle radius
band_params_candidate = [
(0, 1, (7, 7), 3), # Band 1
(0, 0, (12, 12), 5), # Band 2
(1, 1, (17, 17), 7), # Band 3
]

# Band parameters for benchmark
# background value, circle value, circle center, and circle radius
# background value, circle value, circle center (x, y) , and circle radius
band_params_benchmark = [
(0, 1, (8, 8), 4), # Band 1
(0, 0, (13, 13), 6), # Band 2
Expand Down
Loading

0 comments on commit 3c09fcf

Please sign in to comment.