Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
7fbfb6c
code: unit test for get_excel_sheets
finozzifa Jan 24, 2025
2ec34f1
Merge branch 'master' of https://github.com/open-energy-transition/te…
finozzifa Jan 24, 2025
8f40db1
pre-commit
finozzifa Jan 24, 2025
b2efc33
code: move sheet_names to _helpers.py
finozzifa Jan 24, 2025
9cf87d5
code: modify years_list
finozzifa Jan 24, 2025
be66811
output: cost outputs
finozzifa Jan 27, 2025
074e1e0
Merge branch 'master' of https://github.com/open-energy-transition/te…
finozzifa Jan 29, 2025
2b43e07
code: merge from master
finozzifa Jan 29, 2025
5516b47
code: new unit tests
finozzifa Jan 30, 2025
11543fe
code: revert changes to _helpers.py
finozzifa Jan 30, 2025
d339277
code:fix quick issues
finozzifa Jan 30, 2025
c31a02f
code: add logger
finozzifa Jan 31, 2025
a9aa5df
code: add docstrings
finozzifa Jan 31, 2025
f07979d
add pre-commit changes
finozzifa Jan 31, 2025
8af30ca
code: modify sheet location method
finozzifa Jan 31, 2025
d020522
code: add docstring
finozzifa Jan 31, 2025
98b92b8
code: unit test clean_up_units
finozzifa Jan 31, 2025
45e33c3
code: add docstring for get_dea_martime_data
finozzifa Feb 3, 2025
299220f
code: add unit test for set_specify_assumptions
finozzifa Feb 3, 2025
4afab7d
code: add docstring for set_specify_assumptions
finozzifa Feb 3, 2025
eb2a7ad
code: remove assert False
finozzifa Feb 3, 2025
01c398d
code: unit test for set_round_trip_efficiency
finozzifa Feb 4, 2025
a3af10d
include pre-commit
finozzifa Feb 4, 2025
8dadf6c
code: switch to numpydoc and introduce static types
finozzifa Feb 5, 2025
43f3391
code:include pre-commit
finozzifa Feb 5, 2025
c5898bf
code: numpydoc and static types for order_data
finozzifa Feb 5, 2025
6d20ebb
code:replace print with logger statements
finozzifa Feb 5, 2025
1e6e000
code: add logger
finozzifa Feb 5, 2025
04a4346
Merge branch 'master' of https://github.com/PyPSA/technology-data int…
finozzifa Feb 5, 2025
d4c7f5a
code: modify static type
finozzifa Feb 5, 2025
62f4962
docu: update numpydoc to the requested standard
finozzifa Feb 5, 2025
80e1e0d
Merge branch 'master' of https://github.com/open-energy-transition/te…
finozzifa Feb 6, 2025
1e7ec73
code: add unit test for add_description
finozzifa Feb 10, 2025
ac97bdf
modify logger msg
finozzifa Feb 10, 2025
ce3706d
code: fix logger messages
finozzifa Feb 10, 2025
f843db9
code: add unit test for convert_units
finozzifa Feb 14, 2025
58d72a6
code: add numpydoc for add_gas_storage
finozzifa Feb 14, 2025
b2fc9e9
code: new changes
finozzifa Feb 17, 2025
5a61847
Merge branch 'master' of https://github.com/PyPSA/technology-data int…
finozzifa Feb 17, 2025
6a11f07
code: add numpydoc
finozzifa Feb 17, 2025
0709e06
code: re-factor and numpydoc'
finozzifa Feb 17, 2025
12be7dc
code: add new numpydoc
finozzifa Feb 17, 2025
933ac90
code: add new numpydoc - 2
finozzifa Feb 17, 2025
6adb0bf
code: add new numpydoc - 3
finozzifa Feb 17, 2025
9b9b40e
doc: update release_notes.rst
finozzifa Feb 17, 2025
76beb53
code: remove unit test for dea_maritime
finozzifa Feb 17, 2025
c3af440
code: add numpydoc for carbon_flow
finozzifa Feb 17, 2025
6dffb71
code: pre-commit for carbon_flow
finozzifa Feb 17, 2025
9864097
code: numpydoc for add_egs_data
finozzifa Feb 17, 2025
450caec
code: add unit test for annuity
finozzifa Feb 17, 2025
3502f7a
code: merge from master
finozzifa Feb 18, 2025
044a1b7
code: update numpydoc and naming
finozzifa Feb 18, 2025
6bc4579
code: add numpydoc to compile_cost_assumptions_usa.py
finozzifa Feb 19, 2025
189f4e5
code: replace list_of_years to years
finozzifa Feb 19, 2025
b3fc382
code: numpydoc for final batch of functions
finozzifa Feb 19, 2025
6893e65
code: replace NoneType with empty DataFrame
finozzifa Feb 19, 2025
38d6be2
code: pre-commit run all
finozzifa Feb 19, 2025
6ffd02b
code: new changes
finozzifa Feb 19, 2025
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
3 changes: 3 additions & 0 deletions docs/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ Upcoming Release
.. The features listed below are not released yet, but will be part of the next release!
.. To use the features already you have to use the ``master`` branch.

* Include unit test for compile_cost_assumptions_usa.py (https://github.com/PyPSA/technology-data/pull/170)

* US specific folder for NREL/ATB data (https://github.com/PyPSA/technology-data/pull/172)

* Include unit test execution and compile_cost_assumptions_usa.py in ci.yaml (https://github.com/PyPSA/technology-data/pull/174)

* Align `snakemake` version and the related `mock_snakemake` to PyPSA-Eur (https://github.com/PyPSA/technology-data/pull/177)

`v0.11.0 <https://github.com/PyPSA/technology-data/releases/tag/v0.11.0>`__ (24th January 2025)
Expand Down
63 changes: 45 additions & 18 deletions scripts/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,39 +187,66 @@ def make_accessable(*ios):
return snakemake


def adjust_for_inflation(inflation_rate, costs, techs, eur_year, col):
def adjust_for_inflation(
inflation_rate: pd.DataFrame,
costs: pd.DataFrame,
techs: pd.Series,
eur_year: int,
col_name: str,
usa_costs_flag: bool = False,
) -> pd.DataFrame:
"""
Adjust the investment costs for the specified techs for inflation.
The function adjust the investment costs for the specified techs for inflation.

techs: str or list
One or more techs in costs index for which the inflation adjustment is done.
eur_year: int
Reference year for which the costs are provided and based on which the inflation adjustment is done.
costs: Dataframe containing the costs data with multiindex on technology and one index key 'investment'.
Parameters
----------
inflation_rate : pd.DataFrame
inflation rates for several years
costs : pd.DataFrame
existing cost dataframe
techs : pd.Series
technologies
eur_year : int,
reference year for which the costs are provided and based on which the inflation adjustment is done
col_name : str
column name to which to apply the inflation rate adjustment
usa_costs_flag: bool
flag for US specific costs

Returns
-------
Dataframe
inflation updated cost dataframe
"""

def get_factor(inflation_rate, ref_year, eur_year):
def get_factor(inflation_rate_df, ref_year, eur_year_val):
if (pd.isna(ref_year)) or (ref_year < 1900):
return np.nan
if ref_year == eur_year:
if ref_year == eur_year_val:
return 1
mean = inflation_rate.mean()
if ref_year < eur_year:
new_index = np.arange(ref_year + 1, eur_year + 1)
df = 1 + inflation_rate.reindex(new_index).fillna(mean)
return df.cumprod().loc[eur_year]
mean = inflation_rate_df.mean()
if ref_year < eur_year_val:
new_index = np.arange(ref_year + 1, eur_year_val + 1)
df = 1 + inflation_rate_df.reindex(new_index).fillna(mean)
return df.cumprod().loc[eur_year_val]
else:
new_index = np.arange(eur_year + 1, ref_year + 1)
df = 1 + inflation_rate.reindex(new_index).fillna(mean)
new_index = np.arange(eur_year_val + 1, ref_year + 1)
df = 1 + inflation_rate_df.reindex(new_index).fillna(mean)
return 1 / df.cumprod().loc[ref_year]

inflation = costs.currency_year.apply(
lambda x: get_factor(inflation_rate, x, eur_year)
)

paras = ["investment", "VOM", "fuel"]
filter_i = costs.technology.isin(techs) & costs.parameter.isin(paras)
costs.loc[filter_i, col] = costs.loc[filter_i, col].mul(

if usa_costs_flag:
filter_i = costs.technology.isin(techs) & costs.parameter.isin(paras)
else:
filter_i = costs.index.get_level_values(0).isin(
techs
) & costs.index.get_level_values(1).isin(paras)
costs.loc[filter_i, col_name] = costs.loc[filter_i, col_name].mul(
inflation.loc[filter_i], axis=0
)

Expand Down
Loading