Challenge

Week 6 - Data analysis

Objective:

Write a program to evaluate the data analysis using python code

File: engine_file.out

Procedure:

1.import matplotlib and scipy libraries

2.try():To test the block of code for errors

3.Except():This block lets you handle the error

4.open():open the file in reading ’r’ mode

5.for loop is used to iterate the data

6.split():Dividing the data

7.float() it reads the data in a decimal format

8.append() add each and every values to an empty list

9.{} this is a replacement operator

10.plot() plot the graphs

'''
   Demonstrating file parasing in Python
'''
import matplotlib.pyplot as plt
from scipy.integrate import simps

line_count=1
try:
	file=open('engine_data.out')
	print('Successfully opened the file \n')
except:
	print('File not found \n')

print('The plot parameters given below are in series \n')
print('1-crank','2-Pressure','3-Max_pressure', '4-Min_pressure','5-Mean_temperature','6-Max_temperature','7-Min_temperature','8-volume','9-Mass','10-Density','11-Integrated_HR','12-HR_rate','13-C_p','14-C_V','15-Gamma','16-Kin_Viscocity','17-Dynamic_Viscocity')

First_column=int(input('Enter the fisrt coloumn (choose number b/w "1" & "17"):'))
Second_column=int(input('Enter the second column number (choose differrnt from first column number):'))		

print('\n')

column_1_data=[]
column_2_data=[]

for line in open('engine_data.out','r'):
	if line_count is 3:
		data1=line.split()[First_column-1]
		data2=line.split()[Second_column-1]
	if '#' not in line:
		coloumn_1_data.appned(float(line.split()[First_column-1]))	
		coloumn_2_data.appned(float(line.split()[Second_column-1]))

	line_count+=1

# Work done is given by area under the Curve
area=float(simps(column_1_data,column_2_data))
print('area:{}\n'.format(area))

#Inputs
rpm=1500
speed=rpm/60
power=area*speed
print('power:{}\n'.format(power))

mass_of_fuel=20*pow(10,-6)
specific_fuel_consumption-mass_of_fuel/power
print('specific fuel consumption:{}\n'.format(specific_fuel_consumption))

#plotting
plt.plot(coloumn_1_data,coloumn_2_data)
plt.xlabel(data1)
plt.ylabel(data2)
print('           {} vs {}'.format(data1,dat2))
plt.show()

Results:

Area, power and Specific fuel consumption results

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.