def mpu6050(data): TOOLTIPS = [ ("(x,y)", "($x, $y)"), ] renderer = 'webgl' graphTools = 'pan,wheel_zoom,box_zoom,zoom_in,zoom_out,hover,crosshair,undo,redo,reset,save' sensor_data_a = data['GForceLat'] sensor_data_b = -data['GForceLong'] sensor_data_c = -data['gyro_z'] sensor_data_d = data['SteeringAngle'] sensor_data_e = data['Speed'] sensor_data_f = data['ECU_GForceLat'] sensor_data_a = pd.to_numeric(sensor_data_a) sensor_data_b = pd.to_numeric(sensor_data_b) sensor_data_c = pd.to_numeric(sensor_data_c) sensor_data_d = pd.to_numeric(sensor_data_d) sensor_data_e = pd.to_numeric(sensor_data_e) sensor_data_f = pd.to_numeric(sensor_data_f) sensor_time = data['time'] sensor_time = pd.to_numeric(sensor_time) sensor_time = sensor_time / 1000 sensor_data_d.loc[sensor_data_d > 3276.8] = sensor_data_d.loc[ sensor_data_d > 3276.8] - 6553.6 sensor_data_f.loc[sensor_data_f > 32.768] = sensor_data_f.loc[ sensor_data_f > 32.768] - 65.536 cutFs = 5 filteredsignal_a = ncuTools.bandPassFilter(sensor_data_a, cutf=cutFs, order=5) filteredsignal_b = ncuTools.bandPassFilter(sensor_data_b, cutf=cutFs, order=5) cutFs = 1 filteredsignal_c = ncuTools.bandPassFilter(sensor_data_c, cutf=cutFs, order=5) p = figure( plot_width=1500, plot_height=300, title='MPU6050', x_axis_label='s', y_axis_label='G', toolbar_location="below", tooltips=TOOLTIPS, output_backend=renderer, tools=graphTools, ) p1 = figure( plot_width=1500, plot_height=300, title='Speed', x_axis_label='s', y_axis_label='Speed(km/h)', toolbar_location="below", tooltips=TOOLTIPS, output_backend=renderer, tools=graphTools, x_range=p.x_range, ) p2 = figure( plot_width=600, plot_height=600, title='GXxGY', x_axis_label='Gx', y_axis_label='Gy', toolbar_location="below", tooltips=TOOLTIPS, output_backend=renderer, tools=graphTools, ) y_overlimit = 0.05 # show y axis below and above y min and max value # FIRST AXIS p.y_range = Range1d(-2, 2) p.extra_y_ranges = { "b": Range1d(sensor_data_c.min() * (1 - y_overlimit), sensor_data_c.max() * (1 + y_overlimit)) } p.add_layout(LinearAxis(y_range_name="b", axis_label="Gyro(°/s)"), 'right') p1.y_range = Range1d(sensor_data_e.min() * (1 - y_overlimit), sensor_data_e.max() * (1 + y_overlimit)) p1.extra_y_ranges = { "b": Range1d(sensor_data_d.min() * (1 - y_overlimit), sensor_data_d.max() * (1 + y_overlimit)) } p1.add_layout(LinearAxis(y_range_name="b", axis_label="degree(°)"), 'right') #g1b = p.line(sensor_time, sensor_data_f, color='orange') # X and Y axis are inverted #g1 = p.line(sensor_time, sensor_data_b, color='red') #X and Y axis are inverted #g2 = p.line(sensor_time, sensor_data_a, color='green') g1f = p.line(sensor_time, filteredsignal_b, color='red') # X and Y axis are inverted g2f = p.line(sensor_time, filteredsignal_a, color='green') #g3 = p.line(sensor_time, sensor_data_c, color='yellow', y_range_name="b", line_width=2) g3f = p.line(sensor_time, filteredsignal_c, color='yellow', y_range_name="b", line_width=2) g4 = p1.line(sensor_time, sensor_data_e, color='blue', line_width=2) g5 = p1.line(sensor_time, sensor_data_d, color='green', y_range_name="b") p2.scatter(filteredsignal_b, filteredsignal_a, line_color=None) legend = Legend( items=[ #('35Hz X axis Acelerometer @MOTEC', [g1b]), #('200Hz X axis MPU6050 @NCU', [g1]), #('200Hz Y axis MPU6050 @NCU', [g2]), #('200Hz Gyro Z axis MPU6050 @NCU', [g3]), ('5Hz Low Pass Filter X axis MPU6050 @NCU', [g1f]), ('5Hz Low Pass Filter Y axis MPU6050 @NCU', [g2f]), ('1Hz Low Pass Filter Gyro Z axis MPU6050 @NCU', [g3f]) ], location=(0, 0)) legend1 = Legend(items=[('35Hz Speed @MOTEC', [g4]), ('35Hz Steering Angle @MOTEC', [g5])], location=(0, 0)) p.add_layout(legend, 'right') p1.add_layout(legend1, 'right') p.legend.click_policy = 'hide' p1.legend.click_policy = 'hide' p.toolbar.logo = None p1.toolbar.logo = None p2.toolbar.logo = None grid = gridplot([[p], [p1], [p2]], merge_tools=True, toolbar_location='left') l1 = layout(grid) tab = Panel(child=l1, title="3Axis Acelerometer and Gyro", closable=True) return tab
def LVDT(data): TOOLTIPS = [ ("(x,y)", "($x, $y)"), ] renderer = 'webgl' graphTools = 'pan,wheel_zoom,box_zoom,zoom_in,zoom_out,hover,crosshair,undo,redo,reset,save' sensor_data_a = data['LVDTFL'] sensor_data_b = data['LVDTFR'] sensor_data_c = data['LVDTRL'] sensor_data_d = data['LVDTRR'] sensor_data_e = data['Speed'] sensor_data_x = -data['GForceLong'] sensor_data_y = data['GForceLat'] sensor_data_z = data['GForceVert'] sensor_data_tps = data['TPS'] sensor_data_bp = data['BrakePressure'] sensor_data_sa = data['SteeringAngle'] sensor_data_a = pd.to_numeric(sensor_data_a) sensor_data_b = pd.to_numeric(sensor_data_b) sensor_data_c = pd.to_numeric(sensor_data_c) sensor_data_d = pd.to_numeric(sensor_data_d) sensor_data_e = pd.to_numeric(sensor_data_e) sensor_data_sa = pd.to_numeric(sensor_data_sa) sensor_data_sa.loc[sensor_data_sa > 3276.8] = sensor_data_sa.loc[sensor_data_sa > 3276.8] - 6553.6 sensor_time = data['time'] sensor_time = pd.to_numeric(sensor_time) sensor_time = sensor_time/1000 cutFs=12 filteredsignal_a = ncuTools.bandPassFilter(sensor_data_a, cutf=cutFs, order = 5) filteredsignal_b = ncuTools.bandPassFilter(sensor_data_b, cutf=cutFs, order = 5) filteredsignal_c = ncuTools.bandPassFilter(sensor_data_c, cutf=cutFs, order = 5) filteredsignal_d = ncuTools.bandPassFilter(sensor_data_d, cutf=cutFs, order = 5) filteredsignal_x = ncuTools.bandPassFilter(sensor_data_x, cutf=5, order=5) filteredsignal_y = ncuTools.bandPassFilter(sensor_data_y, cutf=5, order = 5) filteredsignal_z = ncuTools.bandPassFilter(sensor_data_z, cutf=5, order = 5) sensor_data_a = ncuTools.mapDouble(sensor_data_a, 0.59, 0.65, 206, 196) sensor_data_b = ncuTools.mapDouble(sensor_data_b, 0.9 , 0.94, 206, 196) sensor_data_c = ncuTools.mapDouble(sensor_data_c, 0.92, 1.02, 221, 216) sensor_data_d = ncuTools.mapDouble(sensor_data_d, 0.76, 0.8 , 221, 216) filteredsignal_a = ncuTools.mapDouble(filteredsignal_a, 0.59, 0.65, 206, 196) filteredsignal_b = ncuTools.mapDouble(filteredsignal_b, 0.9, 0.94, 206, 196) filteredsignal_c = ncuTools.mapDouble(filteredsignal_c, 0.92, 1.02, 221, 216) filteredsignal_d = ncuTools.mapDouble(filteredsignal_d, 0.76, 0.8, 221, 216) diffdata_a = np.diff(sensor_data_a) / np.diff(sensor_time) diffdata_b = np.diff(sensor_data_b) / np.diff(sensor_time) diffdata_c = np.diff(sensor_data_c) / np.diff(sensor_time) diffdata_d = np.diff(sensor_data_d) / np.diff(sensor_time) diffdata_a = ncuTools.bandPassFilter(diffdata_a, cutf=cutFs, order=5) diffdata_b = ncuTools.bandPassFilter(diffdata_b, cutf=cutFs, order=5) diffdata_c = ncuTools.bandPassFilter(diffdata_c, cutf=cutFs, order=5) diffdata_d = ncuTools.bandPassFilter(diffdata_d, cutf=cutFs, order=5) altFront = filteredsignal_a/2+filteredsignal_b/2 altRear = filteredsignal_c/2+filteredsignal_d/2 cutFsAlt=5 altFront = ncuTools.bandPassFilter(altFront, cutf=cutFsAlt, order=2) altRear = ncuTools.bandPassFilter(altRear, cutf=cutFsAlt, order=2) ''' p = figure(plot_width = 1200, plot_height = 300, title = 'LVDT RAW', x_axis_label = 's', y_axis_label = 'mm', toolbar_location="below", tooltips=TOOLTIPS, output_backend=renderer, tools=graphtools, ) y_overlimit = 0.05 # show y axis below and above y min and max value # FIRST AXIS p.y_range = Range1d( 150, 250 ) g1 = p.line(sensor_time, sensor_data_a, color='blue', line_width=2) g2 = p.line(sensor_time, sensor_data_b, color='red', line_width=2) g3 = p.line(sensor_time, sensor_data_c, color='yellow', line_width=2) g4 = p.line(sensor_time, sensor_data_d, color='green', line_width=2) legend = Legend(items=[ ('200Hz LVDTFL @NCU', [g1]), ('200Hz LVDTFR @NCU', [g2]), ('200Hz LVDTRL @NCU', [g3]), ('200Hz LVDTRR @NCU', [g4]) ], location=(0,0)) p.add_layout(legend, 'right') p.legend.click_policy='hide' ##### NEW FIGURE ''' p1 = figure(plot_width = 1400, plot_height = 300, title = 'LVDT FILTERED', x_axis_label = 's', y_axis_label = 'mm', toolbar_location="left", tooltips=TOOLTIPS, output_backend=renderer, tools=graphTools, ) p2 = figure(plot_width = 1400, plot_height = 300, title = 'LVDT DUMPER', x_axis_label = 's', y_axis_label = 'mm/s', toolbar_location="left", tools=graphTools, output_backend=renderer, tooltips=TOOLTIPS, x_range=p1.x_range) p3 = figure(plot_width = 1400, plot_height = 300, title = 'LATERAL FORCE', x_axis_label = 's', y_axis_label = 'mm', toolbar_location="left", tools=graphTools, output_backend=renderer, tooltips=TOOLTIPS, x_range=p1.x_range) p4 = figure(plot_width = 1400, plot_height = 300, title = 'ACELERATION', x_axis_label = 's', y_axis_label = 'G', toolbar_location="left", tools=graphTools, output_backend=renderer, tooltips=TOOLTIPS, x_range=p1.x_range) y_overlimit = 0.05 # show y axis below and above y min and max value p1.y_range = Range1d( altFront.min() * (1 - y_overlimit), altRear.max() * (1 + y_overlimit) ) p1.extra_y_ranges = {"b": Range1d( sensor_data_sa.min() * (1 - y_overlimit), sensor_data_sa.max() * (1 + y_overlimit) )} p1.add_layout(LinearAxis(y_range_name="b", axis_label="Speed(km/h)"), 'right') p2.y_range = Range1d(-1000,1000) p2.extra_y_ranges = {"b": Range1d( sensor_data_e.min() * (1 - y_overlimit), sensor_data_e.max() * (1 + y_overlimit) )} p2.add_layout(LinearAxis(y_range_name="b", axis_label="Speed(km/h)"), 'right') p3.extra_y_ranges = {"b": Range1d( sensor_data_e.min() * (1 - y_overlimit), sensor_data_e.max() * (1 + y_overlimit) )} p3.add_layout(LinearAxis(y_range_name="b", axis_label="Speed(km/h)"), 'right') p4.y_range = Range1d(sensor_data_x.min() * (1 - y_overlimit), sensor_data_x.max() * (1 + y_overlimit)) p4.extra_y_ranges = {"b": Range1d(0,100)} p4.add_layout(LinearAxis(y_range_name="b", axis_label="TPS(%)"), 'right') # FIRST AXIS g5 = p1.line(sensor_time, filteredsignal_a, color='blue', line_width=2) g6 = p1.line(sensor_time, filteredsignal_b, color='red', line_width=2) g7 = p1.line(sensor_time, filteredsignal_c, color='orange', line_width=2) g8 = p1.line(sensor_time, filteredsignal_d, color='green', line_width=2) g9 = p1.line(sensor_time, sensor_data_sa, color='black', y_range_name = "b", alpha=0.8, line_width=2) g13 = p2.line(sensor_time[:-1], diffdata_a, color='blue') g14 = p2.line(sensor_time[:-1], diffdata_b, color='red') g15 = p2.line(sensor_time[:-1], diffdata_c, color='orange') g16 = p2.line(sensor_time[:-1], diffdata_d, color='green') g10 = p1.line(sensor_time, altFront, color='yellow', line_width=2) g11 = p1.line(sensor_time, altRear, color='purple', line_width=2) gx = p4.line(sensor_time, filteredsignal_x, color='blue', line_width=2) gy = p4.line(sensor_time, filteredsignal_y, color='purple', line_width=2) gz = p4.line(sensor_time, filteredsignal_z, color='orange' , line_width=2) gtps = p4.line(sensor_time, sensor_data_tps, color='green', y_range_name="b" , line_width=2) gbp = p4.line(sensor_time, sensor_data_bp, color='red', y_range_name="b", line_width=2) legend1 = Legend(items=[ ((str(cutFs) + 'Hz LOW PASS FILTER LVDTFL @NCU'), [g5]), ((str(cutFs) + 'Hz LOW PASS FILTER LVDTFR @NCU'), [g6]), ((str(cutFs) + 'Hz LOW PASS FILTER LVDTRL @NCU'), [g7]), ((str(cutFs) + 'Hz LOW PASS FILTER LVDTRR @NCU'), [g8]), ((str(cutFsAlt) + 'Hz LOW PASS FILTER FRONT ALTERNATOR @NCU'), [g10]), ((str(cutFsAlt) + 'Hz LOW PASS FILTER REAR ALTERNATOR @NCU'), [g11]), ('35Hz Steering Angle @MOTEC', [g9]) ], location=(0,0)) legend2 = Legend(items=[ ((str(cutFs) + 'Hz LOW PASS FILTER DUMPER LVDTFL @NCU'), [g13]), ((str(cutFs) + 'Hz LOW PASS FILTER DUMPER LVDTFR @NCU'), [g14]), ((str(cutFs) + 'Hz LOW PASS FILTER DUMPER LVDTRL @NCU'), [g15]), ((str(cutFs) + 'Hz LOW PASS FILTER DUMPER LVDTRR @NCU'), [g16]) ], location=(0,0)) legend3 = Legend(items=[ ], location=(0,0)) legend4 = Legend(items=[ ((str(5) + 'Hz LOW PASS FILTER G LAT FORCE @NCU'), [gx]), ((str(5) + 'Hz LOW PASS FILTER G LONGITUDIAL FORCE @NCU'), [gy]), ((str(5) + 'Hz LOW PASS FILTER G VERTICAL FORCE @NCU'), [gz]), ((str(35) + 'Hz TPS @MOTEC'), [gtps]), ((str(35) + 'Hz BRAKE PRESSURE @MOTEC'), [gbp]), ], location=(0,0)) p1.add_layout(legend1, 'right') p2.add_layout(legend2, 'right') p3.add_layout(legend3, 'right') p4.add_layout(legend4, 'right') p1.legend.click_policy = 'hide' p2.legend.click_policy='hide' p3.legend.click_policy = 'hide' p4.legend.click_policy = 'hide' p1.toolbar.logo = None p2.toolbar.logo = None p3.toolbar.logo = None p4.toolbar.logo = None grid1 = gridplot([[p1],[p4],[p2]], toolbar_location='left') l1 = layout([grid1]) tab = Panel(child=l1, title="Suspension Position", closable=True) return tab
def suspFFT(data): TOOLTIPS = [ ("(x,y)", "($x, $y)"), ] renderer = 'webgl' graphTools = 'pan,wheel_zoom,box_zoom,zoom_in,zoom_out,hover,crosshair,undo,redo,reset,save' sensor_data_a = data['LVDTFL'] sensor_data_b = data['LVDTFR'] sensor_data_c = data['LVDTRL'] sensor_data_d = data['LVDTRR'] sensor_data_a = pd.to_numeric(sensor_data_a) sensor_data_b = pd.to_numeric(sensor_data_b) sensor_data_c = pd.to_numeric(sensor_data_c) sensor_data_d = pd.to_numeric(sensor_data_d) sensor_time = data['time'] sensor_time = pd.to_numeric(sensor_time) sensor_time = sensor_time / 1000 cutFs = 5 filteredsignal_a = ncuTools.bandPassFilter(sensor_data_a, cutf=cutFs, order=5) filteredsignal_b = ncuTools.bandPassFilter(sensor_data_b, cutf=cutFs, order=5) filteredsignal_c = ncuTools.bandPassFilter(sensor_data_c, cutf=cutFs, order=5) filteredsignal_d = ncuTools.bandPassFilter(sensor_data_d, cutf=cutFs, order=5) sensor_data_a = ncuTools.mapDouble(sensor_data_a, 0.59, 0.65, 206, 196) sensor_data_b = ncuTools.mapDouble(sensor_data_b, 0.9, 0.94, 206, 196) sensor_data_c = ncuTools.mapDouble(sensor_data_c, 0.92, 1.02, 221, 216) sensor_data_d = ncuTools.mapDouble(sensor_data_d, 0.76, 0.8, 221, 216) filteredsignal_a = ncuTools.mapDouble(filteredsignal_a, 0.59, 0.65, 206, 196) filteredsignal_b = ncuTools.mapDouble(filteredsignal_b, 0.9, 0.94, 206, 196) filteredsignal_c = ncuTools.mapDouble(filteredsignal_c, 0.92, 1.02, 221, 216) filteredsignal_d = ncuTools.mapDouble(filteredsignal_d, 0.76, 0.8, 221, 216) p1 = figure(title='LVDT FL FFT', x_axis_label='Hz', y_axis_label='dB', toolbar_location="left", tools=graphTools, output_backend=renderer, tooltips=TOOLTIPS) p2 = figure(title='LVDT FR FFT', x_axis_label='Hz', y_axis_label='dB', toolbar_location="left", tools=graphTools, output_backend=renderer, tooltips=TOOLTIPS) p3 = figure(title='LVDT RL FFT', x_axis_label='Hz', y_axis_label='dB', toolbar_location="left", tools=graphTools, output_backend=renderer, tooltips=TOOLTIPS) p4 = figure(title='LVDT RR FFT', x_axis_label='Hz', y_axis_label='dB', toolbar_location="left", tools=graphTools, output_backend=renderer, tooltips=TOOLTIPS) y_overlimit = 0.05 # show y axis below and above y min and max value cutFsPlot = 10 # FIRST AXIS x_axis, y_axis = ncuTools.dbfft(sensor_time, sensor_data_a) g = p1.line(x_axis, ncuTools.bandPassFilter(y_axis, cutf=cutFsPlot, order=5), color='blue') # FIRST AXIS x_axis, y_axis = ncuTools.dbfft(sensor_time, sensor_data_b) g1 = p2.line(x_axis, ncuTools.bandPassFilter(y_axis, cutf=cutFsPlot, order=5), color='red') # FIRST AXIS x_axis, y_axis = ncuTools.dbfft(sensor_time, sensor_data_c) g2 = p3.line(x_axis, ncuTools.bandPassFilter(y_axis, cutf=cutFsPlot, order=5), color='orange') # FIRST AXIS x_axis, y_axis = ncuTools.dbfft(sensor_time, sensor_data_d) g3 = p4.line(x_axis, ncuTools.bandPassFilter(y_axis, cutf=cutFsPlot, order=5), color='green') grid = gridplot([[p1, p2], [p3, p4]], plot_width=700, plot_height=325, merge_tools=True, toolbar_location='left') #grid.toolbar.logo = None l1 = layout(grid) tab = Panel(child=l1, title="Suspension FFT", closable=True) return tab
def TK(data): TOOLTIPS = [ ("(x,y)", "($x, $y)"), ] renderer = 'webgl' graphTools = 'pan,wheel_zoom,box_zoom,zoom_in,zoom_out,hover,crosshair,undo,redo,reset,save' sensor_data = data['TKFL'] sensor_data_b = data['TKFR'] sensor_data_c = data['TKRL'] sensor_data_d = data['TKRR'] sensor_data_e = data['Speed'] sensor_data_f = data['BrakePressure'] sensor_data_g = data['GForceLat'] #LONGITUDINAL! sensor_data = pd.to_numeric(sensor_data) sensor_data_b = pd.to_numeric(sensor_data_b) sensor_data_c = pd.to_numeric(sensor_data_c) sensor_data_d = pd.to_numeric(sensor_data_d) sensor_data_e = pd.to_numeric(sensor_data_e) sensor_data_f = pd.to_numeric(sensor_data_f)*10 sensor_data_g = pd.to_numeric(sensor_data_g) cutFs = 5 filteredsignal_g = ncuTools.bandPassFilter(sensor_data_g, cutf=cutFs, order = 5) sensor_time = data['time'] sensor_time = pd.to_numeric(sensor_time) sensor_time = sensor_time/1000 p = figure(title = 'Brakes Thermocouple', x_axis_label = 's', y_axis_label = '°C', toolbar_location="left", tooltips=TOOLTIPS, output_backend=renderer, tools=graphTools, ) p1 = figure(title = 'Speed and Brakes', x_axis_label = 's', y_axis_label = 'G', toolbar_location="left", tooltips=TOOLTIPS, output_backend=renderer, tools=graphTools, x_range=p.x_range) y_overlimit = 0.1 # show y axis below and above y min and max value # FIRST AXIS p.y_range = Range1d( sensor_data.min() * (1 - y_overlimit), sensor_data.max() * (1 + y_overlimit) ) p.extra_y_ranges = {"b": Range1d( sensor_data_e.min() * (1 - y_overlimit), sensor_data_e.max() * (1 + y_overlimit) )} # Adding the second axis to the plot. p.add_layout(LinearAxis(y_range_name="b", axis_label="BAR"), 'right') p1.y_range = Range1d( filteredsignal_g.min() * (1 - y_overlimit), filteredsignal_g.max() * (1 + y_overlimit) ) p1.extra_y_ranges = {"b": Range1d( sensor_data_f.min() * (1 - y_overlimit), sensor_data_f.max() * (1 + y_overlimit) )} # Adding the second axis to the plot. p1.add_layout(LinearAxis(y_range_name="b", axis_label="BAR"), 'right') g1 = p.line(sensor_time, sensor_data, color='blue', line_width=2) g2 = p.line(sensor_time, sensor_data_b, color='red', line_width=2) g3 = p.line(sensor_time, sensor_data_c, color='orange', line_width=2) g4 = p.line(sensor_time, sensor_data_d, color='green', line_width=2) g6 = p.line(sensor_time, sensor_data_e, color='purple', y_range_name="b", line_width=2, alpha=0.5) g5 = p1.line(sensor_time, filteredsignal_g, color='green', line_width=2) g7 = p1.line(sensor_time, sensor_data_f, color='red', y_range_name="b", line_width=2) legend = Legend(items=[ ("2Hz TKFL @NCU", [g1]), ("2Hz TKFR @NCU", [g2]), ("2Hz TKRL @NCU", [g3]), ("2Hz TKRR @NCU", [g4]), ("35Hz Speed @MOTEC", [g6]), ], location=(0,0)) legend1 = Legend(items=[ ('5Hz Low Pass Filter Y axis MPU6050 @NCU', [g5]), ("35Hz Brake Pressure @MOTEC", [g7]) ], location=(0,0)) p.add_layout(legend, 'right') p1.add_layout(legend1, 'right') p.legend.click_policy = 'hide' p1.legend.click_policy='hide' p.toolbar.logo = None p1.toolbar.logo = None grid = gridplot([[p], [p1]], plot_width=1450, plot_height=325, merge_tools=True, toolbar_location='left') l1 = layout(grid) tab = Panel(child=l1, title="Brakes", closable=True) return tab
def user_equations(data): ''' Take data and process users equations in the entire database, reducing size poping inused columns. :param data: pandas dataframe containing data :return: pandas dataframe with updated data ''' data.loc[(data['RPM'] > 2000) & (data['EngineTemp'] > 84), 'HalfFan'] = 1 data.loc[(data['RPM'] < 2000) | (data['EngineTemp'] < 84), 'HalfFan'] = 0 data.loc[(data['RPM'] > 2000) & (data['EngineTemp'] > 94), 'FullFan'] = 1 data.loc[(data['RPM'] < 2000) | (data['EngineTemp'] < 94), 'FullFan'] = 0 data['A_9_map'] = programTools.bandPassFilter(data['A_9_map']) ''' sensor_data_a = data['GPSlatHW'] sensor_data_b = data['GPSlatLW'] sensor_data_c = data['GPSlongHW'] sensor_data_d = data['GPSlongLW'] sensor_data_a = pd.to_numeric(sensor_data_a) sensor_data_b = pd.to_numeric(sensor_data_b) sensor_data_c = pd.to_numeric(sensor_data_c) sensor_data_d = pd.to_numeric(sensor_data_d) gpsLat = ((data['GPSlatHW']-65536) * 65536 + data['GPSlatLW'])/10000000 gpsLong = ((data['GPSlongHW']-65536) * 65536 + data['GPSlongLW'])/10000000 ''' data['GPSLat'] = ( (data['GPSlatHW'] - 65536) * 65536 + data['GPSlatLW']) / 10000000 data['GPSLong'] = ( (data['GPSlongHW'] - 65536) * 65536 + data['GPSlongLW']) / 10000000 ''' sensor_data_a = data['GForceLat'] sensor_data_b = -data['GForceLong'] sensor_data_c = -data['gyro_z'] sensor_data_e = data['Speed'] sensor_data_a = pd.to_numeric(sensor_data_a) sensor_data_b = pd.to_numeric(sensor_data_b) sensor_data_c = pd.to_numeric(sensor_data_c) sensor_data_d = pd.to_numeric(sensor_data_d) sensor_data_e = pd.to_numeric(sensor_data_e) sensor_data_f = pd.to_numeric(sensor_data_f) ''' sensor_data = pd.to_numeric(data['SteeringAngle']) sensor_data.loc[ sensor_data > 3276.8] = sensor_data.loc[sensor_data > 3276.8] - 6553.6 data['SteeringAngle'] = sensor_data sensor_data = pd.to_numeric(data['ECU_GForceLat']) sensor_data.loc[ sensor_data > 32.768] = sensor_data.loc[sensor_data > 32.768] - 65.536 data['ECU_GForceLat'] = sensor_data cutFs = 5 data['GForceLat'] = programTools.bandPassFilter(data['GForceLat'], cutf=cutFs, order=5) data['GForceLong'] = programTools.bandPassFilter(-data['GForceLong'], cutf=cutFs, order=5) cutFs = 1 data['gyro_z'] = programTools.bandPassFilter(-data['gyro_z'], cutf=cutFs, order=5) ''' sensor_data_a = data['LVDTFL'] sensor_data_b = data['LVDTFR'] sensor_data_c = data['LVDTRL'] sensor_data_d = data['LVDTRR'] sensor_data_e = data['Speed'] sensor_data_x = -data['GForceLong'] sensor_data_y = data['GForceLat'] sensor_data_z = data['GForceVert'] sensor_data_tps = data['TPS'] sensor_data_bp = data['BrakePressure'] sensor_data_sa = data['SteeringAngle'] sensor_data_a = pd.to_numeric(sensor_data_a) sensor_data_b = pd.to_numeric(sensor_data_b) sensor_data_c = pd.to_numeric(sensor_data_c) sensor_data_d = pd.to_numeric(sensor_data_d) sensor_data_e = pd.to_numeric(sensor_data_e) sensor_data_sa = pd.to_numeric(sensor_data_sa) ''' cutFs = 12 data['LVDTFL'] = programTools.bandPassFilter(data['LVDTFL'], cutf=cutFs, order=5) data['LVDTFR'] = programTools.bandPassFilter(data['LVDTFR'], cutf=cutFs, order=5) data['LVDTRL'] = programTools.bandPassFilter(data['LVDTRL'], cutf=cutFs, order=5) data['LVDTRR'] = programTools.bandPassFilter(data['LVDTRR'], cutf=cutFs, order=5) ''' filteredsignal_x = ncuTools.bandPassFilter(sensor_data_x, cutf=5, order=5) filteredsignal_y = ncuTools.bandPassFilter(sensor_data_y, cutf=5, order=5) filteredsignal_z = ncuTools.bandPassFilter(sensor_data_z, cutf=5, order=5)''' data['LVDTFL'] = programTools.mapDouble(data['LVDTFL'], 0.59, 0.65, 206, 196) data['LVDTFR'] = programTools.mapDouble(data['LVDTFR'], 0.9, 0.94, 206, 196) data['LVDTRL'] = programTools.mapDouble(data['LVDTRL'], 0.92, 1.02, 221, 216) data['LVDTRR'] = programTools.mapDouble(data['LVDTRR'], 0.76, 0.8, 221, 216) ''' filteredsignal_a = ncuTools.mapDouble(filteredsignal_a, 0.59, 0.65, 206, 196) filteredsignal_b = ncuTools.mapDouble(filteredsignal_b, 0.9, 0.94, 206, 196) filteredsignal_c = ncuTools.mapDouble(filteredsignal_c, 0.92, 1.02, 221, 216) filteredsignal_d = ncuTools.mapDouble(filteredsignal_d, 0.76, 0.8, 221, 216)''' diff1 = np.diff(data['LVDTFL']) / np.diff(data['time']) diff2 = np.diff(data['LVDTFR']) / np.diff(data['time']) diff3 = np.diff(data['LVDTRL']) / np.diff(data['time']) diff4 = np.diff(data['LVDTRR']) / np.diff(data['time']) diff1 = np.append(diff1, 0) diff2 = np.append(diff2, 0) diff3 = np.append(diff3, 0) diff4 = np.append(diff4, 0) data['diffLVDTFL'] = diff1 data['diffLVDTFR'] = diff2 data['diffLVDTRL'] = diff3 data['diffLVDTRR'] = diff4 #diffdata_a = ncuTools.bandPassFilter(diffdata_a, cutf=cutFs, order=5) #diffdata_b = ncuTools.bandPassFilter(diffdata_b, cutf=cutFs, order=5) #diffdata_c = ncuTools.bandPassFilter(diffdata_c, cutf=cutFs, order=5) #diffdata_d = ncuTools.bandPassFilter(diffdata_d, cutf=cutFs, order=5) altFront = data['LVDTFL'] / 2 + data['LVDTFR'] / 2 altRear = data['LVDTRL'] / 2 + data['LVDTRR'] / 2 cutFsAlt = 5 data['altFront'] = programTools.bandPassFilter(altFront, cutf=cutFsAlt, order=2) data['altRear'] = programTools.bandPassFilter(altRear, cutf=cutFsAlt, order=2) data = data.drop(columns=[ 'GPSlatHW', 'GPSlongHW', 'GPSlatLW', 'GPSlongLW', 'max_enable', 'CAN_ID', 'CAN_byte[0]', 'CAN_byte[1]', 'CAN_byte[2]', 'CAN_byte[3]', 'CAN_byte[4]', 'CAN_byte[5]', 'CAN_byte[6]', 'CAN_byte[7]', 'A_1', 'A_4', 'A_5', 'A_6', 'A_9', 'A_1_map', 'A_4_map', 'A_5_map', 'A_6_map', 'LVDTFLmap', 'LVDTFRmap', 'LVDTRRmap', 'LVDTRLmap', 'O_1', 'O_2', 'O_3' ]) data = data.dropna(axis=1, how='all') return data
def suspHisto(data): TOOLTIPS = [ ("(x,y)", "($x, $y)"), ] renderer = 'webgl' graphTools = 'pan,wheel_zoom,box_zoom,zoom_in,zoom_out,hover,crosshair,undo,redo,reset,save' FrontMotionRatio = 1.05 RearMotionRatio = 0.98 sensor_data_a = data['LVDTFL'] sensor_data_b = data['LVDTFR'] sensor_data_c = data['LVDTRL'] sensor_data_d = data['LVDTRR'] sensor_data_e = data['Speed'] sensor_data_a = pd.to_numeric(sensor_data_a) sensor_data_b = pd.to_numeric(sensor_data_b) sensor_data_c = pd.to_numeric(sensor_data_c) sensor_data_d = pd.to_numeric(sensor_data_d) sensor_data_e = pd.to_numeric(sensor_data_e) sensor_time = data['time'] sensor_time = pd.to_numeric(sensor_time) sensor_time = sensor_time / 1000 cutFs = 1 / 0.08 filteredsignal_a = ncuTools.bandPassFilter(sensor_data_a, cutf=cutFs, order=5) filteredsignal_b = ncuTools.bandPassFilter(sensor_data_b, cutf=cutFs, order=5) filteredsignal_c = ncuTools.bandPassFilter(sensor_data_c, cutf=cutFs, order=5) filteredsignal_d = ncuTools.bandPassFilter(sensor_data_d, cutf=cutFs, order=5) sensor_data_a = ncuTools.mapDouble(sensor_data_a, 0.59, 0.65, 206, 196) * FrontMotionRatio sensor_data_b = ncuTools.mapDouble(sensor_data_b, 0.9, 0.94, 206, 196) * FrontMotionRatio sensor_data_c = ncuTools.mapDouble(sensor_data_c, 0.92, 1.02, 221, 216) * RearMotionRatio sensor_data_d = ncuTools.mapDouble(sensor_data_d, 0.76, 0.8, 221, 216) * RearMotionRatio #filteredsignal_a = ncuTools.mapDouble(filteredsignal_a, 0.59, 0.65, 206, 196) #filteredsignal_b = ncuTools.mapDouble(filteredsignal_b, 0.9, 0.94, 206, 196) #filteredsignal_c = ncuTools.mapDouble(filteredsignal_c, 0.92, 1.02, 221, 216) #filteredsignal_d = ncuTools.mapDouble(filteredsignal_d, 0.76, 0.8, 221, 216) diffdata_a = np.diff(sensor_data_a) / np.diff(sensor_time) diffdata_b = np.diff(sensor_data_b) / np.diff(sensor_time) diffdata_c = np.diff(sensor_data_c) / np.diff(sensor_time) diffdata_d = np.diff(sensor_data_d) / np.diff(sensor_time) diffdata_a = ncuTools.bandPassFilter(diffdata_a, cutf=cutFs, order=5) diffdata_b = ncuTools.bandPassFilter(diffdata_b, cutf=cutFs, order=5) diffdata_c = ncuTools.bandPassFilter(diffdata_c, cutf=cutFs, order=5) diffdata_d = ncuTools.bandPassFilter(diffdata_d, cutf=cutFs, order=5) p1 = figure(title='LVDT FL DUMPER HISTOGRAM', output_backend=renderer, tools=graphTools, tooltips=TOOLTIPS) p2 = figure(title='LVDT FR DUMPER HISTOGRAM', output_backend=renderer, tools=graphTools, tooltips=TOOLTIPS) p3 = figure(title='LVDT RL DUMPER HISTOGRAM', output_backend=renderer, tools=graphTools, tooltips=TOOLTIPS) p4 = figure(title='LVDT RR DUMPER HISTOGRAM', output_backend=renderer, tools=graphTools, tooltips=TOOLTIPS) # Normal Distribution hist_a, edges_a = np.histogram(diffdata_a, density=True, bins='auto') hist_b, edges_b = np.histogram(diffdata_b, density=True, bins='auto') hist_c, edges_c = np.histogram(diffdata_c, density=True, bins='auto') hist_d, edges_d = np.histogram(diffdata_d, density=True, bins='auto') p1.quad(top=hist_a, bottom=0, left=edges_a[:-1], right=edges_a[1:], fill_color="blue", line_color="blue") p2.quad(top=hist_b, bottom=0, left=edges_b[:-1], right=edges_b[1:], fill_color="red", line_color="red") p3.quad(top=hist_c, bottom=0, left=edges_c[:-1], right=edges_c[1:], fill_color="orange", line_color="orange") p4.quad(top=hist_d, bottom=0, left=edges_d[:-1], right=edges_d[1:], fill_color="green", line_color="green") #p1.x_range= Range1d(-300, 300) #p2.x_range = Range1d(-300, 300) #p3.x_range = Range1d(-300, 300) #p4.x_range = Range1d(-300, 300) p1.y_range.start = 0 p2.y_range.start = 0 p3.y_range.start = 0 p4.y_range.start = 0 grid = gridplot([[p1, p2], [p3, p4]], plot_width=700, plot_height=325, merge_tools=True, toolbar_location='left') l1 = layout(grid) tab = Panel(child=l1, title="Suspension Histogram", closable=True) return tab