gearshift.core.model.scaleTrace package

Module contents

It provides GEARSHIFT model dsp to obtain the speed trace following Sub-Annex 1 of the Annex XXI from the COMMISSION REGULATION (EU) 2017/1151.

Docstrings should provide sufficient understanding for any individual function.

Sub-Modules:

resample_trace(Trace)[source]

Re-sample the trace in 1Hz. If the trace was provided with higher sample rate, this may lead to data loss.

Parameters:

Trace (array) – Velocities and times from the phases of the WLTC cycle.

Returns:

  • originalTraceTimes (numpy.array):

    Times for each vehicle speed required re-sampled in 1Hz

  • originalVehicleSpeeds (numpy.array):

    The vehicle speed required for the whole cycle re-sampled in 1Hz

  • originalTraceTimesCount (int):

    The length of trace times re-sampled in 1Hz

identify_phases(PhaseLengths, originalTraceTimes)[source]

This function determines the starts and ends of different phases of the whole cycles.

Parameters:
  • PhaseLengths (list) – Contains the lengths of the different phases.

  • originalTraceTimes (array) – Contains the total times of the whole WLTC cycles.

Returns:

  • phaseStarts (numpy.array):

    The position of the beginning of each cycle

  • phaseEnds (numpy.array):

    The position of the end of each cycle

calculate_accelerations(originalVehicleSpeeds, originalTraceTimes)[source]

Calculate accelerations.

Parameters:
  • originalVehicleSpeeds (array) – Contains the speeds of the whole WLTC cycles.

  • originalTraceTimes (array) – Contains the times of the whole WLTC cycles.

Returns:

  • accelerations (numpy.array):

    Accelerations from the whole WLTC cycles.

calculate_required_powers(originalVehicleSpeeds, accelerations, VehicleTestMass, f0, f1, f2)[source]

Calculate required powers, following the P_req,max,i function in section 8.3.

Parameters:
  • originalVehicleSpeeds (array) – Contains the speeds of the whole WLTC cycles.

  • accelerations (array) – Accelerations from the whole WLTC cycles.

  • VehicleTestMass (float) – Vehicle test mass used during the cycle execution.

  • f0 (float) – Represents the constant road load coefficient, i.e. independent of velocity, caused by internal frictional resistances.

  • f1 (float) – Represents the linear road load coefficient, i.e. proportional to velocity, caused by tyres rolling resistances.

  • f2 (float) – Represents the exponential road load coefficient, i.e. quadratical to velocity, caused by aerodynamic resistances.

Returns:

  • requiredPowers (numpy.array):

    The power required to overcome driving resistance and to accelerate.

downscale_trace(r0, a1, b1, UseCalculatedDownscalingPercentage, DownscalingPercentage, requiredPowers, RatedEnginePower, ScalingStartTimes, ScalingCorrectionTimes, ScalingEndTimes, originalTraceTimes, ScalingAlgorithms, originalVehicleSpeeds, ApplyDownscaling, accelerations)[source]

Downscaling applies to very low powered class 1 vehicles or vehicles with power to mass ratios close to class borderlines, thus causing driveability issues.

Parameters:
  • r0 (float) – Factor to determine the downscaling factor

  • a1 (float) – Factor to determine the downscaling factor

  • b1 (float) – Factor to determine the downscaling factor

  • UseCalculatedDownscalingPercentage (boolean) – Boolean variable to check if is necessary calculates the downscaling factor

  • DownscalingPercentage (float) – The degree of downscaling. This value will only be used if the input parameter UseCalculatedDownscalingPercentage is false.

  • requiredPowers (array) – The power required to overcome driving resistance and to accelerate.

  • RatedEnginePower (float) – The maximum rated engine required

  • ScalingStartTimes (array) – Contains the start times of the segments to scale in seconds.

  • ScalingCorrectionTimes (array) – Contains the times to begin the scaling correction at in seconds. The size must correspond to the size of ScalingStartTimes. Each value must be between the corresponding start and end times.

  • ScalingEndTimes (array) – Contains the end times of the segments to scale in seconds. The size must correspond to the size of ScalingStartTimes.

  • originalTraceTimes (array) – The times used in the whole trace.

  • ScalingAlgorithms (String) – Represents a strings, that denotes the algorithm to use for the specific segment.

  • originalVehicleSpeeds (array) – The speeds used in the whole trace.

  • ApplyDownscaling (boolen) – Specifies if the trace shall be downscaled.

  • accelerations (array) – Accelerations from the whole WLTC cycles.

Returns:

  • downscaled (boolean numpy.array):

    Array that contains the values that have been downscaled as True

  • downscaledVehicleSpeeds (boolean numpy.array):

    The vehicle speed after have been downscaled

  • requiredToRatedPowerRatios (numpy.array):

    The required power ratios after apply the downscaling factor

  • calculatedDownscalingFactors (numpy.array):

    The downscaling factor for each time of the whole cycle

  • downscalingFactor (float):

    The downscaling factor applicable

  • requiredToRatedPowerRatio (float):

    The maximum required to rated power ratio

cap_trace(ApplySpeedCap, CappedSpeed, downscaledVehicleSpeeds)[source]

Speed cap applies to vehicles that are technically able to follow the given trace, but whose maximum speed is limited to a value lower than the maximum speed of that trace.

Parameters:
  • ApplySpeedCap (boolean) – Specifies if the trace shall be capped to the given CappedSpeed.

  • CappedSpeed (array) – The maximum speed of vehicles, which are technically able to follow the speed of the given trace but are not able to reach the maximum speed of that trace.

Returns:

  • capped (boolean numpy.array):

    The boolean array that show the vehicle speeds capped

  • cappedVehicleSpeeds (numpy.array):

    The vehicle speeds capped according to the maximum value available

compensate_trace(originalTraceTimesCount, originalTraceTimes, cappedVehicleSpeeds, PhaseLengths, ApplyDistanceCompensation, phaseStarts, phaseEnds, downscaledVehicleSpeeds, CappedSpeed, capped, downscaled)[source]

A capped trace may need compensations to achieve the same distance as for the original trace.

Parameters:
  • originalTraceTimesCount (integer) – The original length of the trace time

  • originalTraceTimes (array) – The times used in the whole trace.

  • cappedVehicleSpeeds (array) – The vehicle speeds capped according to the maximum value available

  • PhaseLengths (list) – Contains the lengths of the different phases.

  • ApplyDistanceCompensation (boolean) – Specifies it the trace shall be compensated for distance due to capped speeds.

  • phaseStarts (array) – The position of the beginning of each cycle.

  • phaseEnds (array) – The position of the end of each cycle.

  • downscaledVehicleSpeeds (array) – Contains the speeds of the whole WLTC cycles downscaled.

  • CappedSpeed (array) – The maximum speed of vehicles, which are technically able to follow the speed of the given trace but are not able to reach the maximum speed of that trace.

  • capped (boolean array) – The boolean array that show the vehicle speeds capped.

  • downscaled (boolean array) – The boolean array that show the vehicle speeds downscaled.

Returns:

  • compensated (boolean numpy.array):

    The boolean array that contains the values that have been compensated as True

  • compensatedTraceTimes (numpy.array):

    The trace times that array contains the new values of the compensation if compensation has been necessary

  • compensatedVehicleSpeeds (numpy.array):

    The vehicle speeds array that contains the new values of the compensation if compensation has been necessary

  • downscaledCompensated (boolean numpy.array):

    The boolean array that contains the values that have been downscaled and compensated as True

  • cappedCompensated (boolean numpy.array):

    The boolean array that contains the values that have been capped and compensated as True

  • additionalSamples (numpy.array):

    The additional samples after apply compensation

generate_speed_trace(downscalingFactor, requiredToRatedPowerRatio, requiredToRatedPowerRatios, calculatedDownscalingFactors, originalVehicleSpeeds, PhaseLengths, phaseStarts, phaseEnds, compensatedVehicleSpeeds, additionalSamples, originalTraceTimes, compensatedTraceTimes, downscaledCompensated, cappedCompensated, compensated)[source]

This function creates a dictionary with the final results of the Scale trace

Parameters:
  • downscalingFactor (float) – The downscaling factor for the cycle

  • requiredToRatedPowerRatio (float) – The required rated power ratio after apply the downscaling factor.

  • requiredToRatedPowerRatio – The required rated power ratio after apply the downscaling factors.

  • calculatedDownscalingFactors (float) – The downscaling factor for the cycle

  • originalVehicleSpeeds (array) – The speeds used in the whole trace.

  • PhaseLengths (list) – Contains the lengths of the different phases.

  • phaseStarts (array) – The position of the beginning of each cycle.

  • phaseEnds (array) – The position of the end of each cycle.

  • compensatedVehicleSpeeds (array) – The vehicle speeds after apply compensation.

  • additionalSamples (array) – The additional samples added to compensate the capped speed correction.

  • originalTraceTimes (array) – The times used in the whole trace.

  • compensatedTraceTimes (array) – The final times after applied compensation

  • downscaledCompensated (boolean array) – The boolean array that shows the vehicle speeds downscaled and compensated

  • cappedCompensated – The boolean array that shows the vehicle speeds capped and compensated

:param compensated:boolean array

Returns:

  • speed_trace (dict):

    The dictionary that contains the all final values of speed trace