Project

data analysis using python

Data analysis using python

OBJECTIVES:

1) Read data from file.

2) Checking for file compatibility

3) Plotting data column wise and saving them using file header

4) Plotting data from one column against data from another, labelling them using header data

5) Calculating area under a curve (pv diagram)

6) Calculating power output of the engine using the area

7) Calculating Specific Fuel consumption

Parse means to \'\'resolve (a sentence) into its component parts and describe their syntactic roles\'\'. In computing, parsing is \'an act of parsing a string or a text\'. [Google Dictionary]File parsing in computer language means to give a meaning to the characters of a text file as per the formal grammar. . A parser is a program that parses the text files.

Stepwise Program to create a data visualizer tool:

#Importing libraries
import matplotlib.pyplot as graph
import numpy as np 
from numpy import trapz as trp

#Compatability check
try:
  f=open(\'engine_data.out\',\'r\')

except FileNotFoundError:
  print(\'File not recognized. Please provide a valid CONVERGE output file!\')
  sys.exit()

#input
file = \'engine_data.out\'
count = 0
count_header = 0
column_title = []
column_units = []
for line in open(file,\'r\'):
	if \'#\' not in line:
		count = count + 1
		columns = len(str.split(line))
	else:
		count_header = count_header +1
		if count_header == 3:
			line_content = str.split(line)
			for i in range(0,len(line_content)):
				column_title.append(line_content[i])
		elif count_header == 4:
			line_content = str.split(line)
			for i in range(0,len(line_content)):
				column_units.append(line_content[i])


if (count_header < 4 or count < 1 or columns < 8):
	print(\'Invalid data file\')
else:
	data = np.zeros((count,columns,1))
	row = 0
	for line in open(file,\'r\'):
		if \'#\' not in line:		
			column = 0
			data_line = str.split(line)
			while (column < columns):
				data[row,column] =  float(data_line[column])
				column = column + 1
			row = row + 1

	column_number = 1
	while (column_number <= columns):
		graph.plot(data[:,column_number-1])
		graph.ylabel(column_title[column_number]+column_units[column_number])
		graph.savefig(column_title[column_number]+\'.png\')
		graph.figure()
		column_number = column_number + 1


	x_column_number = 8
	y_column_number = 2
	x_data = np.array(data[:,x_column_number-1])
	y_data = np.array(data[:,y_column_number-1])
	graph.plot(x_data,y_data)
	graph.xlabel(column_title[x_column_number]+column_units[x_column_number])
	graph.ylabel(column_title[y_column_number]+column_units[y_column_number])
	graph.savefig(column_title[y_column_number]+\' VS \'+column_title[x_column_number]+\'.png\') 


	area = trp(y = y_data.transpose(), x = x_data.transpose())
	print(\'Area under pv diagram:\',area,\'(MJ)\') 
	#Power in kw = Nm * RPM / 9550
	RPM = 1500
	power = area * 1e+06*RPM/(9550)
	print(\'Power:\',power,\'(kw)\')
	fuel_per_stroke = 20*1e-06
	fuel_per_sec = fuel_per_stroke*RPM*60
	Spec_fuel_cons = fuel_per_sec/ (power * 1e+03)
	print(\'Specific Fuel Consumption:\',Spec_fuel_cons,\'(g/J)\')
	

RESULTS:

PRESSURE(MPa) VS VOLUME(m^3)

FOLDER SHOWING ALL CURVES:

folder link:

https://drive.google.com/open?id=1Rl1I9rnrRgTkOzUwYu-93up9nKF6wgpK

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.