Climate2Weather / scripts /result.py
zhangrenchao's picture
Publish Climate2Weather reproduction
21b9cf1 verified
Raw
History Blame Contribute Delete
763 Bytes
from pathlib import Path
import sys,numpy as np;import matplotlib;matplotlib.use('Agg');import matplotlib.pyplot as plt
R=Path(__file__).resolve().parents[1];sys.path.insert(0,str(R));from model.climate2weather import cfg,write
c=cfg(R);d=np.load(R/c['paths']['predictions']);e=d['ensemble'];t=d['target'];mean=e.mean(0);rmse=float(np.sqrt(np.mean((mean-t)**2)));spread=float(e.std(0).mean());pit=float(np.mean(e<t[None]));coherence=float(np.mean(abs(np.diff(mean,axis=0))));write(R/c['paths']['evaluation'],{'rmse':rmse,'spread':spread,'pit_mean':pit,'temporal_difference':coherence,'synthetic':True});plt.imshow(mean[0,0]-t[0,0],cmap='coolwarm');plt.colorbar();p=R/c['paths']['figure'];p.parent.mkdir(parents=True,exist_ok=True);plt.savefig(p,dpi=150);print(p)