DiscRates class

Discount rates are used to calculate the net present value of any future or past value. They are thus used to compare amounts paid (costs) and received (benefits) in different years. A project is economically viable (attractive), if the net present value of benefits exceeds the net present value of costs - a const-benefit ratio < 1.

There are several important implications that come along with discount rates. Namely, that higher discount rates lead to smaller net present values of future impacts (costs). As a consequence of that, climate action and mitigation measures can be postboned. In the literature higher discount rates are typically justified by the expectation of continued exponential growth of the economy. The most widley used interest rate in climate change economics is 1.4% as propsed by the Stern Review (2006). Neoliberal economists around Nordhaus (2007) claim that rates should be higher, around 4.3%. Environmental economists argue that future costs shouldn’t be discounted at all. This is especially true for non-monetary variables such as ecosystems or human lifes, where no price tag should be applied out of ethical reasons. This discussion has a long history, reaching back to the 18th century: “Some things have a price, or relative worth, while other things have a dignity, or inner worth” (Kant, 1785).

This class contains the discount rates for every year and discounts given values. Its attributes are:

  • tag (Tag): information about the source data

  • years (np.array): years

  • rates (np.array): discount rates for each year (between 0 and 1)

[2]:
from climada.entity import DiscRates
help(DiscRates)
2020-10-19 09:43:26,307 - climada - DEBUG - Loading default config file: /Users/sam/Documents/Python/climada_python/climada/conf/defaults.conf
Help on class DiscRates in module climada.entity.disc_rates.base:

class DiscRates(builtins.object)
 |  Defines discount rates and basic methods. Loads from
 |  files with format defined in FILE_EXT.
 |
 |  Attributes:
 |      tag (Tag): information about the source data
 |      years (np.array): years
 |      rates (np.array): discount rates for each year (between 0 and 1)
 |
 |  Methods defined here:
 |
 |  __init__(self)
 |      Empty initialization.
 |
 |      Examples:
 |          Fill discount rates with values and check consistency data:
 |
 |          >>> disc_rates = DiscRates()
 |          >>> disc_rates.years = np.array([2000, 2001])
 |          >>> disc_rates.rates = np.array([0.02, 0.02])
 |          >>> disc_rates.check()
 |
 |          Read discount rates from year_2050.mat and checks consistency data.
 |
 |          >>> disc_rates = DiscRates(ENT_TEMPLATE_XLS)
 |
 |  append(self, disc_rates)
 |      Check and append discount rates to current DiscRates. Overwrite
 |      discount rate if same year.
 |
 |      Parameters:
 |          disc_rates (DiscRates): DiscRates instance to append
 |
 |      Raises:
 |          ValueError
 |
 |  check(self)
 |      Check attributes consistency.
 |
 |      Raises:
 |          ValueError
 |
 |  clear(self)
 |      Reinitialize attributes.
 |
 |  net_present_value(self, ini_year, end_year, val_years)
 |      Compute net present value between present year and future year.
 |
 |      Parameters:
 |          ini_year (float): initial year
 |          end_year (float): end year
 |          val_years (np.array): cash flow at each year btw ini_year and
 |              end_year (both included)
 |      Returns:
 |          float
 |
 |  plot(self, axis=None, **kwargs)
 |      Plot discount rates per year.
 |
 |      Parameters:
 |          axis (matplotlib.axes._subplots.AxesSubplot, optional): axis to use
 |          kwargs (optional): arguments for plot matplotlib function, e.g. marker='x'
 |
 |      Returns:
 |          matplotlib.axes._subplots.AxesSubplot
 |
 |  read_excel(self, file_name, description='', var_names={'sheet_name': 'discount', 'col_name': {'year': 'year', 'disc': 'discount_rate'}})
 |      Read excel file following template and store variables.
 |
 |      Parameters:
 |          file_name (str): absolute file name
 |          description (str, optional): description of the data
 |          var_names (dict, optional): name of the variables in the file
 |
 |  read_mat(self, file_name, description='', var_names={'sup_field_name': 'entity', 'field_name': 'discount', 'var_name': {'year': 'year', 'disc': 'discount_rate'}})
 |      Read MATLAB file generated with previous MATLAB CLIMADA version.
 |
 |      Parameters:
 |          file_name (str): absolute file name
 |          description (str, optional): description of the data
 |          var_names (dict, optional): name of the variables in the file
 |
 |  select(self, year_range)
 |      Select discount rates in given years.
 |
 |      Parameters:
 |          year_range (np.array): continuous sequence of selected years.
 |
 |      Returns:
 |          DiscRates
 |
 |  write_excel(self, file_name, var_names={'sheet_name': 'discount', 'col_name': {'year': 'year', 'disc': 'discount_rate'}})
 |      Write excel file following template.
 |
 |      Parameters:
 |          file_name (str): absolute file name to write
 |          var_names (dict, optional): name of the variables in the file
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  __dict__
 |      dictionary for instance variables (if defined)
 |
 |  __weakref__
 |      list of weak references to the object (if defined)

An example of use - we define discount rates and apply them on a coastal protection scheme which initially costs 100 mn. USD plus 75’000 USD maintance each year, starting after 10 years. Net present value of the project can be calculated as displayed:

[8]:
%matplotlib inline
import numpy as np
from climada.entity import DiscRates

# define discount rates
disc = DiscRates()
disc.years = np.arange(1950, 2100)
disc.rates = np.ones(disc.years.size) * 0.014
disc.rates[51:55] = 0.025
disc.rates[95:120] = 0.035
disc.check()
disc.plot()

# Compute net present value between present year and future year.
ini_year = 2019
end_year = 2050
val_years = np.zeros(end_year-ini_year+1)
val_years[0] = 100000000 # initial investment
val_years[10:] = 75000 # maintenance from 10th year
npv = disc.net_present_value(ini_year, end_year, val_years)
print('net present value: {:.5e}'.format(npv))
net present value: 1.01231e+08
../_images/tutorial_climada_entity_DiscRates_3_1.png

## Read discount rates of an Excel file

Discount rates defined in an excel file following the template provided in sheet discount of climada_python/data/system/entity_template.xlsx can be ingested directly using the method read_excel().

[4]:
from climada.entity import DiscRates
from climada.util import ENT_TEMPLATE_XLS

# Fill DataFrame from Excel file
file_name = ENT_TEMPLATE_XLS # provide absolute path of the excel file
disc = DiscRates()
disc.read_excel(file_name)
print('Read file:', disc.tag.file_name)
disc.plot()
Read file: /Users/sam/Documents/Python/climada_python/data/system/entity_template.xlsx
[4]:
<matplotlib.axes._subplots.AxesSubplot at 0x121bf2518>
../_images/tutorial_climada_entity_DiscRates_5_2.png

Write discount rates

Discount rates defined in an excel file following the template provided in sheet discount of climada_python/data/system/entity_template.xlsx can be ingested directly using the method read_excel().

[6]:
from climada.entity import DiscRates
from climada.util import ENT_TEMPLATE_XLS

# Fill DataFrame from Excel file
file_name = ENT_TEMPLATE_XLS # provide absolute path of the excel file
disc = DiscRates()
disc.read_excel(file_name)

# write file
disc.write_excel('results/tutorial_disc.xlsx')

Pickle can always be used as well:

[7]:
from climada.util.save import save
# this generates a results folder in the current path and stores the output there
save('tutorial_disc.p', disc)
2020-10-19 09:46:38,974 - climada.util.save - INFO - Written file /Users/sam/Documents/Python/climada_python/doc/tutorial/results/tutorial_disc.p
[ ]: