Challenge

Week 6 - Data analysis


Aim: To read the data from the file provided and perform the same calculation
and plot the parameter

Objective:
1. Data Visualizer
2. Compatibility heck
3. Performance calculation


Formulas:
1. W = Area * 100
2. Power = 2 * Pi * RPM * W/60
3. Fuel Consumption(F) = 20 * (1e -6)*RPM * 0.5/60
4. BSFC = (F/P)*3600

-------------------------------------------------------------------------------------------------------------------

#Main Code

import numpy as np #Import necessary library
import math
import matplotlib.pyplot as plt

try:
var1 = input("Please enter the file name with .out extension") # Accept the data file name with extension as input from user
print("INput received from the user:",var1)

except FileNotFoundError:
print("File not reconized. Please provide valid file")

#Reading the Data

file_object = open(var1,'r') #Read the data file

name=[]
units=[]
crank=[]
line_count = 1

for i in file_object:
crank.append(i)
if len(crank) ==5:
a = crank[2]
b = crank[3]
a = a.split()
b = b.split()
c = 0
a.pop(0)
for i in a:
c = c+1
name.append(i)
units.append(b[c])
print(str(c)+ " "+ i + " " + b[c])

def value(var2,var3):
x_data = []
y_data = []

file_object = open(var1,'r')

for line in file_object:
if '#' not in line:
x_data.append(float(line.split()[var2-1]))
y_data.append(float(line.split()[var3-1]))

#Plotting Graphs
plt.figure(1) #PLotting the graphs according the quantity on the X and Y axis
ax= plt.axes()
ax.set_facecolor('lightgrey')
plt.xlabel(name[var2-1]+units[var2-1],color= 'green', fontsize='large',fontweight= 'bold')
plt.ylabel(name[var3-1]+units[var3-1],color= 'purple', fontsize='large',fontweight= 'bold')
plt.title(name[var2-1]+units[var2-1] + ' v/s' + name[var3-1]+ units[var3-1])
plt.plot(x_data,y_data)
plt.show()

#Performance Calcualtions
if(var==8 and var3==2):
rpm = 1500
area = np.trapz(y_data,x_data) # MJ
print("area = ", area, "MJ")
workdone = area*1000 #KJ

print("workdone = ", workdone, "KJ")

Power = 2*math.pi*rpm*workdone/60 #KW #Performing the Power and BSFC Calcualtion
print("Power=", Power, "KW")
FuelConsumption = (20*(1e-6))*rpm*(0.5/60)
BSFC = ((FuelConsumption)/(Power))*3600 #G/KW HR

print("BSFC=", BSFC, "g/KWHr")

loop = 'yes'
while loop == 'yes':
g = int(input("Enter the no from above list to plot x-axis:"))
u = int(input("Enter the no from above list to plot y-axis:"))

value(g,u)
loop = input('If you want to give more inputs for x and y press yes or no:')

Conclusion:
The basic performance calculations and plots has been obtained
using python code.

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.