captest.util.process_reg_cols

captest.util.process_reg_cols(original_calc_params, calc_params=None, key_id=None, dict_path=None, cd=None, agg_cache=None, verbose=True)

Recursively process a regression columns dictionary that includes calculated parameters.

The regression parameters dictionary attribute of CapData can be defined with a nested structure which includes tuples with two values where the first is a CapData method to calculate a new value (column of Data attribute) and the second is a dictionary of the kwargs to be passed to the function.

An example tuple: (bom_temp, {‘poa’: ‘irr_poa’, ‘temp_amb’:’temp_amb’, ‘wind_speed’:’wind_speed’})

Where bom_temp is a CapData method that accepts the kwargs poa, temp_amb, and wind_speed, which have the values (column group ids) irr_poa, temp_amb, wind_speed, respectively.

Additionally, column groups can be aggregated by specifying a tuple which contains two strings - the column group id (e.g., ‘irr_poa’) and the aggregation method (e.g. ‘mean’). This will result in the CapData.agg_group method being called and the first value in the tuple passed to the group_id kwarg and the second passed to the agg_func kwarg.

If a regression parameter key is paired with a column groups id for a column group with only a single column, then that column name will replace the column group id.

The dictionary passed to original_calc_params may be nested like this example:

calc_params_map = {
‘power_tc’: (CapData.power_tc, {

‘power’: ‘real_pwr_mtr’, ‘cell_temp’: (CapData.cell_temp, {

‘poa’: (‘irr_poa’, ‘mean’), ‘bom’: (CapData.bom_temp, {

‘poa’: (‘irr_poa’, ‘mean’), ‘temp_amb’: (‘temp_amb’, ‘mean’), ‘wind_speed’: (‘wind_speed’, ‘mean’)

})

})

}),

}

This function will start at the bottom of nested dictionaries and progressively call the functions with the kwargs replacing the function tuples with the function names or the aggregated column names.

Parameters:
  • original_calc_params (dict) – The original dictionary to be modified

  • calc_params (dict or tuple) – Deprecated. Ignored if provided.

  • key_id (str) – Deprecated. Ignored if provided.

  • dict_path (list) – Deprecated. Ignored if provided.

  • cd (CapData) – CapData instance that functions in original_calc_params will act on.

  • agg_cache (dict, optional) – Cache of already aggregated column groups to avoid redundant calls to agg_group. Keys are tuples of (group_id, agg_func) and values are the aggregated column names.

  • verbose (bool, default True) – Passed to the group aggregations and the parameter calculations. Set to False to prevent all summary output.

Returns:

Modifies the original_calc_params and the data attribute of the CapData object passed to the cd argument.

Return type:

None