Skip to content

Commit

Permalink
No ticket: update trade operational_life to operating_life, and updat…
Browse files Browse the repository at this point in the history
…e docs (#128)

* Rename trade operational_life to operating_life for consistency

* Update technology/commodity docs to include include_in_joint_reserve_margin
  • Loading branch information
edwardxtg authored Jul 23, 2024
1 parent 656c208 commit 4bdb9e4
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 21 deletions.
5 changes: 5 additions & 0 deletions docs/commodity.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ combination of timeslices. Optional, defaults to `None`.
Boolean tag to mark commodities which are considered
as renewable for applying renewable generation targets. Optional, defaults to `None`.

`include_in_joint_reserve_margin` `({region:{year:bool}})` - OSeMOSYS
ReserveMarginTagFuel. Boolean tagging the commodities that can contribute to reaching the
indicated reserve margin. It has value True for the commodities contributing, False otherwise.
Optional, defaults to `None`.



## Examples
Expand Down
7 changes: 6 additions & 1 deletion docs/technology.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,14 @@ turn into a Mixed Integer Linear Problem. Optional, defaults to `None`.

`include_in_joint_renewable_target` `({region:{year:bool}})` - OSeMOSYS RETagTechnology.
Boolean tagging the renewable technologies that must contribute to reaching the indicated
minimum renewable production target. It has value True for thetechnologies contributing,
minimum renewable production target. It has value True for the technologies contributing,
False otherwise. Optional, defaults to `None`.

`include_in_joint_reserve_margin` `({region:{year:bool}})` - OSeMOSYS
ReserveMarginTagTechnology. Boolean tagging the technologies that can contribute to reaching the
indicated reserve margin. It has value True for the technologies contributing, False otherwise.
Optional, defaults to `None`.

`capacity_gross_max` `({region:{year:float}})` - OSeMOSYS TotalAnnualMaxCapacity.
Total maximum existing (residual plus cumulatively installed) capacity allowed for a technology
in a specified year. Optional, defaults to `None`.
Expand Down
4 changes: 2 additions & 2 deletions docs/trade.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Optional, defaults to 0.00001.
`capacity_additional_max` `({region:{region:{year:float}}})` - Maximum capacity investment of
the given trade route. Optional, defaults to `None`.

`operational_life` `({region:{region:{year:int}}})` - Integer value of operating life in years
`operating_life` `({region:{region:{year:int}}})` - Integer value of operating life in years
for the given trade route. Optional, defaults to 1.

`cost_of_capital` `({region:region})` - Cost of capital (discount rate) for investments in the
Expand Down Expand Up @@ -66,7 +66,7 @@ basic_trade = dict(
commodity="electricity",
trade_routes={"R1": {"R2": {"*": True}}},
capex={"R1": {"R2": {"*": 100}}},
operational_life={"R1": {"R2": {"*": 5}}},
operating_life={"R1": {"R2": {"*": 5}}},
trade_loss={"R1": {"R2": {"*": 0.1}}},
construct_region_pairs=True,
)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_construction/test_trade.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
commodity="electricity",
trade_routes={"R1": {"R2": {"*": True}}},
capex={"R1": {"R2": {"*": 100}}},
operational_life={"R1": {"R2": {"*": 2}}},
operating_life={"R1": {"R2": {"*": 2}}},
trade_loss={"*": {"*": {"*": 0.1}}},
residual_capacity={"R1": {"R2": {"*": 5}}},
capacity_additional_max={"R1": {"R2": {"*": 5}}},
Expand All @@ -23,7 +23,7 @@
id="electricity trade",
trade_routes={"R1": {"R2": {"*": True}}, "R2": {"R1": {"*": False}}},
capex={"R1": {"R2": {"*": 100}}},
operational_life={"R1": {"R2": {"*": 2}}},
operating_life={"R1": {"R2": {"*": 2}}},
trade_loss={"*": {"*": {"*": 0.1}}},
residual_capacity={"R1": {"R2": {"*": 5}}},
capacity_additional_max={"R1": {"R2": {"*": 5}}},
Expand Down
2 changes: 1 addition & 1 deletion tests/test_solve/test_solve.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def test_simple_trade():
commodity="electricity",
trade_routes={"R1": {"R2": {"*": True}}},
capex={"R1": {"R2": {"*": 100}}},
operational_life={"R1": {"R2": {"*": 2}}},
operating_life={"R1": {"R2": {"*": 2}}},
trade_loss={"*": {"*": {"*": 0.1}}},
residual_capacity={"R1": {"R2": {"*": 5}}},
capacity_additional_max={"R1": {"R2": {"*": 5}}},
Expand Down
5 changes: 5 additions & 0 deletions tz/osemosys/schemas/commodity.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ class Commodity(OSeMOSYSBase, OtooleCommodity):
Boolean tag to mark commodities which are considered
as renewable for applying renewable generation targets. Optional, defaults to `None`.
`include_in_joint_reserve_margin` `({region:{year:bool}})` - OSeMOSYS
ReserveMarginTagFuel. Boolean tagging the commodities that can contribute to reaching the
indicated reserve margin. It has value True for the commodities contributing, False otherwise.
Optional, defaults to `None`.
## Examples
Expand Down
18 changes: 9 additions & 9 deletions tz/osemosys/schemas/compat/trade.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class OtooleTrade(BaseModel):
"columns": ["REGION", "_REGION", "FUEL", "YEAR", "VALUE"],
},
"OperationalLifeTrade": {
"attribute": "operational_life",
"attribute": "operating_life",
"columns": ["REGION", "_REGION", "FUEL", "YEAR", "VALUE"],
},
"CapitalCostTrade": {
Expand Down Expand Up @@ -160,7 +160,7 @@ def from_otoole_csv(cls, root_dir) -> "Trade":
if "TotalAnnualMaxTradeInvestment" not in otoole_cfg.empty_dfs
else None
)
operational_life = (
operating_life = (
OSeMOSYSData.RRY.Int(
group_to_json(
g=dfs["OperationalLifeTrade"].loc[
Expand Down Expand Up @@ -198,7 +198,7 @@ def from_otoole_csv(cls, root_dir) -> "Trade":
residual_capacity=residual_capacity,
capex=capex,
capacity_additional_max=capacity_additional_max,
operational_life=operational_life,
operating_life=operating_life,
cost_of_capital=cost_of_capital,
)
)
Expand All @@ -215,7 +215,7 @@ def to_dataframes(cls, trade: List["Trade"]):
residual_capacity_dfs = []
capex_dfs = []
capacity_additional_max_dfs = []
operational_life_dfs = []
operating_life_dfs = []
cost_of_capital_dfs = []

for trade_commodity in trade:
Expand Down Expand Up @@ -262,16 +262,16 @@ def to_dataframes(cls, trade: List["Trade"]):
df["FUEL"] = trade_commodity.commodity
residual_capacity_dfs.append(df)

if trade_commodity.operational_life is not None:
df = pd.json_normalize(trade_commodity.operational_life.data).T.rename(
if trade_commodity.operating_life is not None:
df = pd.json_normalize(trade_commodity.operating_life.data).T.rename(
columns={0: "VALUE"}
)

df[["REGION", "_REGION", "YEAR"]] = pd.DataFrame(
df.index.str.split(".").to_list(), index=df.index
)
df["FUEL"] = trade_commodity.commodity
operational_life_dfs.append(df)
operating_life_dfs.append(df)

if trade_commodity.capex is not None:
df = pd.json_normalize(trade_commodity.capex.data).T.rename(columns={0: "VALUE"})
Expand Down Expand Up @@ -312,8 +312,8 @@ def to_dataframes(cls, trade: List["Trade"]):
else pd.DataFrame(columns=cls.otoole_stems["ResidualTradeCapacity"]["columns"])
)
dfs["OperationalLifeTrade"] = (
pd.concat(operational_life_dfs)
if operational_life_dfs
pd.concat(operating_life_dfs)
if operating_life_dfs
else pd.DataFrame(columns=cls.otoole_stems["OperationalLifeTrade"]["columns"])
)
dfs["CapitalCostTrade"] = (
Expand Down
7 changes: 6 additions & 1 deletion tz/osemosys/schemas/technology.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,14 @@ class Technology(OSeMOSYSBase, OtooleTechnology):
`include_in_joint_renewable_target` `({region:{year:bool}})` - OSeMOSYS RETagTechnology.
Boolean tagging the renewable technologies that must contribute to reaching the indicated
minimum renewable production target. It has value True for thetechnologies contributing,
minimum renewable production target. It has value True for the technologies contributing,
False otherwise. Optional, defaults to `None`.
`include_in_joint_reserve_margin` `({region:{year:bool}})` - OSeMOSYS
ReserveMarginTagTechnology. Boolean tagging the technologies that can contribute to reaching the
indicated reserve margin. It has value True for the technologies contributing, False otherwise.
Optional, defaults to `None`.
`capacity_gross_max` `({region:{year:float}})` - OSeMOSYS TotalAnnualMaxCapacity.
Total maximum existing (residual plus cumulatively installed) capacity allowed for a technology
in a specified year. Optional, defaults to `None`.
Expand Down
10 changes: 5 additions & 5 deletions tz/osemosys/schemas/trade.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Trade(OSeMOSYSBase, OtooleTrade):
`capacity_additional_max` `({region:{region:{year:float}}})` - Maximum capacity investment of
the given trade route. Optional, defaults to `None`.
`operational_life` `({region:{region:{year:int}}})` - Integer value of operating life in years
`operating_life` `({region:{region:{year:int}}})` - Integer value of operating life in years
for the given trade route. Optional, defaults to 1.
`cost_of_capital` `({region:region})` - Cost of capital (discount rate) for investments in the
Expand Down Expand Up @@ -76,7 +76,7 @@ class Trade(OSeMOSYSBase, OtooleTrade):
commodity="electricity",
trade_routes={"R1": {"R2": {"*": True}}},
capex={"R1": {"R2": {"*": 100}}},
operational_life={"R1": {"R2": {"*": 5}}},
operating_life={"R1": {"R2": {"*": 5}}},
trade_loss={"R1": {"R2": {"*": 0.1}}},
construct_region_pairs=True,
)
Expand All @@ -91,7 +91,7 @@ class Trade(OSeMOSYSBase, OtooleTrade):
residual_capacity: OSeMOSYSData.RRY = Field(OSeMOSYSData.RRY(defaults.trade_residual_capacity))
capex: OSeMOSYSData.RRY = Field(OSeMOSYSData.RRY(defaults.trade_capex))
capacity_additional_max: OSeMOSYSData.RRY | None = Field(default=None)
operational_life: OSeMOSYSData.RRY.Int = Field(
operating_life: OSeMOSYSData.RRY.Int = Field(
OSeMOSYSData.RRY.Int(defaults.trade_operating_life)
)
cost_of_capital: OSeMOSYSData.RR | None = Field(OSeMOSYSData.RR(defaults.discount_rate))
Expand Down Expand Up @@ -184,8 +184,8 @@ def compose(self, **sets):
if self.capacity_additional_max is not None:
self.construct_pairs(self.capacity_additional_max)

if self.operational_life is not None:
self.construct_pairs(self.operational_life)
if self.operating_life is not None:
self.construct_pairs(self.operating_life)

if self.cost_of_capital is not None:
self.construct_pairs(self.cost_of_capital)
Expand Down

0 comments on commit 4bdb9e4

Please sign in to comment.