|
| 1 | +"""Generate the ScenarioMIP workflow.""" |
| 2 | + |
| 3 | +import logging |
| 4 | +from typing import TYPE_CHECKING, Optional |
| 5 | + |
| 6 | +from message_ix_models.workflow import Workflow |
| 7 | + |
| 8 | +if TYPE_CHECKING: |
| 9 | + from message_ix import Scenario |
| 10 | + |
| 11 | + from message_ix_models import Context |
| 12 | + |
| 13 | +log = logging.getLogger(__name__) |
| 14 | + |
| 15 | + |
| 16 | +def step_01(context: "Context", scenario: "Scenario") -> "Scenario": |
| 17 | + """Clean Timeseries.""" |
| 18 | + log.info("Not implemented: step_01(…)") |
| 19 | + return scenario |
| 20 | + |
| 21 | + |
| 22 | +def step_02(context: "Context", scenario: "Scenario") -> "Scenario": |
| 23 | + """Add Land-use Emulator.""" |
| 24 | + log.info("Not implemented: step_02(…)") |
| 25 | + return scenario |
| 26 | + |
| 27 | + |
| 28 | +def step_03(context: "Context", scenario: "Scenario") -> "Scenario": |
| 29 | + """Add Biomass Trade.""" |
| 30 | + log.info("Not implemented: step_03(…)") |
| 31 | + return scenario |
| 32 | + |
| 33 | + |
| 34 | +def step_04(context: "Context", scenario: "Scenario") -> "Scenario": |
| 35 | + """Solve for Historic Reporting.""" |
| 36 | + log.info("Not implemented: step_04(…)") |
| 37 | + return scenario |
| 38 | + |
| 39 | + |
| 40 | +def step_05(context: "Context", scenario: "Scenario") -> "Scenario": |
| 41 | + """Build Materials.""" |
| 42 | + log.info("Not implemented: step_05(…)") |
| 43 | + return scenario |
| 44 | + |
| 45 | + |
| 46 | +def step_06(context: "Context", scenario: "Scenario") -> "Scenario": |
| 47 | + """Add DAC (Direct Air Capture).""" |
| 48 | + log.info("Not implemented: step_06(…)") |
| 49 | + return scenario |
| 50 | + |
| 51 | + |
| 52 | +def step_07(context: "Context", scenario: "Scenario") -> "Scenario": |
| 53 | + """Add Non-CO2 GHGs.""" |
| 54 | + log.info("Not implemented: step_07(…)") |
| 55 | + return scenario |
| 56 | + |
| 57 | + |
| 58 | +def step_08(context: "Context", scenario: "Scenario") -> "Scenario": |
| 59 | + """Add Water.""" |
| 60 | + log.info("Not implemented: step_08(…)") |
| 61 | + return scenario |
| 62 | + |
| 63 | + |
| 64 | +def step_09(context: "Context", scenario: "Scenario") -> "Scenario": |
| 65 | + """Add Techno-economic Parameters.""" |
| 66 | + log.info("Not implemented: step_09(…)") |
| 67 | + return scenario |
| 68 | + |
| 69 | + |
| 70 | +def step_10(context: "Context", scenario: "Scenario") -> "Scenario": |
| 71 | + """Add Balance Equalities (some petrochemical trade balances?).""" |
| 72 | + log.info("Not implemented: step_10(…)") |
| 73 | + return scenario |
| 74 | + |
| 75 | + |
| 76 | +def step_11(context: "Context", scenario: "Scenario") -> "Scenario": |
| 77 | + """OBSOLETE.""" |
| 78 | + log.info("Not implemented: step_11(…)") |
| 79 | + return scenario |
| 80 | + |
| 81 | + |
| 82 | +def step_12(context: "Context", scenario: "Scenario") -> "Scenario": |
| 83 | + """Gas Mix Limitations (constrain gas use in industries).""" |
| 84 | + log.info("Not implemented: step_12(…)") |
| 85 | + return scenario |
| 86 | + |
| 87 | + |
| 88 | +def step_13(context: "Context", scenario: "Scenario") -> "Scenario": |
| 89 | + """Add Slack and Constraints (so we need to update the slacks).""" |
| 90 | + log.info("Not implemented: step_13(…)") |
| 91 | + return scenario |
| 92 | + |
| 93 | + |
| 94 | +def step_14(context: "Context", scenario: "Scenario") -> "Scenario": |
| 95 | + """Add Shipping.""" |
| 96 | + log.info("Not implemented: step_14(…)") |
| 97 | + return scenario |
| 98 | + |
| 99 | + |
| 100 | +def step_15(context: "Context", scenario: "Scenario") -> "Scenario": |
| 101 | + log.info("Not implemented: step_15(…)") |
| 102 | + return scenario |
| 103 | + |
| 104 | + |
| 105 | +def step_16(context: "Context", scenario: "Scenario") -> "Scenario": |
| 106 | + """Calibrate Macro.""" |
| 107 | + log.info("Not implemented: step_16(…)") |
| 108 | + return scenario |
| 109 | + |
| 110 | + |
| 111 | +#: Order of steps in the workflow. |
| 112 | +STEP_ORDER = [ |
| 113 | + step_01, |
| 114 | + step_02, |
| 115 | + step_03, |
| 116 | + step_04, |
| 117 | + step_05, |
| 118 | + step_06, |
| 119 | + step_07, |
| 120 | + step_08, |
| 121 | + step_09, |
| 122 | + step_10, |
| 123 | + step_11, |
| 124 | + step_12, |
| 125 | + step_13, |
| 126 | + step_14, |
| 127 | + step_15, |
| 128 | + step_16, |
| 129 | +] |
| 130 | + |
| 131 | + |
| 132 | +def generate(context: "Context", step_order: Optional[list] = None) -> "Workflow": |
| 133 | + """Generate the ScenarioMIP workflow. |
| 134 | +
|
| 135 | + Parameters |
| 136 | + ---------- |
| 137 | + step_order |
| 138 | + Order of steps in the workflow. If not given, :data:`STEP_ORDER` is used. |
| 139 | + """ |
| 140 | + wf = Workflow(context) |
| 141 | + |
| 142 | + prev = wf.add_step("base", None) |
| 143 | + |
| 144 | + step_order = step_order or STEP_ORDER |
| 145 | + |
| 146 | + for i, func in enumerate(step_order, start=1): |
| 147 | + prev = wf.add_step(f"step_{i}", prev, func) |
| 148 | + |
| 149 | + # "all" is an alias for the last step, whatever it is |
| 150 | + wf.add("all", prev) |
| 151 | + |
| 152 | + return wf |
0 commit comments