Challenge

Week 6 - Data analysis

data analysis:

objective of project:

  • data visualizer:
  1. the python code must take the column numbers as the inputs and plot the respective column as separate images
  2. each file have to besaved by its respective name of the coloum
  3. the plot labels should be extracted from the file. as, if i want to plot a graph betweem coloum number1 and 3 then it should extract the data autometically
  • compatability check:

code must be executed sucessfully ,if not the it must show that a non compatible file is provided as input the disply showld be like 'file not recognised please provide a valid converge output file'

  • basic performance calculation
  1. calculate the area under the P-V diagram. p is in the coloumn 2 and v is in the column 8
  2. calculate the power output of the engine at 1500rpm
  3. calculate the specific fuel consuption as this engine consumes 20micro grams of fuel per stroke

python code steps:

  1. import required libraries 
  2. save the python file and the engine data output in the same folder as the python file reads the data and if not stored the code will not be executed
  3. file gets opened and read by the programme
  4. then the parameters are stored in the empty arrays created and each array given a name in the programme
  5. the formula to calculate the power, specific fuel consuption is given in the programme to calculate from the data
  6. these parameters are calculated and graphs are displayed at the end of the programme

python code:

import matplotlib.pyplot as plt
import numpy as np
from numpy import trapz

fname = input("enter the filename:   ")

if fname == 'engine_data.out':
	print('file is valid')
else:
	print('file is invalid')
	exit()

def compatibility_check(a):
	if 'CONVERGE' not in a:
		print('please provide converge output file to process')
		exit()

	else:
		print('compatibility check is sucessful')
		
		pass
FILE= []

for line in open(fname):
	if '#' in line:
		FILE.append(line.split())

compatibility_check(FILE[0])
noc = len(FILE[1])
head = len(FILE[2])
col_no = []
col_val = []
col_units = []

z = FILE[1].index('column')
for i in range(z,noc-1):

	col_no.append(i)

for j in FILE[2]:

	if j is not '#':

		col_val.append(j)

for k in FILE[3]:

	if k is not '#':

		col_units.append(k)

print('data available are:')

for a in range(0,len(col_no)):

	print(col_no[a],col_val[a],col_units[a])

xaxis = int(input('Enter xaxis column no:'))-1
yaxis = int(input('Enter yaxis column no:'))-1

x = []
y = []

for line in open(fname):

	if '#' not in line:

		x.append(float(line.split()[xaxis]))
		y.append(float(line.split()[yaxis]))

plt.plot(x,y,linewidth=1.5)
plt.xlabel(col_val[xaxis])
plt.ylabel(col_val[yaxis])
plt.show()

pressure = []
vol = []

for line in open(fname):
	if '#' not in line:

		pressure.append(float(line.split()[1]))
		vol.append(float(line.split()[7]))

Pressure = 1e6*np.array(pressure)
Volume = np.array(vol)
area = np.trapz(Pressure,Volume)
print('workdone =',area, 'joules')
cyclepersec = 750/60
power = area*(cyclepersec/1000)
print('power=',power,'kw')
mass_flow = 20e-6
sfc = mass_flow*3600/power
print('specific fuel consumption =',sfc,'g/kwh')

#******************************************************************************

results and discussions:

  1. the programme was sucessfull in reading and importing data from the file
  2. the calculations werw done and results are obtained

plot obtained between min_pressure and crank

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.