climada.entity.disc_rates package¶
climada.entity.disc_rates.base module¶
-
class
climada.entity.disc_rates.base.
DiscRates
[source]¶ Bases:
object
Defines discount rates and basic methods. Loads from files with format defined in FILE_EXT.
-
years
¶ years
- Type
np.array
-
rates
¶ discount rates for each year (between 0 and 1)
- Type
np.array
-
__init__
()[source]¶ 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)
-
select
(year_range)[source]¶ Select discount rates in given years.
- Parameters
year_range (np.array) – continuous sequence of selected years.
- Returns
DiscRates
-
append
(disc_rates)[source]¶ Check and append discount rates to current DiscRates. Overwrite discount rate if same year.
- Parameters
disc_rates (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
float
-
plot
(axis=None, **kwargs)[source]¶ 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_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) – absolute file name
description (str, optional) – description of the data
var_names (dict, optional) – name of the variables in the file
-
read_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) – absolute file name
description (str, optional) – description of the data
var_names (dict, optional) – name of the variables in the file
-