Data Analysis using Python

OBJECTIVE – We have to write the script which should take column numbers as the input and plot the respective columns as separate images. The plot labels should be extracted from the file. If there is a request for a plot between column 1(crank angle) and column 8(volume) , then label information should automatically be extracted and must appear as labels in the plots.Also to calculate the area under the P-V diagram. P is in the column 2 and V is in column 8,the power output of this engine(Assume RPM is 1500) and its specific fuel consumption.


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

Crank = []
Pressure = []
Max_Pres = []
Min_Pres = []
Mean_Temp = []
Max_Temp = []
Min_Temp = []
Volume = []
Mass = []
Density = []
Integrated_HR = []
HR_Rate = []
C_v = []
C_p = []
Gamma = []
Kin_Visc = []
Dyn_Visc =[] 
label = []
Units = []

filename = input('Enter a Converge output file: ')
		file = open(filename,'r')
		line_count = 1
		for line in file:
				if '#' in line:
					if line_count is 3:
							for j in range(1,18):

					if line_count is 4:
							for k in range(1,18):

					line_count = line_count + 1
				if '#'	not in line:

		Inp = np.array([[0], Crank, Pressure, Max_Pres, Min_Pres, Mean_Temp, Max_Temp, Min_Temp, Volume, Mass, Density, Integrated_HR, HR_Rate, C_v, C_p, Gamma, Kin_Visc, Dyn_Visc])
		print('\n Enter the Engine Parameters: ')

		x = input("Engine parameter the x axis: ")
		x = int(x)

		y = input("Engine parameter on the y axis: ")
		y = int(y)			

		plt.Title(str(label[x-1]) + ' v ' + str(label[y-1]) + 'plot')
		plt.xlabel(str(label[x-1]) + str(Units[x-1]))
		plt.ylabel(str(label[y-1]) + str(Units[y-1]))
		plt.savefig(str(label[x-1]) + 'v' + str(label[y-1]))

		if x == 2 and y == 8 or x == 8 and y == 2:
			rpm = input('\nWhat is the engine rpm? ')
			rpm = float(rpm)
			r = input('\nWhat is the fuel consumption?')
			r = float(r)
			T = np.trapz(Inp[x], Inp[y])
			P = (2*math.pi*rpm*T)/(60)
			SFC = ((r*rpm)*(pow(10,-6))*(3600))/(P*1000*60)
			print('\nArea under the pv plt = t = ',T,'N-m')
			print('\nPower = ', P,'Mw')
			print('\nSFC = ', SFC, 'g/KW-h')

		print('Enter a valid Converge output file')			

The P-V plot obtained by the code.

The command line arguments inputs to obtain the results:


The code is written such that the rpm and fuel consumption values can be input for different running conditions.Sublime text is modified with a package such that it is able to take in user input and read the input to provide the output. The results for the Power and SFC calculations are as above and the P-V plot is added below.

For any other variables, the area under the plot isn’t a case of study and it will not be printed as part of the output.

As we can see, the area under the graph and subsequent calculations haven’t been done for this case plotting crank angle and pressure.

The result as obtained from this.


Finally the script is written such that the file must be an output file from Converge. If not an error will be displayed.

The script has been written to be modular and find any data that the user required from the data file.

Projects by Habishek Umapathy

AIM – To run a pipe flow simulation with an inlet Reynolds number of 100, 1000 and 10000. For each of these cases do the following Place the line probes at 95%, 90%, 85%of the pipe length. Compare the normalized velocity profile at each of these locations. N Read more

  OBJECTIVE – To write a program to perform curve fitting.   Curve Fitting is the process of constructing a curve or mathematical functions, which possess the closest proximity to the real series of data. By curve fitting, we can mathematically constr Read more

The Newton Raphson method is an iterative technique that is used to find out the roots of a real valued function. It uses the idea that a continuous and differentiable function can be approximated by a straight-line tangent to it. In this case Newton Raphson method is Read more

OBJECTIVE – To write a program to simulate the transient behaviour of a simple pendulum and to create an animation of its motion.   PROCEDURE – In Engineering, ODE is used to describe the transient behavior of a system. A simple example is a pendulum Read more

OBJECTIVE - To write a code for P_V diagram of an Otto cycle and calculate thermal efficiency




  • Initially state variables p1,t1,t3 and gamma a Read more

OBJECTIVE - 1. Write a function that extracts the 14 co-efficient and calculates the enthalpy, entropy and specific heats for all the species in the data file. Calculate the molecular weight of each species and display it in the command window. Plot the Cp, Ent Read more

OBJECTIVE - Write a code in MATLAB to optimise the stalagmite function and find the global maxima of the function. PROCEDURE- The genetic algorithm is a method for solving both constrained and unconstrained optimization problems that is based on natural sele Read more

OBJECTIVE – To write code to fit a linear and cubic polynomial for the Cp data and plot the linear and cubic fit curves along with the raw data points.   PROCEDURE – Curve Fitting is the process of constructing a curve or mathematical functions, whic Read more


The End