@sh.add_function(
dsp, inputs=['output.calibration.wltp_h', 'data.prediction.models_wltp_h',
'input.prediction.wltp_h'], outputs=['data.prediction.wltp_h']
)
@sh.add_function(
dsp, inputs=['output.calibration.wltp_l', 'data.prediction.models_wltp_l',
'input.prediction.wltp_l'], outputs=['data.prediction.wltp_l']
)
def select_prediction_data(data, *new_data):
"""
Selects the data required to predict the CO2 emissions with CO2MPAS model.
:param data:
Output data.
:type data: dict
:param new_data:
New data.
:type new_data: dict
:return:
Data required to predict the CO2 emissions with CO2MPAS model.
:rtype: dict
"""
ids = _prediction_data
from co2mpas.defaults import dfl
if not dfl.functions.select_prediction_data.theoretical:
ids = ids + _prediction_data_ts
data = sh.selector(ids, data, allow_miss=True)
if new_data:
new_data = sh.combine_dicts(*new_data)
data = sh.combine_dicts(data, new_data)
if 'gears' in data and 'gears' not in new_data:
if data.get('gear_box_type', 0) == 'automatic' or \
len(data.get('velocities', ())) != len(data['gears']):
data.pop('gears')
return data