Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make usage of vintage_and_active_years() in the tutorials consistent #900

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
9 changes: 1 addition & 8 deletions tutorial/westeros/westeros_firm_capacity.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@
"metadata": {},
"outputs": [],
"source": [
"year_df = scen.vintage_and_active_years()\n",
"vintage_years, act_years = year_df[\"year_vtg\"], year_df[\"year_act\"]\n",
"model_horizon = scen.set(\"year\")\n",
"country = \"Westeros\""
]
Expand Down Expand Up @@ -387,7 +385,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "message_ix",
"display_name": "mix312",
"language": "python",
"name": "python3"
},
Expand All @@ -402,11 +400,6 @@
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.3"
},
"vscode": {
"interpreter": {
"hash": "29605b568787f5559ca1ba05da75d155c3dcfa15a1a63b1885b057c5465ade2e"
}
}
},
"nbformat": 4,
Expand Down
14 changes: 5 additions & 9 deletions tutorial/westeros/westeros_fossil_resource.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,12 @@
"metadata": {},
"outputs": [],
"source": [
"country = \"Westeros\"\n",
"\n",
"# Retrieving model period information\n",
"year_df = scen.vintage_and_active_years()\n",
"year_df = scen.vintage_and_active_years((country, \"coal_ppl\"), in_horizon=False)\n",
"vintage_years, act_years = year_df[\"year_vtg\"], year_df[\"year_act\"]\n",
"model_horizon = scen.set(\"year\")\n",
"country = \"Westeros\""
"model_horizon = scen.set(\"year\")"
]
},
{
Expand Down Expand Up @@ -491,7 +492,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "message_ix",
"display_name": "mix312",
"language": "python",
"name": "python3"
},
Expand All @@ -506,11 +507,6 @@
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.3"
},
"vscode": {
"interpreter": {
"hash": "29605b568787f5559ca1ba05da75d155c3dcfa15a1a63b1885b057c5465ade2e"
}
}
},
"nbformat": 4,
Expand Down
34 changes: 21 additions & 13 deletions tutorial/westeros/westeros_historical_new_capacity.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@
"outputs": [],
"source": [
"df = scenario.par(\"demand\")\n",
"df[\"value\"] = float(df[df[\"year\"] == 700][\"value\"])\n",
"df[\"value\"] = float(df.loc[df[\"year\"] == 700, \"value\"].iloc[0])\n",
"scenario.add_par(\"demand\", df)\n",
"df"
]
Expand Down Expand Up @@ -279,7 +279,7 @@
"# We will hence start by retrieving the demand in the `firstmodelyear`,\n",
"# and assume this also applies for historic time-periods.\n",
"demand_of_firstmodelyear = float(\n",
" scenario.par(\"demand\", filters={\"year\": scenario.firstmodelyear})[\"value\"]\n",
" scenario.par(\"demand\", filters={\"year\": scenario.firstmodelyear})[\"value\"].iloc[0]\n",
")\n",
"print(f\"The demand of the `firstmodelyear` is {demand_of_firstmodelyear} GWa.\")"
]
Expand All @@ -292,15 +292,15 @@
"source": [
"# We know that there are losses that occur when electricity is transmitted via the\n",
"# `grid`.\n",
"grid_eff = float(\n",
"grid_eff = 1 / float(\n",
" scenario.par(\n",
" \"output\",\n",
" \"input\",\n",
" filters={\n",
" \"year_vtg\": scenario.firstmodelyear,\n",
" \"year_act\": scenario.firstmodelyear,\n",
" \"technology\": \"grid\",\n",
" },\n",
" )[\"value\"]\n",
" )[\"value\"].iloc[0]\n",
")\n",
"print(f\"Grid efficiency is {grid_eff}.\")\n",
"demand_of_firstmodelyear /= grid_eff"
Expand All @@ -313,7 +313,7 @@
"outputs": [],
"source": [
"duration_period = float(\n",
" scenario.par(\"duration_period\", filters={\"year\": history})[\"value\"]\n",
" scenario.par(\"duration_period\", filters={\"year\": history})[\"value\"].iloc[0]\n",
")\n",
"print(f\"The duration of the period is {duration_period} years.\")\n",
"historical_new_capacity = demand_of_firstmodelyear / duration_period"
Expand All @@ -323,7 +323,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Each year within the historical 10 year period, a 11.11 GW `\"coal_ppl\"` must be added to meet the demand of the `firstmodelyear`. Therefore, the value of `\"historical_new_capacity\"` is calculated to `\"historical_new_capacity\" = demand_of_firstmodelyear / \"duration_period\"`."
"Each year within the historical 10 year period, a 6.11 GW `\"coal_ppl\"` must be added to meet the demand of the `firstmodelyear`. Therefore, the value of `\"historical_new_capacity\"` is calculated to `\"historical_new_capacity\" = demand_of_firstmodelyear / \"duration_period\"`."
]
},
{
Expand All @@ -344,7 +344,7 @@
")\n",
"print(\n",
" \"The `'historical_new_capacity'` for `coal_ppl` is set to \"\n",
" f\"{round(historical_new_capacity, 2)}\"\n",
" f\"{round(historical_new_capacity, 2)} {df[\"unit\"].values}.\"\n",
")\n",
"scenario.add_par(\"historical_new_capacity\", df)"
]
Expand Down Expand Up @@ -844,12 +844,16 @@
"\n",
"# Retrieve `\"historical_new_capacity\"`\n",
"value = float(\n",
" scenario2.par(\"historical_new_capacity\", filters={\"technology\": \"coal_ppl\"}).value\n",
" scenario2.par(\n",
" \"historical_new_capacity\", filters={\"technology\": \"coal_ppl\"}\n",
" ).value.iloc[0]\n",
")\n",
"\n",
"# Retrieve `\"duration_period\"` for the year 700\n",
"duration_period = float(\n",
" scenario.par(\"duration_period\", filters={\"year\": scenario.firstmodelyear})[\"value\"]\n",
" scenario.par(\"duration_period\", filters={\"year\": scenario.firstmodelyear})[\n",
" \"value\"\n",
" ].iloc[0]\n",
")\n",
"\n",
"value *= duration_period\n",
Expand Down Expand Up @@ -976,12 +980,16 @@
"source": [
"# Retrieve `historical_new_capacity`\n",
"value = float(\n",
" scenario2.par(\"historical_new_capacity\", filters={\"technology\": \"coal_ppl\"}).value\n",
" scenario2.par(\n",
" \"historical_new_capacity\", filters={\"technology\": \"coal_ppl\"}\n",
" ).value.iloc[0]\n",
")\n",
"\n",
"# Retrieve `duration_period` for the year 700\n",
"duration_period = float(\n",
" scenario.par(\"duration_period\", filters={\"year\": scenario.firstmodelyear})[\"value\"]\n",
" scenario.par(\"duration_period\", filters={\"year\": scenario.firstmodelyear})[\n",
" \"value\"\n",
" ].iloc[0]\n",
")\n",
"\n",
"value *= duration_period\n",
Expand Down Expand Up @@ -1106,7 +1114,7 @@
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "mix312",
"language": "python",
"name": "python3"
},
Expand Down
13 changes: 4 additions & 9 deletions tutorial/westeros/westeros_renewable_resource.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@
"metadata": {},
"outputs": [],
"source": [
"year_df = scen.vintage_and_active_years()\n",
"country = \"Westeros\"\n",
"year_df = scen.vintage_and_active_years((country, \"wind_ppl\"), in_horizon=False)\n",
"vintage_years, act_years = year_df[\"year_vtg\"], year_df[\"year_act\"]\n",
"model_horizon = scen.set(\"year\")\n",
"country = \"Westeros\""
"model_horizon = scen.set(\"year\")"
]
},
{
Expand Down Expand Up @@ -517,7 +517,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "message_ix",
"display_name": "mix312",
"language": "python",
"name": "python3"
},
Expand All @@ -532,11 +532,6 @@
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.3"
},
"vscode": {
"interpreter": {
"hash": "29605b568787f5559ca1ba05da75d155c3dcfa15a1a63b1885b057c5465ade2e"
}
}
},
"nbformat": 4,
Expand Down
5 changes: 1 addition & 4 deletions tutorial/westeros/westeros_share_constraint.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@
"metadata": {},
"outputs": [],
"source": [
"year_df = scen.vintage_and_active_years()\n",
"vintage_years, act_years = year_df[\"year_vtg\"], year_df[\"year_act\"]\n",
"model_horizon = scen.set(\"year\")\n",
"country = \"Westeros\""
]
},
Expand Down Expand Up @@ -472,7 +469,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "mix312",
"language": "python",
"name": "python3"
},
Expand Down
Loading