In [ ]:
%pwd
In [ ]:
%cd /Users/brianbeckage/Documents/PROJECTS/Sesync/CLIMATE_CHANGE_MODEL
In [ ]:
%cd
Another way of changing working directory
In [ ]:
import os
os.chdir('/Users/brianbeckage/Documents/PROJECTS/Sesync/CLIMATE_CHANGE_MODEL')
Loading required libraries
In [1]:
%matplotlib inline
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
In [3]:
import SoCCo as sc
from SoCCo import api
In [4]:
sc.__file__
sc.__version__
Out[4]:
Setting initial conditions
In [6]:
nGroups=12
co2_ts=np.linspace(298, 299, 3)
popTotal=7130010000 # Wolfram: QuantityMagnitude[CountryData["World", "Population"]]
popN=sc.api.popIntoNgroups(popTotal,nGroups=nGroups)
pcE_ts=sc.api.randomNormalF(5.049, 0.5, nGroups)
pcE_ts=np.atleast_2d(pcE_ts).transpose()
tData_ts=np.array([0,0.1,0.2,0.1]) # temperature
eff=sc.api.efficacyF(nGroups)
pbc=sc.api.perceivedBehavioralControlF(nGroups)
percepWindowSize=3
riskSens=1000.0
In [7]:
sc.algorithms.social.popIntoNgroups(popTotal, nGroups=nGroups)
Out[7]:
In [8]:
sc.api.popIntoNgroups(popTotal,nGroups=nGroups)
Out[8]:
In [9]:
pcE_ts,tData_ts, co2_ts=sc.api.iterateNsteps(pcE_ts,tData_ts, co2_ts, 5, eff, pbc,popN,percepWindowSize,riskSens)
In [10]:
pcE_ts,tData_ts, co2_ts=api.iterateNsteps(pcE_ts,tData_ts, co2_ts, 100, eff, pbc,popN,percepWindowSize,riskSens)
In [11]:
pcE_ts,tData_ts, co2_ts=sc.algorithms.iter.iterateNsteps(pcE_ts,tData_ts, co2_ts, 100, eff, pbc,popN,percepWindowSize,riskSens)
In [12]:
pcE_tsT=pcE_ts.transpose()
In [13]:
pcE_tsT;
In [14]:
len(pcE_ts)
Out[14]:
In [15]:
tData_ts
Out[15]:
In [16]:
co2_ts
Out[16]:
In [17]:
plt.plot(tData_ts)
plt.xlabel('Year')
plt.ylabel('T')
Out[17]:
In [18]:
plt.plot(co2_ts)
plt.xlabel('Year')
plt.ylabel('ppm')
Out[18]:
In [19]:
plt.plot(pcE_ts.transpose())
plt.xlabel('Year')
plt.ylabel('ppm')
Out[19]:
In [20]:
plt.plot(pcE_ts)
plt.xlabel('Group')
plt.ylabel('ppm')
plt.legend(np.arange(5).astype('str'))
Out[20]:
In [21]:
pcE_ts.shape
Out[21]:
In [23]:
np.arange(5).astype('str')
Out[23]: