windisch.array

fill_xarray_from_input_parameters creates an xarray and fills it with sampled input parameter values if a distribution is defined.

Functions

fill_xarray_from_input_parameters(tip[, ...])

Create an xarray labeled array from the sampled input parameters.

missing_param_for_distribution(param, ...)

Print a warning message in case of misisng parameters for a distribution.

modify_xarray_from_custom_parameters(...)

Override default parameters values in xarray based on values provided by the user.

windisch.array.fill_xarray_from_input_parameters(tip: TurbinesInputParameters, sensitivity: bool = False, scope: dict | None = None) Tuple[Tuple, DataArray]

Create an xarray labeled array from the sampled input parameters.

This function extracts the parameters’ names and values contained in the parameters attribute of the TurbinesInputParameters class in turbines_input_parameters and insert them into a multi-dimensional numpy-like array from the xarray package (http://xarray.pydata.org/en/stable/).

Parameters:
  • sensitivity

  • tip – Instance of the TurbinesInputParameters class in turbines_input_parameters.

  • scope – a dictionary to narrow down the scope of vehicles to consider

Returns:

tuple, xarray.DataArray

  • tuple (size_dict, application_dict, parameter_dict, year_dict)

  • array

Dimensions of array:

  1. Turbine size (in kW), e.g. “100”, “500”. str.

  2. Application, e.g. “onshore”, “offshore”. str.

  3. Year. int.

  4. Samples.

windisch.array.missing_param_for_distribution(param: str, dist_type: str, year: int)

Print a warning message in case of misisng parameters for a distribution. :param param: input parameter for which the distribution parameter is missing, str. :param dist_type: distribution type, str. :param year: year, int :return: nothing.

windisch.array.modify_xarray_from_custom_parameters(filepath: str | dict, array: DataArray) DataArray

Override default parameters values in xarray based on values provided by the user.

This function allows to override one or several default parameter values by providing either:

  • a file path to an Excel workbook that contains the new values

  • or a dictionary

The dictionary must be of the following format:

{
    (parameter category,
        application,
        size,
        parameter name,
        uncertainty type): {
                            (year, 'loc'): value,
                            (year, 'scale'): value,
                            (year, 'shape'): value,
                            (year, 'minimum'): value,
                            (year, 'maximum'): value
    }

}

For example:

{
    ('Operation',
    'all',
    'all',
    'lifetime',
    'none'): {
        (2018, 'loc'): 15, (2040, 'loc'): 25
        }

}
Parameters:
  • array – the array to modify

  • filepath (str or dict) – File path of workbook with new values or dictionary.

Returns:

the original array, but modified