Skip to content

Commit

Permalink
Add calculation of the Scatter Index statistic #108
Browse files Browse the repository at this point in the history
  • Loading branch information
TatianaBurek committed Aug 17, 2021
1 parent 3039283 commit fb6f400
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions metcalcpy/agg_stat.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ def __init__(self, in_params):
'mse': ['ffbar', 'oobar', 'fobar'],
'msess': ['ffbar', 'oobar', 'fobar', 'obar'],
'rmse': ['ffbar', 'oobar', 'fobar'],
'si': ['ffbar', 'oobar', 'fobar', 'obar'],
'estdev': ['ffbar', 'oobar', 'fobar', 'fbar', 'obar'],
'bcmse': ['ffbar', 'oobar', 'fobar', 'fbar', 'obar'],
'bcrmse': ['ffbar', 'oobar', 'fobar', 'fbar', 'obar'],
Expand Down
26 changes: 26 additions & 0 deletions metcalcpy/util/sl1l2_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,32 @@ def calculate_rmse(input_data, columns_names, aggregation=False):
return result


def calculate_si(input_data, columns_names, aggregation=False):
"""Performs calculation of SI - Scatter Index
Args:
input_data: 2-dimensional numpy array with data for the calculation
1st dimension - the row of data frame
2nd dimension - the column of data frame
columns_names: names of the columns for the 2nd dimension as Numpy array
aggregation: if the aggregation on fields was performed
Returns:
calculated SI as float
or None if some of the data values are missing or invalid
"""
warnings.filterwarnings('error')
try:
rmse = calculate_rmse(input_data, columns_names, aggregation)
obar = calculate_obar(input_data, columns_names, aggregation)
result = rmse / obar
result = round_half_up(result, PRECISION)
except (TypeError, Warning):
result = None
warnings.filterwarnings('ignore')
return result


def calculate_estdev(input_data, columns_names, aggregation=False):
"""Performs calculation of ESTDEV - Standard deviation of the error
Expand Down

0 comments on commit fb6f400

Please sign in to comment.