for i, run_id in enumerate(dict_in.keys()): if hy == '2017-18': sim_swe = dict_in[run_id]['states_output'].swe.copy().truncate( after='2017-12-31 23:00:00') if hy == '2019-20': sim_swe = dict_in[run_id]['states_output'].swe.copy().truncate( before='2019-05-01 00:00:00', after='2019-11-12 00:00:00') # assert np.all(sim_swe.index == obs_swe.index) #TODO fix index so both timezone aware # cut to just period with observed swe sim_swe = sim_swe[obs_ind] if model == 'fsm2': sim_swe = sim_swe.values stats_store['ns'][i] = nash_sut(sim_swe, obs_swe) stats_store['bias'][i] = mean_bias(sim_swe, obs_swe) stats_store['rmsd'][i] = rmsd(sim_swe, obs_swe) stats_store['mae'][i] = mean_absolute_error(sim_swe, obs_swe) stats_store['run_id'][i] = run_id if model == 'fsm2': sim_nml = dict_in[run_id]['namelist'] for key in sim_nml['params'].keys(): param_store[key][i] = sim_nml['params'][key] # param_store['exe'][i] = dict_in[run_id]['exe'][1] # param_store['density'][i] = dict_in[run_id]['exe'][0] param_store['exchng'][i] = dict_in[run_id]['exe'][1] param_store['hydrol'][i] = dict_in[run_id]['exe'][2] elif model == 'clark' or model == 'eti': for key in dict_in[run_id]['config'].keys(): param_store[key][i] = dict_in[run_id]['config'][key]
# plt.imshow(np.mean(modis_fsca_rs, axis=0),origin=0) # plt.figure() # plt.imshow(np.mean(model_fsca_rs, axis=0),origin=0) ns_array = np.zeros((ny_out, nx_out)) mbd_array = np.zeros((ny_out, nx_out)) rmsd_array = np.zeros((ny_out, nx_out)) mae_array = np.zeros((ny_out, nx_out)) for i in range(ny_out): for j in range(nx_out): obs = np.convolve(modis_fsca_rs[:, i, j], np.ones((smooth_period,)) / smooth_period, mode='same') mod = np.convolve(model_fsca_rs[:, i, j], np.ones((smooth_period,)) / smooth_period, mode='same') ns_array[i, j] = nash_sut(mod, obs) mbd_array[i, j] = mean_bias(mod, obs) rmsd_array[i, j] = rmsd(mod, obs) mae_array[i, j] = mean_absolute_error(mod, obs) modis_mean = np.mean(modis_fsca_rs, axis=0) model_mean = np.mean(model_fsca_rs, axis=0) s_ns.append(ns_array) s_bias.append(mbd_array) s_rmse.append(rmsd_array) s_mae.append(mae_array) s_obs.append(modis_mean) s_mod.append(model_mean) for i,j,name in zip([161,147,127,107,186,125],[83,102,59,88,21,34],['Pisa','Dunstan','Hector','Old Man','Earnslaw','Lochy']): plot_point(i,j,name,year_to_take)
inp_hourdec, dtstep=1800, init_swe=init_swe, init_d_snow=init_d_snow, inp_sw=inp_sw, which_melt='dsc_snow', **config) daily_swe3 = [] for k in range(47, len(st_swe3[:, 0]), 48): daily_swe3.append(st_swe3[k, 0]) mb_sim = -1 * np.diff(np.asarray(daily_swe3)) ns_array[i, j] = nash_sut(mb_sim, daily_sfc_melt) mbd_array[i, j] = mean_bias(mb_sim, daily_sfc_melt) rmsd_array[i, j] = rmsd(mb_sim, daily_sfc_melt) h_ns_array[i, j] = nash_sut(-1 * np.diff(st_swe3[:, 0]), hourly_seb_melt) h_mbd_array[i, j] = mean_bias(-1 * np.diff(st_swe3[:, 0]), hourly_seb_melt) h_rmsd_array[i, j] = rmsd(-1 * np.diff(st_swe3[:, 0]), hourly_seb_melt) np.savetxt( outfolder + '/daily_sfc_ns_2010_TF_TT_ROS{}_ta_m_tt{}.txt'.format( config['ros'], config['ta_m_tt']), ns_array) np.savetxt( outfolder + '/daily_sfc_mbd_2010_TF_TT_ROS{}_ta_m_tt{}.txt'.format( config['ros'], config['ta_m_tt']), mbd_array) np.savetxt(