From 5fba797d9c9c2478c0abec27d1ee205feb362746 Mon Sep 17 00:00:00 2001 From: Daniel Olsen Date: Fri, 9 Oct 2020 14:24:53 -0700 Subject: [PATCH] feat: add inflation calculator function --- powersimdata/design/investment/__init__.py | 2 +- powersimdata/design/investment/inflation.py | 24 +++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 powersimdata/design/investment/inflation.py diff --git a/powersimdata/design/investment/__init__.py b/powersimdata/design/investment/__init__.py index 4590d82cc..68de68755 100644 --- a/powersimdata/design/investment/__init__.py +++ b/powersimdata/design/investment/__init__.py @@ -1 +1 @@ -__all__ = ["const", "create_mapping_files", "investment_costs"] +__all__ = ["const", "create_mapping_files", "inflation", "investment_costs"] diff --git a/powersimdata/design/investment/inflation.py b/powersimdata/design/investment/inflation.py new file mode 100644 index 000000000..52f1780ff --- /dev/null +++ b/powersimdata/design/investment/inflation.py @@ -0,0 +1,24 @@ +inflation_rate_pct = { + 2010: 1.5, + 2011: 3.0, + 2012: 1.7, + 2013: 1.5, + 2014: 0.8, + 2015: 0.7, + 2016: 2.1, + 2017: 2.1, + 2018: 1.9, + 2019: 2.3, + 2020: 1.3, +} + + +def calculate_inflation(start_year, end_year): + if start_year not in inflation_rate_pct: + raise ValueError + if (end_year - 1) not in inflation_rate_pct: + raise ValueError + factor = 1 + for i in range(start_year, end_year): + factor *= 1 + (inflation_rate_pct[i] / 100) + return factor