MISO2 Functions

Collection of helper methods used throughout the src code.

Created on Wed Jul 6 09:46:18 2022 @author: bgrammer

util.MISO2_functions.compare_parameter_dict(parameter_dict, other_parameter_dict)

Compare two parameter dicts values for equality.

Parameters:
  • parameter_dict (dict) – First dict of ODYM parameters

  • other_parameter_dict() – Second dict of ODYM parameters

Returns:

Bool comparison by parameter name

Return type:

dict

util.MISO2_functions.copy_and_subset_parameter_dict(parameter_dict, nr_start, nr_stop)

Creates a copy of a Parameter dictionary subset by the region index.

Parameters:
  • parameter_dict (dict) – A dictionary of ODYM Parameter objects.

  • nr_start (int) – Start region index.

  • nr_stop (int) – Stop region index. As usual with indexing, the subset will NOT include this row.

Returns:

A copy of the original parameter dict, subset by the region index.

Return type:

parameter_dict_copy(dict)

util.MISO2_functions.equalize_enduses(enduse_array, enduse_selectors)

Equalizes values in the enduse dimension of an array to 1.

Parameters:
  • enduse_array (np.ndarray) – Numpy array of enduses

  • enduse_selectors (list) – List of material indices where enduses must sum up to 1

Returns:

Copy of the equalized array.

Return type:

equalized_enduses(np.ndarray)

util.MISO2_functions.nb_any(array)

Short circuit version of np.any. Returns True if an array contains a null value. Note that np.nan counts as a value.

Parameters:

array (np.ndarray) – Array to be checked

Return type:

bool

util.MISO2_functions.set_arrays_exclusive_in_order(array_tuple_list)

Set values overlapping by index to zero in successive order.

Parameters:

array_tuple_list (list) – List of tuples with (name, np.ndarray) format

util.MISO2_functions.swap_dict_by_mat_to_dict_by_param(values_dict)

Swap a nested dictionary which is ordered by material {parameter: dataframe} into format parameter: [dataframes]

Parameters:

values_dict (dict)