climada.entity.disc_rates package¶
climada.entity.disc_rates.base module¶
- class climada.entity.disc_rates.base.DiscRates(years=None, rates=None, tag=None)[source]¶
Bases:
object
Defines discount rates and basic methods. Loads from files with format defined in FILE_EXT.
- years¶
list of years
- Type
np.array
- rates¶
list of discount rates for each year (between 0 and 1)
- Type
np.array
- __init__(years=None, rates=None, tag=None)[source]¶
Fill discount rates with values and check consistency data
- Parameters
years (numpy.ndarray(int)) – Array of years. Default is numpy.array([]).
rates (numpy.ndarray(float)) – Discount rates for each year in years. Default is numpy.array([]). Note: rates given in float, e.g., to set 1% rate use 0.01
tag (climate.entity.tag) – Metadata. Default is None.
- select(year_range)[source]¶
Select discount rates in given years.
- Parameters
year_range (np.array(int)) – continuous sequence of selected years.
Returns (climada.entity.DiscRates) – The selected discrates in the year_range
- append(disc_rates)[source]¶
Check and append discount rates to current DiscRates. Overwrite discount rate if same year.
- Parameters
disc_rates (climada.entity.DiscRates) – DiscRates instance to append
- Raises
ValueError –
- net_present_value(ini_year, end_year, val_years)[source]¶
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
net_present_value – net present value between present year and future year.
- Return type
float
- plot(axis=None, figsize=(6, 8), **kwargs)[source]¶
Plot discount rates per year.
- Parameters
axis (matplotlib.axes._subplots.AxesSubplot, optional) – axis to use
figsize (tuple(int, int), optional) – size of the figure. The default is (6,8)
kwargs (optional) – keyword arguments passed to plotting function axis.plot
- Returns
axis – axis handles of the plot
- Return type
matplotlib.axes._subplots.AxesSubplot
- classmethod from_mat(file_name, description='', var_names={'field_name': 'discount', 'sup_field_name': 'entity', 'var_name': {'disc': 'discount_rate', 'year': 'year'}})[source]¶
Read MATLAB file generated with previous MATLAB CLIMADA version.
- Parameters
file_name (str) – filename including path and extension
description (str, optional) – description of the data. The default is ‘’
var_names (dict, optional) – name of the variables in the file. The Default is DEF_VAR_MAT = {‘sup_field_name’: ‘entity’, ‘field_name’: ‘discount’,
‘var_name’: {‘year’: ‘year’, ‘disc’: ‘discount_rate’}}
- Returns
The disc rates from matlab
- Return type
climada.entity.DiscRates
- classmethod from_excel(file_name, description='', var_names={'col_name': {'disc': 'discount_rate', 'year': 'year'}, 'sheet_name': 'discount'})[source]¶
Read excel file following template and store variables.
- Parameters
file_name (str) – filename including path and extension
description (str, optional) – description of the data. The default is ‘’
var_names (dict, optional) – name of the variables in the file. The Default is DEF_VAR_EXCEL = {‘sheet_name’: ‘discount’,
‘col_name’: {‘year’: ‘year’, ‘disc’: ‘discount_rate’}}
- Returns
The disc rates from excel
- Return type
climada.entity.DiscRates
- write_excel(file_name, var_names={'col_name': {'disc': 'discount_rate', 'year': 'year'}, 'sheet_name': 'discount'})[source]¶
Write excel file following template.
- Parameters
file_name (str) – filename including path and extension
var_names (dict, optional) – name of the variables in the file. The Default is DEF_VAR_EXCEL = {‘sheet_name’: ‘discount’,
‘col_name’: {‘year’: ‘year’, ‘disc’: ‘discount_rate’}}