Project

data analysis by python

Aim:

  • Your script should take column numbers as the input and plot the respective columns as separate images
  • Each file should be saved by the name of the column
  • The plot labels should be extracted from the file. If, I request for a plot between column 1 (crank angle) and column 8(volume), then the label information should automatically be extracted and must appear as labels in the plots. THIS SHOULD NOT BE DONE MANUALLY
  • Calculate the area under the P-V diagram. P is in column 2 and V is in column 8.
  • Calculate the power output of this engine. Assume that RPM is 1500
  • This engine consumed 20 micro grams of fuel (per 1 stroke cycle). Calculate its specific fuel consumption

Introduction:

python is high level programming lanuguage used for general purpose programming which also supports for structed and object oriented programming. data analysis of any particular system have large number of data with is very difficult, hence python is way to in simple to analysis each and very parameter at very less time.

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


x=int(input(\"type column number which is to be plotted on y-axis\\n\"))
y=int(input(\"type column number which is to be plotted on x-axis\\n\"))

columns=[x,y]
file=\'engine_data.out\'
t
if\".out\"in file:
	print(\"file compatible\")
	def filereader(file,columns):
		file2open=file
		x=columns[0]
		y=columns[1]
		with open(file2open)as data:
			column1=[]
			column2=[]
			for line in data:
				if \"crank\"in line:
					column_name=line.split()
				elif\"#\" not in line:
					column1.append(float(line.split()[x-1]))
					column2.append(float(line.split()[y-1]))
			return(column_name,column1,column2)
		column_name,column1,column2=filereader(file,columns)
		plt.title(column_name[columns[0]]+\'vs\'+column_name[columns[1]]+\'plot\')
		plt.plot(column2,column1)
		plt.xlabel(column_name[columns[1]])
		plt.ylabel(column_name[columns[0]])
		plt.savefig(column_name[columns[0]]+\'vs\'+[columns_name[1]])
		plt.show()
		if columns[0]==2 and columns[1]==8 or columns[0]==8 and columns[1]==2:
			print(\"results\")
			a=np.trapz(column1,column2,axis=0)
			print(f\'area under the{column_name[columns[0]]}-{column_name[columns[1]]} curve is {a*1000}KJ\')
			rpm=1500
			power=((2*3.14*rpm*a*1000)/60)
			print(f\'power output of this engine is {power} Mw\')
			fcps=20
			sfc(fcps*rpm*pow(10,-6)*3600)/(1000*power*60)
			print(f\'specific fuel consumption of engine is {sfc}kg/kwh\')
		else:
			print(\"file not recongnized.please provide valid CONVERGE output file\")

\"\"

\"\"

\"\"

Expalination:

1] imported requried modules for program

2] data file of engine data is imported by command open.

3] hence columns as to present by coding(not manually) defined columns numbers called 1,2ect

4] with respect to crank and columns 1 and 8 plot as done

5] pressure vs volume plot as done by plot command

6] finally power, sfc ect found as shown in above figures.

Conculsion:

program is written as for given condition and excuted and obtained 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.