Ejemplo n.º 1
0
def plot_p_over_vel(ax, plot_data: pd.PlotData):

    range_gears = np.unique(plot_data.gear)
    range_gears = np.sort(range_gears)
    range_gears = range_gears[range_gears > 0.0]

    labels = ['Gear {}'.format(str(g)) for g in range_gears]
    scale = 50.0
    alphas = [0.5] * len(labels)
    colors = [static_colors[i] for i, g in enumerate(range_gears)]
    full_acceleration_mask = data_processing.get_full_acceleration_mask(plot_data=plot_data)

    energy, kinetic_energy, potential_energy = data_processing.get_energy(plot_data=plot_data)
    times_steps = plot_data.run_time
    power = data_processing.derive_no_nan(x=kinetic_energy, time_steps=times_steps) / 1000.0

    x_points = []
    y_points = []
    scales = []
    for gear in range_gears:
        current_gear = plot_data.gear == gear
        interesting = np.logical_and(current_gear, full_acceleration_mask)

        speed_ms = plot_data.speed_ms
        x_points += [speed_ms[interesting]]
        y_points += [power[interesting]]
        scales += [np.ones_like(speed_ms[interesting]) * scale]

    scatter_plot(ax, x_points=x_points, y_points=y_points, title='Power over velocity (full throttle)',
                 labels=labels, colors=colors, scales=scales, alphas=alphas,
                 x_label='Velocity (m/s)', y_label='Power (kW)', plot_mean=True, plot_polynomial=False)
Ejemplo n.º 2
0
def energy_over_time(ax, plot_data: pd.PlotData):
    race_time = plot_data.run_time
    energy, kinetic_energy, potential_energy = data_processing.get_energy(plot_data=plot_data)
    energy_data = np.array([energy, kinetic_energy, potential_energy])

    labels = ['Energy (kJ)', 'Kinetic Energy (kJ)', 'Potential Energy (kJ)']
    y_points = energy_data
    x_points = np.array([race_time] * y_points.shape[0])

    line_plot(ax, x_points=x_points, y_points=y_points, title='Energy over time',
              labels=labels, alpha=0.5, x_label='Time (s)', y_label='Energy (kJ)', min_max_annotations=False)
Ejemplo n.º 3
0
def power_over_time(ax, plot_data: pd.PlotData):
    race_time = plot_data.run_time
    energy, kinetic_energy, potential_energy = data_processing.get_energy(plot_data=plot_data)
    # energy is dominated by potential energy -> take only kinetic energy
    power = data_processing.derive_no_nan(kinetic_energy, race_time)
    full_acceleration = data_processing.get_full_acceleration_mask(plot_data=plot_data)
    not_full_acceleration = np.logical_not(full_acceleration)
    power_full_acceleration = power.copy()
    power_full_acceleration[not_full_acceleration] = 0.0
    power_not_full_acceleration = power.copy()
    power_not_full_acceleration[full_acceleration] = 0.0
    power_data = np.array([power_full_acceleration, power_not_full_acceleration])
    power_data_mean = [np.mean(d) for d in power_data]

    labels = ['Power at full throttle (kW)', 'Power otherwise (kW)']
    labels = [l + ', mean: {:.1f}'.format(power_data_mean[li]) for li, l in enumerate(labels)]
    y_points = power_data
    x_points = np.array([race_time] * y_points.shape[0])

    line_plot(ax, x_points=x_points, y_points=y_points, title='Power over time',
              labels=labels, alpha=0.5, x_label='Time (s)', y_label='Power (kW)', min_max_annotations=False)
Ejemplo n.º 4
0
def plot_energy_over_2d_pos(ax, plot_data: pd.PlotData):

    scale_factor = 100.0
    range_gears = np.unique(plot_data.gear)
    range_gears = np.sort(range_gears)

    energy, kinetic_energy, potential_energy = data_processing.get_energy(plot_data=plot_data)
    energy_truncated = energy - np.min(energy)
    energy_normalized = energy_truncated / np.max(energy_truncated)

    labels = ['Gear {}'.format(str(g)) for g in range_gears]
    lines_x = []
    lines_y = []
    scales = []
    for i, g in enumerate(range_gears):
        current_gear = plot_data.gear == g
        lines_x += [plot_data.pos_x[current_gear]]
        lines_y += [plot_data.pos_y[current_gear]]
        scales += [energy_normalized[current_gear] * scale_factor]

    plot_over_2d_pos(ax, plot_data=plot_data, lines_x=lines_x, lines_y=lines_y,
                     scale=scales, alpha=0.5, title='Gear at 2D positions, scaled by energy', labels=labels)