Data from runs over 3000 years for different possible income from trade.
Single trajectories are also evaluated, since the aggregate data does not give insight into the actual model behavior.
NOTE: These runs are done without climate variability. The variation is only caused by interplay of social and ecological dynamics in the system.
In [1]:
%pylab inline
pylab.rcParams['figure.figsize'] = (14, 6)
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
d_start = 150
d_length = 20
testing = False
location = '/home/jakob/Project_MayaSim/Python/output_data/X8_longterm_dynamics/results/trajectory'
if testing:
location = '/home/jakob/Project_MayaSim/Python/output_data/test_output/X8_longterm_dynamics/results/trajectory'
data = pd.read_pickle(location)
def plot(obs, data):
r_trades = data.index.levels[0].values
fig = plt.figure()
k = 0
plots = []
for j, r in enumerate(r_trades):
k += 1
ax = fig.add_subplot(1, len(r_trades), j + 1)
ax.set_title('{}) r_trade = {}'.format(k, r))
dt = data['<mean_trajectories>'].xs(level=('r_trade', 'observables'), key=(r, obs))
de = data['<sigma_trajectories>'].xs(level=('r_trade', 'observables'), key=(r, obs))
dt.plot(ax=ax)
dtt = de.index.values
ddt = dt.values
dde = de.values
plt.fill_between(dtt, ddt - dde, ddt + dde, alpha=0.2)
ax.set_ylabel(obs)
#ax.axvspan(d_start, d_start + d - 1, alpha=0.5, color='grey')
plots.append((r, k, obs))
ax.set_xticklabels(ax.xaxis.get_majorticklabels(), rotation=45)
fig.tight_layout()
return (fig, plots)
print(data.index.levels)
In [ ]:
pylab.rcParams['figure.figsize'] = (16, 4)
r_trades = data.index.levels[0].values
fig, plots = plot('total_population', data)
fig, plots = plot('total_income_trade', data)
The plots above show the long run data (aggregated from 50 runs) for total population and total income from trade
We see:
To get some more information, a closer look at individual trajectories is required.
In [ ]:
location = '/home/jakob/Project_MayaSim/Python/output_data/X8_longterm_dynamics/results/all_trajectories'
all_data = pd.read_pickle(location)
print(all_data.columns)
In [2]:
pylab.rcParams['figure.figsize'] = (6, 12)
all_data.columns = range(0,2)
all_data.loc[6000, 1]
runs = range(0, 2)
r_trades = all_data.index.values
fig = plt.figure()
annotations=['A)', 'B)', 'C)', 'D)']
for i, r_trade in enumerate(r_trades[[0, 1, 3]]):
ax = fig.add_subplot(4, 1, i + 1)
observable = 'total_population'
for run in [0,1]:
all_data.loc[r_trade, run][observable].plot(legend=(True if i == len(r_trades) - 1 else False))
ax.set_xlim([0,2100])
ax.annotate(annotations[i], xy=(0,0), xycoords='data', xytext=(0.92, 0.1), textcoords='axes fraction', fontsize=18)
ax.set_ylabel('total population')
if i == len(r_trades)-1:
ax.set_xlabel('time in years')
leg = ax.get_legend()
for j, text in enumerate(leg.get_texts()):
text.set_text('run {}'.format(j+1))
plt.savefig('longterm_population_development.pdf')
The plots above show the total population of single two single runs for different possible trade income.
We see:
This is in accordance with findings in archeological reserach that state that there have been cycles of growth and collapse in the Maya civilisation from 2000 BC to ~ 0 BC and that only after that in the socalled Classical Period a signifficant overshoot and collapse without recovery was observed.
In our model, this can be reproduced via an increase in trade efficiency, that leads to qualitatively different model behavior.
In [86]:
pylab.rcParams['figure.figsize'] = (6, 12)
all_data.columns = range(0,2)
all_data.loc[6000, 1]
runs = range(0, 2)
r_trades = all_data.index.values
fig = plt.figure()
annotations=['A)', 'B)', 'C)']
colors = ['#336600', '#66FF33', '#FF9900', 'black']
for i, r_trade in enumerate(r_trades[[0,1,3]]):
ax = fig.add_subplot(3, 1, i + 1)
observables = ['forest_state_3_cells', 'forest_state_2_cells', 'forest_state_1_cells', 'total_agriculture_cells']
forest_data = all_data.loc[r_trade, run][observables]
forest_data['forest_state_1_cells'] = forest_data['forest_state_1_cells'].sub(forest_data['total_agriculture_cells'])
forest_data.columns = ['climax forest', 'secondary regrowth', 'cleared land', 'agriculture cells']
run = 1
ln1 = forest_data.plot.area(stacked=True,
legend=(True if i == len(r_trades) - 2 else False),
ax=ax,
color=colors)
ax2 = ax.twinx()
ln2 = all_data.loc[r_trade, run]['total_population'].plot(legend=(True if i == len(r_trades) - 2 else False),
ax=ax2,
color='k')
#print(all_data.loc[r_trade, run][observables])
ax.set_xlim([0,1000])
ax.annotate(annotations[i], xy=(0,0), xycoords='data', xytext=(0.9, 0.9), textcoords='axes fraction', fontsize=18)
ax2.set_ylabel('total population')
ax.set_ylabel('forest state')
ax.set_ylim([0, 101000])
if i == len(r_trades)-2:
ax.set_xlabel('time in years')
lgd2 = ax.legend(loc=1, bbox_to_anchor=[1, .4])
lgd1 = ax2.legend(loc=1, bbox_to_anchor=[1., .55])
#fig.tight_layout()
fig.savefig('longterm_population_development.pdf', transparent=True, dpi=200)
In [ ]: