Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # import pandas as pd
- # import numpy as np
- # from numpy import array
- # import matplotlib.pyplot as plt
- # data = pd.read_csv("Multi_P1FWM_turbo_failure_deviation_ano.csv", header=0)
- # train_data = data.iloc[:,5:405]
- # # print(train_data.head(2))
- # print(train_data.shape)
- # newdata = array(train_data)
- # print(newdata.shape)
- # newdata = newdata[1,:]
- # print(newdata.shape)
- # print(newdata)
- import numpy as np
- import pandas as pd
- from PIL import Image
- import plotly.plotly as py
- import plotly.figure_factory as ff
- from numpy import array
- import matplotlib.pyplot as plt
- import argparse
- parser = argparse.ArgumentParser()
- parser.add_argument( '-a', "--anonymous", action='store_true', default=False, help='Hide axes' )
- parser.add_argument( '-t', "--truck", type=str, default=None, help='PLot one truck ID' )
- parser.add_argument( '-f', "--filename", type=str, default="Multi_P1FWM_turbo_failure_deviation_ano.csv", help='CSV filename' )
- parser.add_argument( '-n', "--normalise", action='store_true', default=False, help='Normalise' )
- parser.add_argument( "--max_pics", type=int, default=16, help='Max histograms on a plot' )
- parser.add_argument( "--cols", type=int, default=4, help='Number of histogram columns in plot' )
- parser.add_argument( "--rows", type=int, default=None, help='Number of rows to read from CSV file' )
- parser.add_argument( "--start", type=int, default=0, help='Start histogram' )
- parser.add_argument( "--trucks", type=str, default=None, help='Multiple chassis IDs, comma seperated' )
- args = parser.parse_args()
- df = pd.read_csv("Multi_P1FWM_turbo_failure_deviation_ano.csv")
- vehicle_1 = df[df['VEHICLE_ID'] == 1]
- vehicle_2 = df[df['VEHICLE_ID'] == 2]
- vehicle_3 = df[df['VEHICLE_ID'] == 3]
- vehicle_4 = df[df['VEHICLE_ID'] == 4]
- vehicle_5 = df[df['VEHICLE_ID'] == 5]
- #print(vehicle_1)
- vehicle_1_time = vehicle_1.SEND_DATETIME
- vehicle_2_time = vehicle_2.SEND_DATETIME
- vehicle_3_time = vehicle_3.SEND_DATETIME
- vehicle_4_time = vehicle_4.SEND_DATETIME
- vehicle_5_time = vehicle_5.SEND_DATETIME
- #print(vehicle_1_time)
- new = df["SEND_DATETIME"].str.split(" ",n=1,expand=True)
- df["Date"] =new[0]
- df["Time"] =new[1]
- df.drop(columns=["SEND_DATETIME"], inplace= True)
- # df.dropna(inplace= True)
- # df = df.join(df['SEND_DATETIME'].str.split(',',expand=True).add_prefix('Time'))
- #print(df.shape)
- #print(df)
- data = array(df)
- # print(data)
- #print(type(data))
- #print(data[0,4:404])
- print('Rows: %d' %data.shape[0])
- print('Cols: %d' %data.shape[1])
- num_pics = data.shape[0]
- if num_pics > args.max_pics:
- st = num_pics - args.max_pics
- num_pics = args.max_pics
- print(num_pics)
- sp =1
- n = 3
- cols = args.cols
- rows = int(num_pics/cols)+ 1*((num_pics % cols)!=0)
- nn = rows * cols
- pc = 0
- fig = plt.figure(figsize=(cols*3, rows*3)) #plt.figure(figsize=(sz,sz))
- plt.subplots_adjust( hspace=0.7, wspace=0.5 )
- ax = fig.add_subplot(rows,cols,sp)
- im = data[13,4:404]
- im = np.reshape(im,(20,20))
- im = im.astype(int)
- # print(im.shape)
- im = np.flipud(im)
- # print(im)
- if args.normalise:
- _min = 0
- _max = 1
- im += -(np.min(im))
- im /= np.max(im) / (_max - _min)
- im_masked = np.ma.masked_where(im == 0 , im)
- plt.imshow(im_masked,interpolation='none',cmap="plasma")
- ax.set_aspect('equal')
- ax.get_xaxis().set_ticks([0,19])
- ax.get_yaxis().set_ticks([])
- ax.set_xticks(np.arange(-.5, 19, 1), minor=True);
- ax.set_yticks(np.arange(-.5, 19, 1), minor=True);
- ax.grid(which='minor', color='w', linestyle='-', linewidth=1)
- if not args.anonymous:
- ax.set_xlabel( "engine speed" )
- ax.set_ylabel( "engine torque" )
- plt.colorbar(orientation='vertical', ax=ax, format='%.1f', fraction=0.04)
- else:
- plt.colorbar(orientation='vertical', ax=ax, ticks=[])
- plt.show()
- #print(a)
- #print(a.shape)
- # a = a.reshape(20,20)
- # print(a.shape)
- # plt.hist(a, 20, density=1,alpha=0.75)
- # plt.ylabel('engine torque')
- # plt.xlabel('engine speed')
- # # plt.title('vehicle_id')
- # # plt.grid(True)
- # # plt.show()
- # xx = a[:19]
- # yy = a[19:]
- # #plt.hist2d(xx,yy,bins=20,cmap=plt.cm.BuGn_r)
- # plt.figure(2)
- # plt.plot(xx,'bo',yy,'k')
- # plt.show()
- # nn = [go.Histogram2d(x=xx,y=yy)]
- # py.iplot(nn)
- # plt.show()
- # plt.figure(3)
- # # plt.hexbin(xx,yy,gridsize=(15,10),cmap='Blues')
- # # cb=plt.colorbar
- # # plt.show()
- # hist_data = [xx, yy]
- # group_labels=['a','b']
- # fig = ff.create_distplot(hist_data,group_labels,bin_size=.2)
- # py.iplot(fig)
- # print(xx)
- # print(yy)
- # plt.hist(a,bins=20)
- # plt.show()
- # newdata = df[:,5:]
- # print(newdata.shape)
- # print(newdata)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement