Skip to content

Commit

Permalink
Feature 360 mode csi (#396)
Browse files Browse the repository at this point in the history
* 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.

* Issue #360 reformatting

* Issue #360 modify the equation for calculate_objacsi to suggested changes in METplus Discussion #2496.
  • Loading branch information
bikegeek authored Jul 30, 2024
1 parent 1c931da commit 2f1aeec
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions metcalcpy/util/mode_arearat_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
8 changes: 4 additions & 4 deletions metcalcpy/util/mode_ratio_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 2f1aeec

Please sign in to comment.