expzstar = expnpzfiles['out_prop_exp'][:,1] expcsurf = expnpzfiles['out_prop_exp'][:,2] lmprofid = lmnpzfiles['out_prop_lm'][:,0] lmzstar = lmnpzfiles['out_prop_lm'][:,1] lmcsurf = lmnpzfiles['out_prop_lm'][:,2] # that are fitted using exp vs. lm expzstarcl = filter(lambda x:~np.isinf(x) and ~np.isnan(x), expzstar) lmzstarcl = filter(lambda x:~np.isinf(x) and ~np.isnan(x), lmzstar) lm_df = pd.DataFrame(data=expnpzfiles['out_prop_exp'][:,1:], index=expnpzfiles['out_prop_exp'][:,0],columns=['zstar','csurf']) exp_df = pd.DataFrame(data=lmnpzfiles['out_prop_lm'][:,1:], index=lmnpzfiles['out_prop_lm'][:,0],columns=['zstar','csurf']) join_df = exp_df.join(lm_df, how='inner', lsuffix='_exp', rsuffix='_lm') fig, axes = plt.subplots(figsize=(10,8)) axes.scatter(join_df['zstar_exp'], join_df['zstar_lm']) axes.set_ylim([-500,1000]) axes.set_xlim([-500,1000]) axes.set_xlabel('zstar (cm, exp)') axes.set_ylabel('zstar (cm, lm)') myplt.refline() fig, axes = plt.subplots(figsize=(8,6)) axes.scatter(join_df['csurf_exp'], join_df['csurf_lm']) axes.set_ylim([0,60]) axes.set_xlim([0,60]) axes.set_xlabel('csurf (%, exp)') axes.set_ylabel('csurf (%, lm)') myplt.refline()
fig, axes = plt.subplots(nrows=1,ncols=1) #plt.hist(y,30,alpha=0.3, normed=True) plt.scatter(X[:,1],y) if plotres == 1: fig = plt.figure() ax = fig.add_axes([0.05, 0.05, 0.9, 0.9]) ax.scatter(model.predict(), model.resid) ax.set_ylabel('residual') ax.set_xlabel('yhat') if plot_y_yhat: fig = plt.figure() ax = fig.add_axes([0.05, 0.05, 0.9, 0.9]) ax.scatter(y, yhat) ax.set_ylabel('yhat') ax.set_xlabel('y') myplot.refline() boolist = yhat < -1000. idx = [i for i, elem in enumerate(boolist) if elem] #%% Linear Mixed Effects Model on profile filename = 'Non_peat_data_synthesis.csv' cutdep = 110. Cave14C = prep.getCweightedD14C2(filename) data = pd.read_csv(filename,encoding='iso-8859-1',skiprows=[1],index_col='ProfileID') profid = Cave14C[:,3] d14C = prep.getvarxls(data,'D14C_BulkLayer', profid, ':') mat = prep.getvarxls(data,'MAT', profid, ':') mapp = prep.getvarxls(data,'MAP', profid, ':') layerbot = prep.getvarxls(data, 'Layer_bottom_norm', profid, ':') vegid = prep.getvarxls(data, 'VegTypeCode_Local', profid, ':')