This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scipy.stats as stats | |
import numpy as np | |
def get_stats(obs, mod): | |
corr, corr_p = stats.pearsonr(obs, mod) | |
nse = 1 - (np.sum((obs - mod)**2)/np.sum((obs - np.mean(obs))**2)) | |
nse1 = 1 - (np.sum(np.abs(obs - mod))/np.sum(np.abs(obs - np.mean(obs)))) | |
rmse = np.sqrt(np.sum((obs-mod)**2)/len(mod)) | |
mae = np.sum(np.abs(mod-obs))/len(mod) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Clip time-series | |
def clip_ts(*tss): | |
mint = max([min(ts.index) for ts in tss]) | |
maxt = min([max(ts.index) for ts in tss]) | |
# clipped_tss = [ts[mint:maxt] for ts in tss] | |
clipped_tss = [ts.loc[(ts.index>=mint)&(ts.index<=maxt)] for ts in tss] | |
return clipped_tss |