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

Dac tutorial message models #807

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 13 additions & 9 deletions message_ix/util/tutorial.py
Expand Up @@ -3,17 +3,19 @@
from functools import partial

from message_ix import Scenario
from message_ix.report import Key, Reporter, operator
from message_ix.report import Key, Reporter, computations
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI I took this from @ywpratama's active PR. Were there recent changes to the core Reporter api? (including file name changes?)

I would not expect all of the change lines here based on what is in https://github.com/iiasa/message_ix/pull/806/files#diff-c26536ce84986d4689980ad63dd90f92b8012bdfcb3bd55ed3df380f71d0c56a

I'll note also this tutorial ran for me locally, so I'm confused if message_ix.report not longer has a computations. FYI @glatterf42

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, there were changes in v3.8.0 to this exact module. See our release notes. You should be using from message_ix.report import operator now instead of ... computations.


log = logging.getLogger(__name__)

PLOTS = [
("activity", operator.stacked_bar, "out:nl-t-ya", "GWa"),
("capacity", operator.stacked_bar, "CAP:nl-t-ya", "GW"),
("demand", operator.stacked_bar, "demand:n-c-y", "GWa"),
("extraction", operator.stacked_bar, "EXT:n-c-g-y", "GW"),
("new capacity", operator.stacked_bar, "CAP_NEW:nl-t-yv", "GWa"),
("prices", operator.stacked_bar, "PRICE_COMMODITY:n-c-y", "¢/kW·h"),
("activity", computations.stacked_bar, "out:nl-t-ya", "GWa"),
("capacity", computations.stacked_bar, "CAP:nl-t-ya", "GW"),
("removal capacity", computations.stacked_bar, "CAP:nl-t-ya", "tCO2/yr"),
("demand", computations.stacked_bar, "demand:n-c-y", "GWa"),
("emission", computations.stacked_bar, "emi:nl-t-ya", "tCO2"),
("extraction", computations.stacked_bar, "EXT:n-c-g-y", "GW"),
("new capacity", computations.stacked_bar, "CAP_NEW:nl-t-yv", "GWa"),
("prices", computations.stacked_bar, "PRICE_COMMODITY:n-c-y", "¢/kW·h"),
]


Expand All @@ -27,6 +29,8 @@ def prepare_plots(rep: Reporter, input_costs="$/GWa") -> None:
- ``plot extraction``
- ``plot fossil supply curve``
- ``plot capacity``
- ``plot removal capacity``
- ``plot emission``
- ``plot new capacity``
- ``plot prices``

Expand All @@ -47,7 +51,7 @@ def prepare_plots(rep: Reporter, input_costs="$/GWa") -> None:
# Add one node to the reporter for each plot
for title, func, key_str, units in PLOTS:
# Convert the string to a Key object so as to reference its .dims
key = Key(key_str)
key = Key.from_str_or_key(key_str)

# Operation for the reporter
comp = partial(
Expand All @@ -68,7 +72,7 @@ def prepare_plots(rep: Reporter, input_costs="$/GWa") -> None:
"plot fossil supply curve",
(
partial(
operator.plot_cumulative,
computations.plot_cumulative,
labels=("Fossil supply", "Resource volume", "Cost"),
),
"resource_volume:n-g",
Expand Down
3 changes: 3 additions & 0 deletions tutorial/README.rst
Expand Up @@ -158,6 +158,9 @@ framework, such as used in global research applications of |MESSAGEix|.
#. Modeling of a multi-node energy system and representing trade between nodes
(:tut:`westeros/westeros_multinode_energy_trade.ipynb`).

#. Including carbon removal technologies
(:tut:`westeros/westeros_carbon_removal.ipynb`).

#. Use other features of :mod:`message_ix` and :mod:`ixmp`:

#. ⭐ After the MESSAGE model has solved, use the :mod:`.message_ix.report`
Expand Down
98 changes: 98 additions & 0 deletions tutorial/westeros/data/westeros_carbon_removal_data.yaml
@@ -0,0 +1,98 @@
daccs:
year_init: 700
inv_cost_:
par_name: inv_cost
value: 100
unit: USD/(tCO2/yr)
node_loc:
Westeros: 1
year_vtg:
rate: 0
fix_cost_:
par_name: fix_cost
value: 5
unit: USD/(tCO2/yr)/yr
node_loc:
Westeros: 1
year_vtg:
rate: 0
year_act:
rate: 0
var_cost_:
par_name: var_cost
value: 5
unit: USD/tCO2
node_loc:
Westeros: 1
year_vtg:
rate: 0
year_act:
rate: 0
input_:
par_name: input
value: 0.0028
unit: '-'
node_loc:
Westeros: 1
mode:
standard: 1
commodity:
electricity: 1
level:
final: 1
output_:
par_name: output
value: 1
unit: tCO2
node_loc:
Westeros: 1
mode:
standard: 1
commodity:
CO2: 1
level:
final: 1
capacity_factor_:
par_name: capacity_factor
value: 0.913
unit: '-'
node_loc:
Westeros: 1
emission_factor_:
par_name: emission_factor
value: -1
unit: tCO2/tCO2
node_loc:
Westeros: 1
mode:
standard: 1
emission:
CO2: 1
technical_lifetime_:
par_name: technical_lifetime
value: 25
unit: y
node_loc:
Westeros: 1
initial_new_capacity_up_:
par_name: initial_new_capacity_up
value: 0.5
unit: Mt CO2/yr
node_loc:
Westeros: 1
year_vtg:
rate: 0
time:
year: 1
growth_new_capacity_up_:
par_name: growth_new_capacity_up
value: 0.05
unit: '-'
node_loc:
Westeros: 1
year_vtg:
rate: 0
time:
year: 1


401 changes: 401 additions & 0 deletions tutorial/westeros/westeros_carbon_removal.ipynb

Large diffs are not rendered by default.