def __get_deficit_stats_comparison(project, analysis_f, units): """ The the deficit stats comparison dataset for a project. Parameters ========== analysis_f : f(data, gap_attribute_name, target_attribute_name) The function that returns the monthly stats dataset for a scenario """ datasets = [] names = [] for scenario in project.scenarios.all(): data = scenario.get_data() attribute_name = scenario.get_gap_attribute_name() target_name = scenario.get_target_attribute_name() monthly_values = analysis_f(data, attribute_name, target_name) monthly_values.index.name = "Month" monthly_values.name = attribute_name datasets.append(monthly_values) names.append(scenario.name + " (%s)" % units) return analysis.compare_series(datasets, names)
def __get_deficit_days_comparison(project, analysis_f, index_name): """ Get the temporal deficit comparison for a project. analysis_f : f(data, gap_attribute_name, target_attribute_name) The function that returns the annual temporal information. index_name : string The name to use for the resulting DataFrame's index. """ datasets = [] names = [] for scenario in project.scenarios.all(): #try: data = scenario.get_data() attribute_name = scenario.get_gap_attribute_name() target_attribute_name = scenario.get_target_attribute_name() data_pct = analysis_f(data, attribute_name, target_attribute_name) data_pct.index.name = index_name datasets.append(data_pct) names.append(scenario.name) #except: # pass return analysis.compare_series(datasets, names)