storage_tree module

class ezclimate.storage_tree.BaseStorageTree(decision_times)[source]

Bases: object

Abstract storage class for the EZ-Climate model.

Parameters:decision_times (ndarray or list) – array of years from start where decisions about mitigation levels are done
decision_times

ndarray – array of years from start where decisions about mitigation levels are done

information_times

ndarray – array of years where new information is given to the agent in the model

periods

ndarray – periods in the tree

tree

dict – dictionary where keys are periods and values are nodes in period

__getitem__(key)[source]
get_next_period_array(period)[source]

Return the array of the next period from periods.

is_decision_period(time_period)[source]

Checks if time_period is a decision time for mitigation, where time_period is the number of years since start.

Parameters:time_period (int) – time since the start year of the model
Returns:True if time_period also is a decision time, else False
Return type:bool
is_information_period(time_period)[source]

Checks if time_period is a information time for fragility, where time_period is the number of years since start.

Parameters:time_period (int) – time since the start year of the model
Returns:True if time_period also is an information time, else False
Return type:bool
is_real_decision_period(time_period)[source]

Checks if time_period is a decision time besides the last period, where time_period is the number of years since start.

Parameters:time_period (int) – time since the start year of the model
Returns:True if time_period also is a real decision time, else False
Return type:bool
last

ndarray – last period’s array.

last_period

int – index of last period.

nodes

int – number of nodes in the tree.

set_value(period, values)[source]

If period is in periods, set the value of element to values (ndarray).

write_columns(file_name, header, start_year=2015, delimiter=';')[source]

Save values in tree as columns into file file_name in the ‘data’ directory in the current working directory. If there is no ‘data’ directory, one is created.

Year Node header
start_year 0 val0
Parameters:
  • file_name (str) – name of saved file
  • header (str) – description of values in tree
  • start_year (int, optional) – start year of analysis
  • delimiter (str, optional) – delimiter in file
write_columns_existing(file_name, header, delimiter=';')[source]

Save values in tree as columns into file file_name in the ‘data’ directory in the current working directory, when file_name already exists. If there is no ‘data’ directory, one is created.

Year Node other_header header
start_year 0 other_val0 val0
Parameters:
  • file_name (str) – name of saved file
  • header (str) – description of values in tree
  • start_year (int, optional) – start year of analysis
  • delimiter (str, optional) – delimiter in file
write_tree(file_name, header, delimiter=';')[source]

Save values in tree as a tree into file file_name in the ‘data’ directory in the current working directory. If there is no ‘data’ directory, one is created.

Parameters:
  • file_name (str) – name of saved file
  • header (str) – first row of file
  • delimiter (str, optional) – delimiter in file
class ezclimate.storage_tree.BigStorageTree(subinterval_len, decision_times)[source]

Bases: ezclimate.storage_tree.BaseStorageTree

Storage tree class for the EZ-Climate model. Storage in nodes between periods in decision_times.

Parameters:
  • subintervals_len (float) – years between periods in tree
  • decision_times (ndarray or list) – array of years from start where decisions about mitigation levels are done
decision_times

ndarray – array of years from start where decisions about mitigation levels are done

information_times

ndarray – array of years where new information is given to the agent in the model

periods

ndarray – periods in the tree

tree

dict – dictionary where keys are periods and values are nodes in period

subintervals_len

float – years between periods in tree

between_decision_times(period)[source]

Check which decision time the period is between and returns the index of the lower decision time.

Parameters:period (int) – period
Returns:index
Return type:int

Examples

>>> bst = BigStorageTree(5, [0, 15, 45, 85, 185, 285, 385])
>>> bst.between_decision_times(5)
0
>>> bst.between_decision_times(15)
1
decision_interval(period)[source]

Check which interval the period is between.

Parameters:period (int) – period
Returns:index
Return type:int

Examples

>>> bst = BigStorageTree(5, [0, 15, 45, 85, 185, 285, 385])
>>> bst.decision_interval(5)
1
>>> bst.between_decision_times(15)
1
>>> bst.between_decision_times(20)
2
first_period_intervals

ndarray – the number of subintervals in the first period.

get_next_period_array(period)[source]

Returns the array of the next period.

Parameters:period (int) – period

Examples

>>> bst = BigStorageTree(5.0, [0, 15, 45, 85, 185, 285, 385])
>>> sst.get_next_period_array(0)
array([0., 0.])
>>> sst.get_next_period_array(10)
array([ 0.,  0., 0., 0.])
Raises:IndexError – If period is not a valid period or too large
class ezclimate.storage_tree.SmallStorageTree(decision_times)[source]

Bases: ezclimate.storage_tree.BaseStorageTree

Storage tree class for the EZ-Climate model. No storage in nodes between periods in decision_times.

Parameters:decision_times (ndarray or list) – array of years from start where decisions about mitigation levels are done
decision_times

ndarray – array of years from start where decisions about mitigation levels are done

information_times

ndarray – array of years where new information is given to the agent in the model

periods

ndarray – periods in the tree

tree

dict – dictionary where keys are periods and values are nodes in period

get_next_period_array(period)[source]

Returns the array of the next decision period.

Parameters:period (int) – period

Examples

>>> sst = SmallStorageTree([0, 15, 45, 85, 185, 285, 385])
>>> sst.get_next_period_array(0)
array([0., 0.])
>>> sst.get_next_period_array(15)
array([ 0.,  0.,  0.,  0.])
Raises:IndexError – If period is not in real decision times
index_below(period)[source]

Returns the key of the previous decision period.

Parameters:period (int) – period

Examples

>>> sst = SmallStorageTree([0, 15, 45, 85, 185, 285, 385])
>>> sst.index_below(15)
0
Raises:IndexError – If period is not in decision times or first element in decision times