Project

Python Report on: - Code to create a Data Visualizer tool

Objective: - Write a code to create a data visualizer tool.

  • Before you even begin a Data analysis project, you must define the problem you’re trying to solve. At this stage, you should be clear about the objectives of your project.
  • Python is a general-purpose programming language and is widely used for data analytics. Almost all cloud data platforms offer Python support and often new features become available in the Python program first.
  • To start programming this problem we have to import matplotlib.pyplot and import math libraries first.
  • Then we will create empty arrays for storing the various values of different properties of engines.
  • After that, we will create a \'for loop\' and then we will append all the values of each individual engine properties.
  • we have used except the command so that if the data file mentioned above is not present in the folder then it will be print \"File not recognized. Please provide a valid CONVERGE output file\".
  • Float and line.split command helps us it detecting required data for specific engine values in their respective columns.
  • Then we have plotted the required plots of pressure vs. volume and max_pressure vs. crank angle.
  • And lastly, we calculated values of area under PV, Power of engine in [KW & Hp] and specific fuel consumption in g/kWh.

Step 1: Wrote code to visualize the engine data file.

\"\"\"
Code by Ravi Thakur
Subject: Write a program to create a data visualizer tool.

\"\"\"

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

# Data extracting

Crank = []
pressure = []
max_pressure = []
min_pressure = []
mean_temperature = []
max_temperature = []
min_temperature = []
volume = []
mass = []
density = []
integrate_hr = []
hr_rate =[]
c_p = []
c_v = []
gamma = []
kin_visc = []
dyn_visc = []

ct = 1

try: 
	open(\'engine_data.out\')

except Wrrong_input_file: 
	print(\'File not recognized. Please provide a valid CONVERGE output file\')

for line in open(\'engine_data.out\'):
	if \'#\' not in line:
		Crank.append(float(line.split()[0]))
		pressure.append(float(line.split()[1]))
		max_pressure.append(float(line.split()[2]))
		min_pressure.append(float(line.split()[3]))
		mean_temperature.append(float(line.split()[4]))
		max_temperature.append(float(line.split()[5]))
		min_temperature.append(float(line.split()[6]))
		volume.append(float(line.split()[7]))
		mass.append(float(line.split()[8]))
		density.append(float(line.split()[9]))
		integrate_hr.append(float(line.split()[10]))
		hr_rate.append(float(line.split()[11]))
		c_p.append(float(line.split()[12]))
		c_v.append(float(line.split()[13]))
		gamma.append(float(line.split()[14]))
		kin_visc.append(float(line.split()[15]))
		dyn_visc.append(float(line.split()[16]))


pyplot.plot(Crank,pressure, color=\'blue\',linewidth=3)
pyplot.xlabel(\'Crank angle, deg\')
pyplot.ylabel(\'Pressure, Bar\')
pyplot.title(\'PV daigram\')
pyplot.grid()
pyplot.show()
pyplot.plot(volume,pressure,linewidth=3)
pyplot.xlabel(\'Volume, m^3\')
pyplot.ylabel(\'Pressure, Bar\')
pyplot.title(\'PV daigram\')
pyplot.grid()
pyplot.show()



area = np.trapz(pressure,volume)
print(\'Area under PV = \', area)
rpm = 1500
rps = rpm/60
powerwatt = area*rps*1000
powerhp = powerwatt/0.746
print(\'Power of engine output = \', powerwatt, \'in kwatt,when rpm is 1500\')
print(\'power of engine is\', powerhp,\'in horsepower\')

sfc = (20*pow(10,-6)*3600)/(0.08*powerwatt)
print(\'specific fuel consumption is\', sfc, \'in g/kwh\')



Step 2: Results

The plot shows maximum pressure vs. crank angle graph

The plot shows a pressure vs. volume graph

The image shows the area under PV, Power of engine in [KW & Hp] and specific fuel consumption in g/kWh.

Step 3: Conclusion

  • We understood how to import data sets for each and every value shown in the Engine data file.
  • We learn to extract data from data use them for specific purposes.
  • We understood how to Summarize data in different plots.
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.