All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Data Analysis OBJECTIVE Data Visualizer Compatibility check Basic performance calculation THEORY Data analysis Data analysis is a process of inspecting, cleansing, transforming and modelling data with the goal of discovering useful information, informing conclusions, and supporting decision-making. This deals with the…
Vidu Bansal
updated on 29 Dec 2022
Data Analysis
OBJECTIVE
THEORY
Data analysis
Data analysis is a process of inspecting, cleansing, transforming and modelling data with the goal of discovering useful information, informing conclusions, and supporting decision-making. This deals with the field of computational linguistics which commonly defines natural language processing. Natural language processing (NLP), is concerned with programming computers to process and analyse the human written language. The parser helps to split the large input data into smaller data and will process the data.
Why data analysis?
Data analysis is necessary because the different application needs the data to be in various forms. Parsing allows transforming the data in a way that a specific software can understand. The obvious example is programs – they are written by humans, but they must be executed by computers. Data analysis helps to automate specific things, and also reduces human effort. And can be used for the applications of machine learning, automation etc.
Problem Statement
Problem Approach
Compatibility check
The file name should be valid and so checking the file name entered by the user is known as a ‘compatibility check’.
Engine_data.out file
The file includes the engine simulation output data and it has 17 different parameter outputs as columns with defined column numbers and units. First, 5 rows are comments. The file data is obtained from converging CFD package.
Thermodynamic data collected from the simulation of a port fuel-injected engine is extracted and analyzed from a data file using a Python program. The data stored is of a 4-stroke Otto cycle. So, the formula used to calculate the Work done, power output and specific fuel consumption –
CODE
'''
Demonstrating file parsing in python
'''
# data analysis
import math
import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import simps
from tabulate import tabulate
# file parsing with uer input
# file input
File = input("Enter the name of CONVERGE output filename with extension (.out): ")
# checking if the file is a valid CONVERGE output file
try:
f = open(File)
except FileNotFoundError:
print('File not recognized. Please provide a valid CONVERGE output file')
# code to read the data line by line
# to fetch title of data file
titles = []
for line in open(File):
if '#' in line:
titles.append(line.split())
print(titles)
print(titles[1])
print(titles[2])
print(titles[3])
# to get column numbers from data file
serial = []
for sn in titles[1]:
if '#' not in sn:
if 'column' not in sn:
serial.append(sn)
print(serial)
# to get parameter names from data file
parameters = []
for p in titles[2]:
if '#' not in p:
parameters.append(p)
print(parameters)
# to get si units from data file
units = []
for u in titles[3]:
if '#' not in u:
units.append(u)
print(units)
# printing parameters with units and column numbers
headers = ['Column No','Parameters','Units']
data = tuple(zip(serial, parameters, units))
print(tabulate(data,headers=headers))
# plotting of parameters by knowing column number
a = int(input('Enter column no of 1st parameter:')) # for volume 8
b = int(input('Enter column no of 2nd parameter:')) # for pressure 2
print('\n')
# To generate labels automatically for plots
x_1 = parameters[a-1]
y_1 = parameters[b-1]
# To store required value to plot
value_1 = []
value_2 = []
# To calculate work done from p-V curve
pressure = []
volume = []
# creating a loop to get required values from data file
for line in open(File):
if '#' not in line:
value_1.append(float(line.split()[a-1]))
value_2.append(float(line.split()[b-1]))
pressure.append(float(line.split()[1]))
volume.append(float(line.split()[7]))
filename = x_1 + ' vs ' + y_1 + '.png'
title = x_1 + ' vs ' + y_1
# Plotting
plt.plot(value_1, value_2, linewidth=3)
plt.xlabel(x_1)
plt.ylabel(y_1)
plt.title(title)
plt.savefig(filename)
plt.show()
# to calculate area under p-V diagram
Area = simps(pressure, volume)
print('Area under p-V curve:' +str(Area))
print('Work done by engine:' +str(Area*1e6))
print('n')
# to calculate power output of engine
rpm = int(input('Enter the engine RPM:')) # RPM = 1500
rps = rpm/60
Power_strokes = rps/2 # no of power strokes in revolution of crank-shaft
power = (Area*1e6)*Power_strokes/1000 # power in kW
print('Power output of engine is:' +str(power)+ 'kW')
print('\n')
# to calculate specific fuel consumption
r = int(input('Enter specific fuel consumption per kg per sec:')) # 20 micro grams of fuel (per 1 stroke cycle)
bsfc = (r/power)*3600
print('Specific fuel consumption of the engine:' +str(bsfc)+ 'kg/kWhr')
SAVED PLOTS
Leave a comment
Thanks for choosing to leave a comment. Please keep in mind that all the comments are moderated as per our comment policy, and your email will not be published for privacy reasons. Please leave a personal & meaningful conversation.
Other comments...
Week 6 - Data analysis
Data Analysis OBJECTIVE Data Visualizer Compatibility check Basic performance calculation THEORY Data analysis Data analysis is a process of inspecting, cleansing, transforming and modelling data with the goal of discovering useful information, informing conclusions, and supporting decision-making. This deals with the…
29 Dec 2022 05:23 PM IST
Week 2 Air standard Cycle
Otto cycle - Python OBJECTIVE Introduction to IC engine and air standard cycle Plotting PV graph of Otto cycle using Python THEORY IC Engine It is a heat engine that converts the chemical energy of fuel into mechanical energy. The chemical energy of the fuel gets converted to thermal energy through the combustion of an…
26 Dec 2022 06:52 PM IST
Week 5 - Curve fitting
CURVE FITTING – Python OBJECTIVE How to change the experimental data into a mathematical equation. Ways to measure the goodness of fit To fit Cp data according to the given Cp vs temperature data file THEORY Curve Fitting It is one of the techniques of data analysis to validate and find the mathematical relation…
25 Dec 2022 04:57 PM IST
Week 3 - Solving second order ODEs
Solving Second Order ODE Using PYTHON OBJECTIVE To create a simulation of simple pendulum with python as a solution for second-order ODE with damping. THEORY ODE is used to describe the transient behavior of a system. Example; PENDULUM The path of pendulum depends on the Newton’s second law. ODE representing the…
25 Dec 2022 07:30 AM IST
Related Courses
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.