Skip to content

Commit

Permalink
science: Update initial CO2 concentrations
Browse files Browse the repository at this point in the history
  • Loading branch information
davidanthoff committed Feb 24, 2014
1 parent 878ca65 commit 610d1dd
Show file tree
Hide file tree
Showing 8 changed files with 219 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Fund/Data/Base/cbox10.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# FUND scenario
283.53
296.002949511
2 changes: 1 addition & 1 deletion Fund/Data/Base/cbox20.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# FUND scenario
5.62
5.52417779186
2 changes: 1 addition & 1 deletion Fund/Data/Base/cbox30.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# FUND scenario
6.29
6.65150094285
2 changes: 1 addition & 1 deletion Fund/Data/Base/cbox40.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# FUND scenario
2.19
2.39635475726
2 changes: 1 addition & 1 deletion Fund/Data/Base/cbox50.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# FUND scenario
0.15
0.17501699667
Binary file added calibration/co2cycle/RCP85_EMISSIONS.xls
Binary file not shown.
Binary file not shown.
214 changes: 214 additions & 0 deletions calibration/co2cycle/fund_co2_cycle.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "code",
"collapsed": false,
"input": [
"import pandas"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 1
},
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
"FUND carbon cycle"
]
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"I. Introduction"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This file calibrates the initial values for the five boxes of the carbon cycle component. The FUND carbon cycle is run with historical emissions from the RCP data set up to 1950 to compute the CO2 content of each of the five boxes in 1950. An additional calibration factor is computed to force the 1950 concentrations to match observed concentrations in that year."
]
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"II. Data sources"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Data obtained from http://www.pik-potsdam.de/~mmalte/rcps/ on 11/15/2013 by Anthoff."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"rcp_emissions = pandas.read_excel('RCP85_EMISSIONS.xls', 'RCP85_EMISSIONS', skiprows=37, index_col=0)\n",
"rcp_emissions.index.name='year'"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 2
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"rcp_concentrations = pandas.read_excel('RCP85_MIDYEAR_CONCENTRATIONS.xls', 'RCP85_MIDYEAR_CONCENTRATIONS', skiprows=38, index_col=0)\n",
"rcp_concentrations.index.name='year'"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 3
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"III. Computation"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Run the FUND carbon cycle with RCP historical emissions data."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# Convert to FUND units\n",
"emissions = rcp_emissions['FossilCO2'].values * 1000.0\n",
"\n",
"# Parameters\n",
"co2decay = numpy.array([1.0, exp(-1.0/363.0), exp(-1.0/74.0),exp(-1.0/17.0),exp(-1.0/2.0)])\n",
"co2frac = numpy.array([0.13,0.2,0.32,0.25,0.1])\n",
"\n",
"# State variables\n",
"cbox = numpy.zeros((len(emissions),5))\n",
"acco2 = numpy.zeros(len(emissions))\n",
"\n",
"# Initial values\n",
"cbox[0,0]=rcp_concentrations['CO2'][0]\n",
"acco2[0] = cbox[0,:].sum()\n",
"\n",
"# Transition function\n",
"for t in range(0,len(emissions)-1):\n",
" cbox[t+1,:] = cbox[t,:] * co2decay[:] + 0.000471 * co2frac[:] * emissions[t]\n",
" acco2[t+1] = cbox[t+1,:].sum()\n",
" \n",
"fund_concentrations = pandas.DataFrame(acco2,index=rcp_emissions.index)\n",
"fund_boxes = pandas.DataFrame(cbox,index=rcp_emissions.index)"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 4
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Compute a calibration factor that forces CO2 concentrations as computed by the FUND component to match observed concentrations in 1950."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"calibration_factor = rcp_concentrations['CO2'].loc[1950]/fund_concentrations.loc[1950][0]"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 5
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Display initial CO2 concentrations per box in 1950 for FUND with the calibration factor applied. Those are the initial values used in FUND."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"numpy.round(fund_boxes.loc[1950]*calibration_factor,2)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 6,
"text": [
"0 296.00\n",
"1 5.52\n",
"2 6.65\n",
"3 2.40\n",
"4 0.18\n",
"Name: 1950.0, dtype: float64"
]
}
],
"prompt_number": 6
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"IV. Output"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Write the input files for the model."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"for i in range(5):\n",
" with open('../../Fund/Data/Base/cbox%s0.csv'%(i+1),'w') as f:\n",
" f.write('# FUND scenario\\n')\n",
" f.write(str(fund_boxes.loc[1950][i]*calibration_factor))\n",
" f.write('\\n')"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 7
}
],
"metadata": {}
}
]
}

0 comments on commit 610d1dd

Please sign in to comment.