@sh.add_function(dsp, outputs=['after_treatment_warm_up_phases'])
def predict_after_treatment_warm_up_phases(
after_treatment_warm_up_duration, after_treatment_cooling_duration,
times, on_engine, is_cycle_hot):
"""
Calculates the engine speed delta due to the after treatment warm up [RPM].
:param after_treatment_warm_up_duration:
After treatment warm up duration [s].
:type after_treatment_warm_up_duration: float
:param after_treatment_cooling_duration:
After treatment cooling duration [s].
:type after_treatment_cooling_duration: float
:param times:
Time vector [s].
:type times: numpy.array
:param on_engine:
If the engine is on [-].
:type on_engine: numpy.array
:param is_cycle_hot:
Is an hot cycle?
:type is_cycle_hot: bool
:return:
Phases when engine speed is affected by the after treatment warm up [-].
:rtype: numpy.array
"""
phases = np.zeros_like(times, bool)
if after_treatment_warm_up_duration and on_engine.any():
indices = co2_utl.index_phases(on_engine)
indices = indices[np.append(not is_cycle_hot, np.diff(
times[indices].ravel()
)[1::2] > after_treatment_cooling_duration)]
for i, j in indices:
t = times[i:j + 1] - times[i]
phases[i:j + 1] = t < after_treatment_warm_up_duration
return phases