is_smlzn1m = data.loc[kk:kk, 'Layer_bottom'].values<100. if data.loc[kk:kk, 'Layer_bottom'].values[-1] > 100.: lastlyrCcnt = data.loc[kk:kk, 'pct_C'].values[wr_smlzn1m[-1]+1] * \ data.loc[kk:kk, 'BulkDensity'].values[wr_smlzn1m[-1]+1] * \ (100. - data.loc[kk:kk, 'Layer_top'].values[wr_smlzn1m[-1]+1]) cumC = data.loc[kk:kk, 'cumC'].values cumC[wr_smlzn1m[-1]+1] = cumC[wr_smlzn1m[-1]] + lastlyrCcnt is_bigznD0 = data.loc[kk:kk, 'D14C_BulkLayer'].values>0. is_smlznD500 = data.loc[kk:kk, 'D14C_BulkLayer'].values<=-500. cfast = cumC[is_bigznD0 & is_smlzn1m] cpasv = cumC[is_smlznD500 & is_smlzn1m][-1] - \ cumC[np.where(cumC==cumC[is_smlznD500 & is_smlzn1m][0])[-1]][0] cfastfrac[-1] += [cfast], cpasvfrac[-1] += [cpasv], df = prep.getprofSOCD14C_interp(filename, 100) #%% calculate # profiles that start from top and are at least 1m deep newdf = prep.cal_pfNumber(0, 0.) filename = 'Non_peat_data_synthesis.csv' data = pd.read_csv(filename,encoding='iso-8859-1',index_col='ProfileID', skiprows=[1]) profid = data.index.unique() Cave14C = prep.getCweightedD14C2(data, cutdep=100.) top0 = prep.getvarxls(data, 'Layer_top', profid, 0) plt.hist(top0,cumulative=True,bins=100) top0bottom = prep.getvarxls(newdf, 'Layer_bottom', newdf.index.unique(), -1) plt.hist(top0bottom,cumulative=True,bins=100) #%% plot total SOC vs. D14C
import pandas as pd import numpy as np import matplotlib.pyplot as plt import D14Cpreprocess as prep import pylab filename = 'tot48prof.txt' dum = np.loadtxt(filename, delimiter=',') profid = dum[:,2] #%% plot cumuSOC vs cumuC-averaged D14C cm = plt.get_cmap('gist_rainbow') numcolr = len(profid) # no repeat in color fig, axes = plt.subplots(nrows=1, ncols=1, figsize=(8,6)) axes.set_color_cycle([cm(1.*jj/numcolr) for jj in range(numcolr)]) for i in profid: data = prep.getprofSOCD14C_interp('Non_peat_data_synthesis.csv',i,cutdep=100.) cumuC = np.cumsum(data[:,2]) cumufracC = cumuC/cumuC[-1] cumuD14C = np.cumsum(data[:,1] * data[:,2])/cumuC axes.plot(cumufracC, cumuD14C, ':', lw=2) axes.set_xlabel('Cumulative SOC fraction (%)') axes.set_ylabel(r"Cumulative $\Delta^{14}C$ ("+ u"\u2030)") #%% plot cumuSOC vs D14C cm = plt.get_cmap('gist_rainbow') numcolr = len(profid) # no repeat in color fig, axes = plt.subplots(nrows=1, ncols=1, figsize=(8,6)) axes.set_color_cycle([cm(1.*jj/numcolr) for jj in range(numcolr)]) for i in profid: if i==144.: continue