Skip to content

Commit

Permalink
Use corrected chapter-2 data file
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhuppmann committed May 27, 2024
1 parent e89b99a commit 673c0cf
Showing 1 changed file with 59 additions and 51 deletions.
110 changes: 59 additions & 51 deletions data/chapter-2-compilation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
"outputs": [],
"source": [
"data = (\n",
" pd.read_excel(\"source/2_Research_Development/chapter-2_grants_formatted+funding.xlsx\")\n",
" pd.read_excel(\"source/2_Research_Development/chapter-2_grants_formatted+funding_corrected.xlsx\")\n",
" .drop(columns=\"description\")\n",
")\n",
"\n",
Expand Down Expand Up @@ -184,6 +184,7 @@
" .replace(\"Restoration of landscapes/peats\", \"Restoration of Landscapes and Peats\")\n",
" .replace(\"Enhanced Weathering (land based)\", \"Enhanced Weathering\")\n",
" .replace(\" Literature on CDR/NET\", \"\")\n",
" .replace(\"General CDR\", \"General\")\n",
" )) for i in df.variable]\n",
")\n",
"df.rename(variable=mapping, inplace=True)"
Expand Down Expand Up @@ -226,18 +227,6 @@
"dsd.validate(df)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7a03995d-3be8-49b0-a13b-ac23be2548b2",
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"df.filter(variable=\"*Share*\").timeseries()"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -272,157 +261,176 @@
{
"cell_type": "code",
"execution_count": null,
"id": "caf7bac6-d550-4edc-a616-0a5b0b10c906",
"id": "b47415a0-436d-4e6e-bed3-c2616c6cbcb0",
"metadata": {},
"outputs": [],
"source": [
"df.filter(variable=\"*Mitigation*\").variable"
"df_active_share = df.filter(variable=\"*Active Grants*\", region=\"World\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "db44f9db-4490-403f-8e81-fc291cad7f09",
"metadata": {
"scrolled": true
},
"id": "699d1114-3641-4315-acc1-5d908ec55322",
"metadata": {},
"outputs": [],
"source": [
"[v for v in dsd.variable if v not in df.variable and v.startswith(\"Research\")]"
"df_active_share.rename(variable={\"Research|Removal|Active Grants\": \"foo\"}, inplace=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3fbb3c39-7ebb-4c6f-9095-4c6c51a0d728",
"id": "ca697219-aa15-41c8-addd-2dbef925f2d4",
"metadata": {},
"outputs": [],
"source": [
"data = run.iamc.tabulate()"
"df_active_share.aggregate(\"Research|Removal|Active Grants\", append=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "469b9497-9471-4e84-9e77-66f9776ede7e",
"id": "52b963a2-1048-430b-88ee-e461d32a2ea1",
"metadata": {},
"outputs": [],
"source": [
"run.iamc.remove(data)"
"df_list = []\n",
"\n",
"for v in df_active_share.filter(variable=\"Research|Removal|Active Grants|*\").variable:\n",
" _df = df_active_share.divide(v, \"Research|Removal|Active Grants\", f\"{v} [Share]\", ignore_units=\"%\")\n",
" _df._data = _df._data * 100\n",
" df_list.append(_df)\n",
"\n",
"df.append(pyam.concat(df_list), inplace=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "773415b5-28d7-498f-ba97-5b00ad4fedc8",
"id": "ab5edc5d-201d-4d17-933a-35bae72e8d68",
"metadata": {},
"outputs": [],
"source": [
"run.iamc.add(df.data)"
]
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "3710eead-93ef-4f9c-8d52-93924811d02c",
"id": "10463567-fa04-4de9-914f-3197261eca30",
"metadata": {},
"outputs": [],
"source": [
"#df.to_ixmp4(\"socdr-dev\")"
"dsd.validate(df)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7e76c405-55c8-4dc1-8ee9-281c0b60e869",
"id": "3d5cb314-4532-4ec9-8f29-750f7db76956",
"metadata": {},
"outputs": [],
"source": [
"df.to_excel(\"socdr-chapter-2-data_v3.xlsx\")"
]
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "2c10303c-296c-4356-a939-8cd2be53884d",
"id": "d16ef3c7-2bd2-49a6-8dfd-fd42f4986b74",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "28762994-c02b-4611-85cc-f690a5f4cc5e",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "3710eead-93ef-4f9c-8d52-93924811d02c",
"metadata": {},
"outputs": [],
"source": [
"import ixmp4"
"#df.to_ixmp4(\"socdr-dev\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9abe322b-a5d0-4630-90ed-9bac8bb66166",
"id": "7e76c405-55c8-4dc1-8ee9-281c0b60e869",
"metadata": {},
"outputs": [],
"source": [
"platform = ixmp4.Platform(\"socdr-dev\")"
"df.to_excel(\"socdr-chapter-2-data_v4.xlsx\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d44328b7-d7c6-407a-ad7e-13a14fb4eee8",
"id": "2c10303c-296c-4356-a939-8cd2be53884d",
"metadata": {},
"outputs": [],
"source": [
"run = platform.runs.create(**iamc_args)"
"import ixmp4"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "17fc2c78-1d18-49ed-a3b0-8f1cd8720a2c",
"id": "9abe322b-a5d0-4630-90ed-9bac8bb66166",
"metadata": {},
"outputs": [],
"source": [
"run.set_as_default()"
"platform = ixmp4.Platform(\"socdr-dev\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5a0dd1b3-01c9-4710-8936-a663f1f9d04c",
"id": "d44328b7-d7c6-407a-ad7e-13a14fb4eee8",
"metadata": {},
"outputs": [],
"source": [
"run.meta[\"Chapter\"] = \"Chapter 2\""
"run = platform.runs.get(**iamc_args)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b9f25b7a-1e41-489e-9f56-d8f40bcb64f3",
"id": "469b9497-9471-4e84-9e77-66f9776ede7e",
"metadata": {},
"outputs": [],
"source": [
"run.iamc.add(df.data)"
"run.iamc.remove(run.iamc.tabulate())"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c15d461d-2764-421d-b2ed-9116ed9ea0c6",
"id": "773415b5-28d7-498f-ba97-5b00ad4fedc8",
"metadata": {},
"outputs": [],
"source": [
"df.filter(variable=\"Research|Mitigation|*\").plot()"
"run.iamc.add(df.data)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "72b5ab4c-f245-4a8e-b96f-b7d262acfbb3",
"id": "05624fc6-d9d3-469d-9491-668369ee56b4",
"metadata": {},
"outputs": [],
"source": []
"source": [
"df.filter(variable=\"*Grants* [Share]\").plot.bar(stacked=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "90efa05d-7fea-41ce-9198-a317e236f6c7",
"id": "350464ca-fb1f-4669-bfcb-2158a7258964",
"metadata": {},
"outputs": [],
"source": []
Expand Down

0 comments on commit 673c0cf

Please sign in to comment.