weights = 1e4 / sw.plot_size * (dx/4) * np.ones(meas.shape) plt.hist(meas, bins=N/4, weights=weights, histtype='stepfilled', color='0.5', edgecolor='0.5', label='aspen meas') plt.plot(aw.x, naw[j], '-r', label='aspen', linewidth=2) plt.legend(loc='best') plt.xlabel('dbh (mm)') plt.ylabel('stems per hectare') plt.savefig('plots/proj_%s_%d.png' % (plotname, t)) plt.close() psw = [ sw.population(nsw[j]) for j in range(len(T)) ] paw = [ aw.population(naw[j]) for j in range(len(T)) ] psw[0] = sum(nsw[0]) paw[0] = sum(naw[0]) # Tmeas = [ t for t in sw.meas['SW'] ] Tmeas = sw.years pswmeas = np.asarray([ len(sw.meas['SW'][t]) for t in Tmeas ]) / sw.plot_size * 1e4 pawmeas = np.asarray([ len(aw.meas['AW'][t]) for t in Tmeas ]) / aw.plot_size * 1e4 plt.figure() plt.plot(T[1:], psw[1:], 'ob', label='spruce') plt.plot(T[1:], paw[1:], 'or', label='aspen') plt.plot(Tmeas, pswmeas, 'sc', label='spruce (meas)') plt.plot(Tmeas, pawmeas, 'sm', label='aspen (meas)') plt.legend(loc='best')
k.setup(MidPoint(), N) mrates = [] for j in range(1, nsw.shape[0] - 1): mr = sw.population(nsw[j + 1]) / sw.population(nsw[j]) mrates.append(mr) mrates = np.asarray(mrates) print name, np.mean(mrates), np.var(mrates) # plt.figure() # for j, t in enumerate(T): # plt.plot(sw.x, nsw[j], '-b') # plt.plot(aw.x, naw[j], '-r') psw = np.asarray([sw.population(nsw[j]) for j in range(len(T))]) paw = np.asarray([aw.population(naw[j]) for j in range(len(T))]) psw[0] = sum(nsw[0]) paw[0] = sum(naw[0]) sage = np.asarray(T[1:]) + 20 sph[0].plot(sage, psw[1:], label=plotname, **pens[plotname]) sph[1].plot(sage, paw[1:], label=plotname, **pens[plotname]) sph[2].plot(sage, psw[1:] + paw[1:], label=plotname, **pens[plotname]) basal_area = lambda k, s: np.pi * np.dot(k.method.P, s * (k.x / 2) ** 2) / 1e6 swba = np.asarray([basal_area(sw, nsw[j]) for j in range(len(T))]) awba = np.asarray([basal_area(aw, naw[j]) for j in range(len(T))]) ba[0].plot(sage, swba[1:], label=plotname, **pens[plotname])