Week 6 - Data analysis
Data analysis
AIM:-
To perform data analysis by importing raw data values from a data file into python and using those values to obtain useful and meaningful plots.
PROBLEM AND THEORY:-
In simple words, data analysis is the process of collecting and organizing data in order to draw helpful conclusions from it. The process of data analysis uses analytical and logical reasoning to gain information from the data.
The main purpose of data analysis is to find meaning in data so that the derived knowledge can be used to make informed decisions.
In this program, we import data from a data file according to the wish of the user and then visualize it by plotting with the values.
STEPWISE EXPLANATION:-
- - First, we import the necessary modules required for our program. Then we use the try and except commands to prepare the script for both the possibilities of availability and non-availability of the file and use appropriate display messages according to the resulting action.
- - After the file is opened using the open command, we set a counter to easily navigate through the lines of the file and skip the unnecessary comment files.
- - We print out a display menu containing the codes for all the available parameters in the data file and let the user choose the number.
- - We take input from the user using the input command along with a message, informing him to choose only numbers between 1 and 17 while picking the first and second parameters by inputting the corresponding number code.
- - Then, we convert the input from the user into a number by using the int command as the input is in the form of a string and successively, store the value of the numbers.
- - Then, we create a for loop, to access the data values of the column that the user had chosen and store them in empty variables created before the for a loop.
- - The counter is very helpful in navigating the lines of the file.
- - Then, we find the required engine parameter values ie, for the area under the curve, using the function traps. Similarly, other parameters were also calculated and then displayed using the appropriate units.
- - Finally, we plot the given data values by plotting the two variable arrays that contain the concerned column values.
- - To plot the label, we simply access the column headings in the data file and store the column heading in a separate variable and then print that variable as the label.



# Array for header and their unitsparameters = ['Crank','Pressure','Maximum Pressure','Minimum Pressure','Mean Temperature','MaximumTemperature','Minimum Temperature','Volume','Mass','Density','Integrated HR','HRrate','Cp','Cv','gamma','Kinematic Viscosity','Dynamic Viscosity']
units = ['(DEG)','(Mpa)','(Mpa)','(Mpa)','(K)','(K)','(K)','pow(m,3)','(kg)','(kg/(pow(m,3)))','(J)','(J)','(J/time)','(J/kgK)','(J/kgK)','','pow(m,2)/s','(Ns/pow(m,2)']
# Providing user choice of picking 2 parameters for plotting
print('Choose from following options and press enter key')
print('1 Crank n 2 Pressure n 3 Maximum Pressure n 4 Minimum Pressure n 5 Mean Temperature n 6 MaximumTemperature n 7 MinimumTemperature n 8 Volume n 9 Mass n 10 Density n 11 Integrated HR n 12 HR rate n 13 Cp n 14 Cv n 15 gamma n 16 Kinematic Viscosity n 17 Dynamic Viscosity')



Result:-

Graph between pressure and crank:

file is valid
Area under the curve using Simpsons Rule :0.0005005864474262364 units
Work done by the engine : 0.0005005864474262364 MJ
Work done by engine : 500.58644742623636 J
power output from engine : 6.257330592827954KW
Specific Fuel consumption, SFC = 0.00014383130100742395 (kg/hr)/KW
t
Area under curve using trapezoidal rule : 0.0005005866274680075units
Work done by the engine : 0.0005005866274680075 MJ
Work done by engine : 500.58662746800746 J
power output from the engine : 6.257332843350094KW
Specific Fuel consumption, SFC = 0.00014383124927683276 (kg/hr)/KW
t
Choose from following options and press enter key
1 Crank n 2 Pressure n 3 Maximum Pressure n 4 Minimum Pressure n 5 Mean Temperature n 6 MaximumTemperature n 7 Minimum Temperature n 8 Volume n 9 Mass n 10 Density n 11 Integrated HR n 12 HR rate n 13 Cp n 14 Cv n 15 gamma n 16 Kinematic Viscosity n 17 Dynamic Viscosity