def plot_soil_canal(soil_canal, polys='all', calib_valid='valid'): soil = {s: [] for s in ['C', 'B', 'F', 'J']} canal = {c: [] for c in ['H', 'M', 'T']} if polys == 'best': if calib_valid == 'valid': if soil_canal == 'soil': npoly = [164, 36, 76, 50] #TODO: this can be changed elif soil_canal == 'canal': npoly = [76, 36, 164] elif calib_valid == 'calib': print('Please add the the best calibration polygons to present') elif polys == 'all': polygon_path = [ calib_polygon if calib_valid == 'calib' else valid_polygon ][0] npoly = list(load_obs_data(polygon_path)) d_polys = _soil_canal(npoly) for s_c, l_polys in d_polys.items(): soil[s_c[0]].extend(l_polys) canal[s_c[s_c.find(' ') + 1]].extend(l_polys) # plot by soils if soil_canal == 'soil': sc = soil elif soil_canal == 'canal': sc = canal return sc, npoly
from Paths import calib_polygon, valid_polygon from examples.load_data import load_obs_data, load_valid_res calib_obs = load_obs_data(calib_polygon) valid_obs = load_obs_data(valid_polygon) gofs = ['rmse', 'nse', 'aic', 'mic'] algorithms = ['fscabc', 'mle', 'demcz', 'dream'] dict_res = load_valid_res(algorithms, gofs) dict_res = {gof: {al: v2['all_res'] for al, v2 in v1.items()} for gof, v1 in dict_res.items()} print()
from Paths import plot_path from Histograms import plot_theil from Paths import valid_polygon, calib_polygon from data_process import _soil_canal, proc_soil_canal_mask from examples.load_data import load_obs_data, load_theil_data gofs = ['aic', 'mic'] algorithms = ['demcz', 'dream', 'fscabc', 'mle'] #'fscabc', 'mle', , 'dream' soil_canal = 'soil' calib_valid = 'valid' type_sim = ['weighted_sim', 'top_weighted_sim'] npoly = [ list(load_obs_data(calib_polygon)) if calib_valid == 'calib' else list( load_obs_data(valid_polygon)) ][0] s_cnl = _soil_canal(npoly) s_cnl = proc_soil_canal_mask(soil_canal, s_cnl) for type in type_sim: theil_data = load_theil_data(algorithms, gofs, type_sim=type, calib_valid=calib_valid) for gof in gofs: plot_theil(methods=algorithms, data=theil_data, polys=npoly, gof=gof,
if not gof_location: plot_path = plot_path + ['gofs/' if os.name == 'posix' else 'gofs\\'][0] valid_data = load_valid_likes(algorithms, gofs) calib_data, valid_data = equal_len_calib_valid(calib_data, valid_data) dfs = construct_df(calib_data, valid_data)[0] dist_parameters(dfs, save=plot_path + f'{obj_type}') else: plot_path = plot_path + ['gofs_soil_canal/' if os.name == 'posix' else 'gofs_soil_canal\\'][0] soil_canal = 'soil' # 'soil', 'canal' sc_name = ['' if soil_canal == 'all' else soil_canal][0] v_data = load_valid_res(algorithms, gofs) s_cnl = _soil_canal(list(load_obs_data(valid_polygon))) # calib_polygon s_cnl, mask = proc_soil_canal_mask(soil_canal, s_cnl, gen_mask=True) for gof in gofs: ylims = ylims(gof, v_data, algorithms) for al in algorithms: vdata = [ np.asarray([calib_data[gof][al][i] - v for i, v in enumerate(v_data[gof][al])]) if gof == 'aic' else v_data[gof][al]][0] vdata = proc_data_to_soil_canal(data=vdata, soil_canal=s_cnl) print(f"\nPlotting {gof}, {al.upper()}") boxplot_gof_loc({gof: calib_data[gof][al]}, {gof: vdata}, soil_canal_mask=mask, save=plot_path + f'{gof}_{sc_name}_{al[:2]}', ylims=ylims)
from Paths import calib_polygon, valid_polygon, plot_path from ParameterPlots import group_parameters_at_loc from config import construct_param_df from data_process import _soil_canal, retrieve_name, find_optimiza_parameter from examples.load_data import load_calib_param_data, load_obs_data gofs = ['aic', 'mic'] # algorithms = ['mle','demcz', 'dream', 'fscabc'] #'mle', 'demcz', 'dream', 'fscabc' calib_valid = 'valid' sc_type = 'canal' parameter_data = load_calib_param_data(algorithms, gofs, tops=False) if calib_valid == 'all': c_polys = list(load_obs_data(calib_polygon)) v_polys = list(load_obs_data(valid_polygon)) info_polys = {'calib': [c_polys, _soil_canal(c_polys)], 'valid': [v_polys, _soil_canal(v_polys)]} else: if calib_valid == 'valid': polys = list(load_obs_data(valid_polygon)) elif calib_valid == 'calib': polys = list(load_obs_data(calib_polygon)) soil_canal = _soil_canal(polys) info_polys = [polys, soil_canal] bf_opt_params, sd_opt_params = find_optimiza_parameter(parameter_data, algorithms, gofs, sc_type) type = 'hist' sc_type1 = ['Soil Class' if sc_type == 'soil' else 'Canal Position'][0] for gof in gofs: