Created
February 15, 2022 22:30
-
-
Save pritamd47/dd512a1892c208d030a61fe370fed4d6 to your computer and use it in GitHub Desktop.
Compute statistics for observed and modeled time-series relevant to hydrological modeling
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) | |
return {'pearson-r': corr, 'pearson-r p-val': corr_p, 'nse': nse, 'nse1': nse1, 'rmse': rmse, 'mae': mae} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment