From 36bbb8390f29d307fa77412cd51a4d2847e263d5 Mon Sep 17 00:00:00 2001 From: Chris Leaman Date: Mon, 19 Nov 2018 15:14:28 +1100 Subject: [PATCH] Add module to compare forecasted and observed storm impacts --- src/analysis/compare_impacts.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/analysis/compare_impacts.py diff --git a/src/analysis/compare_impacts.py b/src/analysis/compare_impacts.py new file mode 100644 index 0000000..a74e8c5 --- /dev/null +++ b/src/analysis/compare_impacts.py @@ -0,0 +1,32 @@ +""" +Compares forecasted and observed impacts, putting them into one data frame and exporting the results. +""" + +import logging.config +import os + +import pandas as pd + +logging.config.fileConfig('./src/logging.conf', disable_existing_loggers=False) +logger = logging.getLogger(__name__) + + +def compare_impacts(df_forecasted, df_observed): + """ + Merge forecasted and observed storm impacts + :param df_forecasted: + :param df_observed: + :return: + """ + df_compared = df_forecasted.merge(df_observed, left_index=True, right_index=True, + suffixes=['_forecasted', '_observed']) + return df_compared + + +if __name__ == '__main__': + logger.info('Importing existing data') + data_folder = './data/interim' + df_forecasted = pd.read_csv(os.path.join(data_folder, 'impacts_forecasted_mean_slope_sto06.csv'), index_col=[0]) + df_observed = pd.read_csv(os.path.join(data_folder, 'impacts_observed.csv'), index_col=[0]) + df_compared = compare_impacts(df_forecasted, df_observed) + df_compared.to_csv(os.path.join(data_folder, 'impacts_observed_vs_forecasted_mean_slope_sto06.csv'))