From da82271092dde3d30ea88e64a73c34da2b1c271e Mon Sep 17 00:00:00 2001 From: bikegeek Date: Tue, 16 Jul 2024 12:15:03 -0600 Subject: [PATCH 1/3] Issue #360 implement equation change to what was suggested in METplus Discussion #2496 for calculating the OBJCSI value corresponding to the calcOBJCSI function that is also implemented in R in the METviewer code. --- metcalcpy/util/mode_ratio_statistics.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/metcalcpy/util/mode_ratio_statistics.py b/metcalcpy/util/mode_ratio_statistics.py index 39b7571e..ebaca3d7 100644 --- a/metcalcpy/util/mode_ratio_statistics.py +++ b/metcalcpy/util/mode_ratio_statistics.py @@ -838,17 +838,17 @@ def calculate_objcsi(input_data, columns_names): or None if some of the data values are missing or invalid """ warnings.filterwarnings('error') - nominator_filter = {'fcst_flag': 1, 'matched_flag': 0} + nominator_filter = {'simple_flag': 1, 'matched_flag': 1} denominator_filter_1 = {'simple_flag': 1, 'matched_flag': 1} denominator_filter_2 = {'simple_flag': 1, 'matched_flag': 0} try: - nominator = nrow_column_data_by_name_value(input_data, columns_names, nominator_filter) + nominator = nrow_column_data_by_name_value(input_data, columns_names, nominator_filter) / 2 denominator_1 = \ - nrow_column_data_by_name_value(input_data, columns_names, denominator_filter_1) + nrow_column_data_by_name_value(input_data, columns_names, denominator_filter_1) / 2 denominator_2 = \ nrow_column_data_by_name_value(input_data, columns_names, denominator_filter_2) - result = round_half_up(nominator / (denominator_1 + 2 * denominator_2), PRECISION) + result = round_half_up(nominator / (denominator_1 + denominator_2), PRECISION) except (TypeError, ZeroDivisionError, Warning, ValueError): result = None warnings.filterwarnings('ignore') From 3d1b4d449a8e2cfa7d91b806c1dead8c5d7e20d3 Mon Sep 17 00:00:00 2001 From: bikegeek Date: Tue, 16 Jul 2024 12:21:57 -0600 Subject: [PATCH 2/3] Issue #360 reformatting --- metcalcpy/util/mode_ratio_statistics.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metcalcpy/util/mode_ratio_statistics.py b/metcalcpy/util/mode_ratio_statistics.py index ebaca3d7..a61d2f28 100644 --- a/metcalcpy/util/mode_ratio_statistics.py +++ b/metcalcpy/util/mode_ratio_statistics.py @@ -848,7 +848,7 @@ def calculate_objcsi(input_data, columns_names): nrow_column_data_by_name_value(input_data, columns_names, denominator_filter_1) / 2 denominator_2 = \ nrow_column_data_by_name_value(input_data, columns_names, denominator_filter_2) - result = round_half_up(nominator / (denominator_1 + denominator_2), PRECISION) + result = round_half_up(nominator / (denominator_1 + denominator_2), PRECISION) except (TypeError, ZeroDivisionError, Warning, ValueError): result = None warnings.filterwarnings('ignore') From f04c770476f35706f5d69ecf9f10de2e7c37e899 Mon Sep 17 00:00:00 2001 From: bikegeek Date: Tue, 16 Jul 2024 12:23:50 -0600 Subject: [PATCH 3/3] Issue #360 modify the equation for calculate_objacsi to suggested changes in METplus Discussion #2496. --- metcalcpy/util/mode_arearat_statistics.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/metcalcpy/util/mode_arearat_statistics.py b/metcalcpy/util/mode_arearat_statistics.py index 2ca56f8e..18d453cb 100644 --- a/metcalcpy/util/mode_arearat_statistics.py +++ b/metcalcpy/util/mode_arearat_statistics.py @@ -902,16 +902,16 @@ def calculate_objacsi(input_data, columns_names): try: nominator_data = column_data_by_name_value(input_data, columns_names, nominator_filter) - nominator = sum_column_data_by_name(nominator_data, columns_names, 'area') + nominator = sum_column_data_by_name(nominator_data, columns_names, 'area') / 2 denominator_1_data = \ column_data_by_name_value(input_data, columns_names, denominator_filter_1) - denominator_1 = sum_column_data_by_name(denominator_1_data, columns_names, 'area') + denominator_1 = sum_column_data_by_name(denominator_1_data, columns_names, 'area') / 2 denominator_2_data = \ column_data_by_name_value(input_data, columns_names, denominator_filter_2) denominator_2 = sum_column_data_by_name(denominator_2_data, columns_names, 'area') - result = round_half_up(nominator / (denominator_1 + 2 * denominator_2), PRECISION) + result = round_half_up(nominator / (denominator_1 + denominator_2), PRECISION) except (TypeError, ZeroDivisionError, Warning, ValueError): result = None warnings.filterwarnings('ignore')