diff --git a/metcalcpy/agg_stat.py b/metcalcpy/agg_stat.py index 87168967..3366cbba 100644 --- a/metcalcpy/agg_stat.py +++ b/metcalcpy/agg_stat.py @@ -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'], diff --git a/metcalcpy/util/sl1l2_statistics.py b/metcalcpy/util/sl1l2_statistics.py index c205f84c..04e62eed 100644 --- a/metcalcpy/util/sl1l2_statistics.py +++ b/metcalcpy/util/sl1l2_statistics.py @@ -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