mirror of
https://github.com/balajsra/EECS-442-WN19-DIC-Project.git
synced 2025-09-03 01:13:15 +00:00
Add main.py
Created main.py with a function to read in the provided text file. Gets specimen dimensions, frame number, load, and displacement data into dictionary of FrameData classes.
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.idea/
|
72
src/main.py
Normal file
72
src/main.py
Normal file
@@ -0,0 +1,72 @@
|
||||
#############################################
|
||||
# EECS 442: Computer Vision - W19 #
|
||||
#############################################
|
||||
# Authors: Sravan Balaji & Kevin Monpara #
|
||||
# Filename: main.py #
|
||||
# Description: #
|
||||
#############################################
|
||||
|
||||
import numpy as np
|
||||
|
||||
|
||||
class FrameData:
|
||||
load = 0 # Load in N
|
||||
disp = 0 # Displacement in mm
|
||||
|
||||
def __init__(self, load, disp):
|
||||
self.load = load
|
||||
self.disp = disp
|
||||
|
||||
|
||||
def calc_stress():
|
||||
file = open("../Section001_Data.txt", "r")
|
||||
|
||||
w = 0 # Specimen Width in mm
|
||||
t = 0 # Specimen Thickness in mm
|
||||
gl = 0 # Specimen Gauge Length in mm
|
||||
ol = 0 # Specimen Overall Length in mm
|
||||
|
||||
load_disp_data = dict()
|
||||
|
||||
data_start = -1
|
||||
in_frame_data = False
|
||||
|
||||
for line in file:
|
||||
if "Width" in line:
|
||||
index = line.find("\t")
|
||||
w = float(line[index + 1:])
|
||||
|
||||
if "Thickness" in line:
|
||||
index = line.find("\t")
|
||||
t = float(line[index + 1:])
|
||||
|
||||
if "Gauge Length" in line:
|
||||
index = line.find("\t")
|
||||
gl = float(line[index + 1:])
|
||||
|
||||
if "Overall Length" in line:
|
||||
index = line.find("\t")
|
||||
ol = float(line[index + 1:])
|
||||
|
||||
if "Frame #" in line:
|
||||
data_start = 2
|
||||
|
||||
if data_start != -1:
|
||||
data_start -= 1
|
||||
|
||||
if data_start == 0:
|
||||
in_frame_data = True
|
||||
|
||||
if in_frame_data:
|
||||
if line != '\t\t\n':
|
||||
frame_num_str, load_str, disp_str = line.split("\t")
|
||||
frame_num = int(frame_num_str)
|
||||
load = float(load_str)
|
||||
disp = float(disp_str)
|
||||
load_disp_data[frame_num] = FrameData(load, disp)
|
||||
|
||||
print("Done")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
calc_stress()
|
Reference in New Issue
Block a user