Project

Data Analysis using Python

Code for data analysis

import matplotlib.pyplot as plt
import math
import numpy as np


try: #Try-Except Syntax. If an error is found in TRY it runs the EXCEPT command
 file = open(\'engine_data.out\',\'r\')
except:
	print(\' >>> File cannot be recognized. Please check again <<< \')

value=[]
for line in file:
	if \'#\' not in line: # The first 4 lines has #. So we are excluding it 
		value.append(line.split()) # Splitting the values
	
column=np.transpose(value) # Converting Row to column for making into float values
column=column.astype(float)

name=[\'Crank\',\'Pressure\',\'Max_Pres\',\'Min_Pres\',\'Mean_Temp\',\'Max_Temp\',\'Min_Temp\',\'Volume\',\'Mass\',\'Density\',\'Integrated_HR\',\'HR_Rate\',\'C_p\',\'C_v\',\'Gamma\',\'Kin_Visc\',\'Dyn_Visc\']
parameter=[\'crank angle = 0\',\'pressure= 1\',\'p_max = 2\',\'p_min = 3\',\'t_mean = 4\',\'t_max = 5\',\'t_min = 6\',\'volume = 7\',\'mass = 8\',\'density = 9\',\'integrated_HR = 10\',\'HR rate = 11\',\'C_p = 12\',\'C_v = 13\',\'gamma = 14\',\'kinematic viscosity = 15\',\'dynamic viscosity = 16\']
print(parameter)

# Getting Inputs
print(\"please enter X axis parameter:\\n\")
x=int(input())

print(\"please enter Y axis parameter:\\n\")
y=int(input())


work=[]
v = column[7,:]
p = column[1,:]*pow(10,6)  # converting the pressure into Pascal

for i in range(0,8664):
	work.append((v[i+1]-v[i])*(p[i+1]+p[i])*0.5)

work_done=0
for j in range(0,len(work)):
	work_done=work_done+work[j]

print(\'Work Done: \',round(work_done,3),\'J\')


speed=1500/60
power=work_done*speed
print(\'Power: \',round(power/1000,3),\'KW\')


m_f=20*pow(10,-6) 
sfc=(m_f*3600)/power
print(\'Specific Fuel Consumption: \',sfc,\'gm/KWhr\')

# Graph
plt.figure()
plt.plot(column[y,:],column[x,:],linewidth=2,color=\'blue\')
plt.xlabel(name[x],color=\'red\',fontsize=10)
plt.ylabel(name[y],color=\'red\',fontsize=10)
plt.title(name[x]+\'  V  \'+name[y],color=\'green\',fontsize=12)
plt.savefig(name[x]+\'_v_\'+name[y]+\'.png\')
plt.show()

Work Done: 500.587 J
Power: 12.515 KW

Specific Fuel Consumption: 5.753249971073308e-06 gm/KWhr

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.