From 386b1fc9515cf8d2db1dde2f4643eb0dc5583bf3 Mon Sep 17 00:00:00 2001 From: wade Date: Tue, 23 Apr 2019 08:46:06 -0600 Subject: [PATCH] Added name and abbreviation properties to each metric function. Also allowed users to import all metrics with `import HydroErr` --- hydrostats/analyze.py | 6 ++++-- hydrostats/tests/tests.py | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/hydrostats/analyze.py b/hydrostats/analyze.py index 8a7f413..b74c8a2 100644 --- a/hydrostats/analyze.py +++ b/hydrostats/analyze.py @@ -36,7 +36,8 @@ def make_table(merged_dataframe, metrics, seasonal_periods=None, mase_m=1, dmod_ metrics: list of str A list of all the metrics that the user wants to calculate. The metrics abbreviations must - be used and can be found in the table of all the metrics in the documentation. + be used (e.g. the abbreviation for the mean error is "ME". Each function has an attribute with the name + and abbreviation, so this can be used instead (see example). seasonal_periods: 2D list of str, optional If given, specifies the seasonal periods that the user wants to analyze (e.g. [['06-01', @@ -121,6 +122,7 @@ def make_table(merged_dataframe, metrics, seasonal_periods=None, mase_m=1, dmod_ >>> import hydrostats.analyze as ha >>> import hydrostats.data as hd + >>> from hydrostats.metrics import mae, r_squared, nse, kge_2012 >>> >>> # Defining the URLs of the datasets >>> sfpt_url = r'https://github.com/waderoberts123/Hydrostats/raw/master/Sample_data/sfpt_data/magdalena-calamar_interim_data.csv' @@ -130,7 +132,7 @@ def make_table(merged_dataframe, metrics, seasonal_periods=None, mase_m=1, dmod_ Here we make a table and print the results: - >>> my_metrics = ['MAE', 'r2', 'NSE', 'KGE (2012)'] + >>> my_metrics = [mae.abbr, r_squared.abbr, nse.abbr, kge_2012.abbr] >>> seasonal = [['01-01', '03-31'], ['04-01', '06-30'], ['07-01', '09-30'], ['10-01', '12-31']] >>> table = ha.make_table(merged_df, my_metrics, seasonal, remove_neg=True, remove_zero=True, location='Magdalena') >>> table diff --git a/hydrostats/tests/tests.py b/hydrostats/tests/tests.py index 739bcf6..b592dd4 100644 --- a/hydrostats/tests/tests.py +++ b/hydrostats/tests/tests.py @@ -1,3 +1,4 @@ +from __future__ import division import sys import os