Integrate python script
This commit is contained in:
parent
c99692fc36
commit
a81d412ae6
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,2 +1,4 @@
|
||||
.DS_Store
|
||||
__pycache__/
|
||||
venv/
|
||||
uploads/
|
7
app.py
7
app.py
@ -4,6 +4,7 @@ from flask_wtf import FlaskForm
|
||||
from flask_wtf.file import FileField, FileRequired, FileAllowed
|
||||
from wtforms import SubmitField
|
||||
from flask_uploads import UploadSet, IMAGES, configure_uploads
|
||||
from scripts.img_V01 import ComputeMain
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
@ -31,9 +32,13 @@ def index():
|
||||
if form.validate_on_submit():
|
||||
filename = photos.save(form.photo.data)
|
||||
file_url = url_for('get_file', filename=filename)
|
||||
|
||||
# Compute surface tension
|
||||
results = ComputeMain(app.config['UPLOADED_PHOTOS_DEST'] + "/" + filename)
|
||||
else:
|
||||
file_url = None
|
||||
return render_template('index.html', form=form, file_url=file_url)
|
||||
results = None
|
||||
return render_template('index.html', form=form, file_url=file_url, results=results)
|
||||
|
||||
|
||||
|
||||
|
7
requirements.txt
Normal file
7
requirements.txt
Normal file
@ -0,0 +1,7 @@
|
||||
Flask==3.1.0
|
||||
flask_uploads==0.2.1
|
||||
flask_wtf==1.2.2
|
||||
numpy==2.2.4
|
||||
opencv_python==4.11.0.86
|
||||
scipy==1.15.2
|
||||
WTForms==3.2.1
|
@ -538,13 +538,7 @@ def PrintCorrectUsage():
|
||||
print("4. Setting min (0.00001) and max (1.5) values for parameter.")
|
||||
print("./img.py -img water-drop.jpg -out water-drop -a 0.00001 -A 1.5\n")
|
||||
|
||||
|
||||
|
||||
# ========== MAIN ==========
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
ImageFilePath = ""
|
||||
def ComputeMain(ImageFilePath):
|
||||
OutputFileName = ""
|
||||
PosPointsFileName = ""
|
||||
NegPointsFileName = ""
|
||||
@ -563,10 +557,6 @@ if __name__ == '__main__':
|
||||
XStep = 5
|
||||
TStep = 5
|
||||
|
||||
if (len(sys.argv) <= 1):
|
||||
PrintCorrectUsage()
|
||||
sys.exit()
|
||||
|
||||
ImageFlag = 0
|
||||
PosFileFlag = 0
|
||||
NegFileFlag = 0
|
||||
@ -574,79 +564,6 @@ if __name__ == '__main__':
|
||||
Counter = 1
|
||||
SolveMethod = 0
|
||||
|
||||
while (Counter <= len(sys.argv)-1):
|
||||
|
||||
CurrentOption = sys.argv[Counter]
|
||||
try:
|
||||
CurrentValue = sys.argv[Counter+1]
|
||||
except:
|
||||
PrintCorrectUsage()
|
||||
sys.exit()
|
||||
|
||||
if CurrentOption == "-help":
|
||||
PrintCorrectUsage()
|
||||
sys.exit()
|
||||
elif CurrentOption == "-img":
|
||||
ImageFilePath = CurrentValue
|
||||
ImageFlag = 1
|
||||
elif CurrentOption == "-filep":
|
||||
PosPointsFileName = CurrentValue
|
||||
PosFileFlag = 1
|
||||
elif CurrentOption == "-filen":
|
||||
NegPointsFileName = CurrentValue
|
||||
NegFileFlag = 1
|
||||
elif CurrentOption == "-out":
|
||||
OutputFileName = CurrentValue
|
||||
OutFlag = 1
|
||||
elif CurrentOption == "-proc":
|
||||
ProcessCount = int(CurrentValue)
|
||||
elif CurrentOption == "-syrg":
|
||||
SyringeWidth = float(CurrentValue)
|
||||
elif CurrentOption == "-a":
|
||||
MinA_radCurv = float(CurrentValue)
|
||||
elif CurrentOption == "-A":
|
||||
MaxA_radCurv = float(CurrentValue)
|
||||
elif CurrentOption == "-b":
|
||||
MinB_shapeFact = float(CurrentValue)
|
||||
elif CurrentOption == "-B":
|
||||
MaxB_shapeFact = float(CurrentValue)
|
||||
elif CurrentOption == "-x":
|
||||
MinX = float(CurrentValue)
|
||||
elif CurrentOption == "-X":
|
||||
MaxX = float(CurrentValue)
|
||||
elif CurrentOption == "-t":
|
||||
MinT_angle = float(CurrentValue)
|
||||
elif CurrentOption == "-T":
|
||||
MaxT_angle = float(CurrentValue)
|
||||
elif CurrentOption == "-ai":
|
||||
AStep = int(CurrentValue)
|
||||
elif CurrentOption == "-bi":
|
||||
BStep = int(CurrentValue)
|
||||
elif CurrentOption == "-xi":
|
||||
XStep = int(CurrentValue)
|
||||
elif CurrentOption == "-ti":
|
||||
TStep = int(CurrentValue)
|
||||
elif CurrentOption == "-solver":
|
||||
SolveMethod = int(CurrentValue)
|
||||
else:
|
||||
PrintCorrectUsage()
|
||||
sys.exit()
|
||||
Counter = Counter + 2
|
||||
|
||||
if (OutFlag == 0 and ImageFlag == 1):
|
||||
print("Output file name not set. (-out)")
|
||||
PrintCorrectUsage()
|
||||
sys.exit()
|
||||
if (ImageFlag == 1 and ((PosFileFlag == 1) or (NegFileFlag == 1))):
|
||||
print("Image(-img) can not be set with files option (-filep, -filen).")
|
||||
print("Either set image only or files only.")
|
||||
PrintCorrectUsage()
|
||||
sys.exit()
|
||||
if (ImageFlag == 0 and ((PosFileFlag == 1 and NegFileFlag == 0) or (PosFileFlag == 0 and NegFileFlag == 1))):
|
||||
print("File inputs (-filep, -filen) should both be set if image input is not set.")
|
||||
PrintCorrectUsage()
|
||||
sys.exit()
|
||||
|
||||
ARange_radCurv = []
|
||||
a = MinA_radCurv
|
||||
ahop = float(MaxA_radCurv - MinA_radCurv)/float(AStep-1)
|
||||
@ -691,25 +608,6 @@ if __name__ == '__main__':
|
||||
if(np.abs(MaxT_angle - TRange_angle[len(TRange_angle)-1] - thop) < 0.000001 and thop != 0.0):
|
||||
TRange_angle.append(MaxT_angle)
|
||||
|
||||
|
||||
print("\n")
|
||||
if (ImageFlag == 1):
|
||||
print("Image File : " + ImageFilePath)
|
||||
print("Output Name : " + OutputFileName)
|
||||
print("Negative Cooridnate File : " + OutputFileName + "_Negative.dat")
|
||||
print("Positive Cooridnate File : " + OutputFileName + "_Positive.dat")
|
||||
print("Syringe Width (millimeter): " + str(SyringeWidth))
|
||||
else:
|
||||
print("Negative Cooridnate File : " + NegPointsFileName)
|
||||
print("Positive Cooridnate File : " + PosPointsFileName)
|
||||
print("Radius of Curvature Range : " + str(MinA_radCurv) + "-" + str(MaxA_radCurv) + " (interval: "+str(len(ARange_radCurv))+")")
|
||||
print("Shape Factor Range : " + str(MinB_shapeFact) + "-" + str(MaxB_shapeFact) + " (interval: "+str(len(BRange_shapeFact))+")")
|
||||
print("Initial X Coordinate Range: " + str(MinX) + "-" + str(MaxX) + " (interval: "+str(len(XRange))+")")
|
||||
print("Initial Angle Range : " + str(MinT_angle) + "-" + str(MaxT_angle) + " (interval: "+str(len(TRange_angle))+")")
|
||||
print("Parameter Combinations : " + str(len(ARange_radCurv) * len(BRange_shapeFact) * len(XRange) * len(TRange_angle)))
|
||||
print("Number of Process to Use : " + str(ProcessCount))
|
||||
|
||||
if (ImageFlag == 1):
|
||||
Pos_edgePts, Neg_edgePts, De_scaledMaxWidth, Dms_diamters = ExtractEdgeCoordinate(ImageFilePath, OutputFileName, SyringeWidth)
|
||||
HInv1 = HJuza(Dms_diamters[7]/De_scaledMaxWidth, 0.8)
|
||||
HInv2 = HJuza(Dms_diamters[8]/De_scaledMaxWidth, 0.9)
|
||||
@ -718,22 +616,6 @@ if __name__ == '__main__':
|
||||
HInv5 = HJuza(Dms_diamters[11]/De_scaledMaxWidth, 1.2)
|
||||
HInvM = (0.20)*(HInv1 + HInv2 + HInv3 + HInv4 + HInv5)
|
||||
HInvSD = math.sqrt((0.20)*( (HInv1-HInvM)**2.0 + (HInv2-HInvM)**2.0 + (HInv3-HInvM)**2.0 + (HInv4-HInvM)**2.0 + (HInv5-HInvM)**2.0))
|
||||
print("Juza 5-Plane (1/H) Std.Dev: " + str(HInvSD))
|
||||
else:
|
||||
Pos_edgePts = []
|
||||
PositivePointFile = open(PosPointsFileName,'r')
|
||||
for Line in PositivePointFile:
|
||||
Coordinate = Line.split()
|
||||
#print(Coordinate)
|
||||
Pos_edgePts.append((float(Coordinate[0]), float(Coordinate[1])))
|
||||
PositivePointFile.close()
|
||||
Neg_edgePts = []
|
||||
NegativePointFile = open(NegPointsFileName,'r')
|
||||
for Line in NegativePointFile:
|
||||
Coordinate = Line.split()
|
||||
#print(Coordinate)
|
||||
Neg_edgePts.append((float(Coordinate[0]), float(Coordinate[1])))
|
||||
NegativePointFile.close()
|
||||
|
||||
def BruteForce():
|
||||
PosList = []
|
||||
@ -788,12 +670,303 @@ if __name__ == '__main__':
|
||||
|
||||
BestOutput = Optimize() if 1 != SolveMethod else BruteForce()
|
||||
|
||||
print("best output: " + str(BestOutput))
|
||||
# print("Negative Cooridnate File : " + OutputFileName + "_Negative.dat")
|
||||
# print("Positive Cooridnate File : " + OutputFileName + "_Positive.dat")
|
||||
# print("Syringe Width (millimeter): " + str(SyringeWidth))
|
||||
# print("Radius of Curvature Range : " + str(MinA_radCurv) + "-" + str(MaxA_radCurv) + " (interval: "+str(len(ARange_radCurv))+")")
|
||||
# print("Shape Factor Range : " + str(MinB_shapeFact) + "-" + str(MaxB_shapeFact) + " (interval: "+str(len(BRange_shapeFact))+")")
|
||||
# print("Initial X Coordinate Range: " + str(MinX) + "-" + str(MaxX) + " (interval: "+str(len(XRange))+")")
|
||||
# print("Initial Angle Range : " + str(MinT_angle) + "-" + str(MaxT_angle) + " (interval: "+str(len(TRange_angle))+")")
|
||||
# print("Parameter Combinations : " + str(len(ARange_radCurv) * len(BRange_shapeFact) * len(XRange) * len(TRange_angle)))
|
||||
# print("Number of Process to Use : " + str(ProcessCount))
|
||||
# print("Juza 5-Plane (1/H) Std.Dev: " + str(HInvSD))
|
||||
|
||||
print("\nLowest RMSD : " + str(BestOutput[0]))
|
||||
print("Computed Surface Tension : " + str(9.8*BestOutput[1]/BestOutput[2]))
|
||||
print("Best Radius of Curvature : " + str(BestOutput[1]))
|
||||
print("Best Shape Factor : " + str(BestOutput[2]))
|
||||
print("Best Initial X Coordinate : " + str(BestOutput[3]))
|
||||
print("Best Initial Angle : " + str(BestOutput[4]))
|
||||
print("Lapsed Time in Seconds : " + str(time.time() -starttime))
|
||||
# print("best output: " + str(BestOutput))
|
||||
|
||||
# print("\nLowest RMSD : " + str(BestOutput[0]))
|
||||
# print("Computed Surface Tension : " + str(9.8*BestOutput[1]/BestOutput[2]))
|
||||
# print("Best Radius of Curvature : " + str(BestOutput[1]))
|
||||
# print("Best Shape Factor : " + str(BestOutput[2]))
|
||||
# print("Best Initial X Coordinate : " + str(BestOutput[3]))
|
||||
# print("Best Initial Angle : " + str(BestOutput[4]))
|
||||
# print("Lapsed Time in Seconds : " + str(time.time() -starttime))
|
||||
|
||||
return {
|
||||
"negCoordFile": OutputFileName + "_Negative.dat",
|
||||
"posCoordFile": OutputFileName + "_Positive.dat",
|
||||
"syringeWidth": SyringeWidth,
|
||||
"radiusCurvatureRange": str(MinA_radCurv) + "-" + str(MaxA_radCurv) + " (interval: "+str(len(ARange_radCurv))+")",
|
||||
"shapeFactorRange": str(MinB_shapeFact) + "-" + str(MaxB_shapeFact) + " (interval: "+str(len(BRange_shapeFact))+")",
|
||||
"initialXCoordinateRange": str(MinX) + "-" + str(MaxX) + " (interval: "+str(len(XRange))+")",
|
||||
"initialAngleRange": str(MinT_angle) + "-" + str(MaxT_angle) + " (interval: "+str(len(TRange_angle))+")",
|
||||
"paramCombinations": len(ARange_radCurv) * len(BRange_shapeFact) * len(XRange) * len(TRange_angle),
|
||||
"numProcess": ProcessCount,
|
||||
"juza": HInvSD,
|
||||
"lowestRMSD": BestOutput[0],
|
||||
"computedSurfaceTension": 9.8*BestOutput[1]/BestOutput[2],
|
||||
"bestRadiusCurvature": BestOutput[1],
|
||||
"bestShapeFactor": BestOutput[2],
|
||||
"bestInitialXCoordinate": BestOutput[3],
|
||||
"bestInitialAngle": BestOutput[4],
|
||||
"lapsedTime": time.time()-starttime
|
||||
}
|
||||
|
||||
|
||||
# ========== MAIN ==========
|
||||
|
||||
if __name__ == '__main__':
|
||||
ImageFilePath = '/Users/fsantelices/Desktop/Pendant Drop App/Surface Tension Data/data/ambient-6-26-15-mf-3-30s-MORPHED.jpg'
|
||||
print(ComputeMain(ImageFilePath))
|
||||
|
||||
# ImageFilePath = ""
|
||||
# OutputFileName = ""
|
||||
# NegPointsFileName = ""
|
||||
# ProcessCount = 2
|
||||
# SyringeWidth = 0.70 * 1.15
|
||||
# MinA_radCurv = 0.0001
|
||||
# MaxA_radCurv = 2.0001
|
||||
# MinB_shapeFact = 0.0001
|
||||
# MaxB_shapeFact = 1.0001
|
||||
# MinX = 0.0001
|
||||
# MaxX = 0.5001
|
||||
# MinT_angle = 0.0001
|
||||
# MaxT_angle = 0.5001
|
||||
# AStep = 20
|
||||
# BStep = 20
|
||||
# XStep = 5
|
||||
# TStep = 5
|
||||
|
||||
# ImageFlag = 0
|
||||
# PosFileFlag = 0
|
||||
# NegFileFlag = 0
|
||||
# OutFlag = 0
|
||||
# Counter = 1
|
||||
# SolveMethod = 0
|
||||
|
||||
# if (len(sys.argv) <= 1):
|
||||
# PrintCorrectUsage()
|
||||
# sys.exit()
|
||||
|
||||
# while (Counter <= len(sys.argv)-1):
|
||||
|
||||
# CurrentOption = sys.argv[Counter]
|
||||
# try:
|
||||
# CurrentValue = sys.argv[Counter+1]
|
||||
# except:
|
||||
# PrintCorrectUsage()
|
||||
# sys.exit()
|
||||
|
||||
# if CurrentOption == "-help":
|
||||
# PrintCorrectUsage()
|
||||
# sys.exit()
|
||||
# elif CurrentOption == "-img":
|
||||
# ImageFilePath = CurrentValue
|
||||
# ImageFlag = 1
|
||||
# elif CurrentOption == "-filep":
|
||||
# PosPointsFileName = CurrentValue
|
||||
# PosFileFlag = 1
|
||||
# elif CurrentOption == "-filen":
|
||||
# NegPointsFileName = CurrentValue
|
||||
# NegFileFlag = 1
|
||||
# elif CurrentOption == "-out":
|
||||
# OutputFileName = CurrentValue
|
||||
# OutFlag = 1
|
||||
# elif CurrentOption == "-proc":
|
||||
# ProcessCount = int(CurrentValue)
|
||||
# elif CurrentOption == "-syrg":
|
||||
# SyringeWidth = float(CurrentValue)
|
||||
# elif CurrentOption == "-a":
|
||||
# MinA_radCurv = float(CurrentValue)
|
||||
# elif CurrentOption == "-A":
|
||||
# MaxA_radCurv = float(CurrentValue)
|
||||
# elif CurrentOption == "-b":
|
||||
# MinB_shapeFact = float(CurrentValue)
|
||||
# elif CurrentOption == "-B":
|
||||
# MaxB_shapeFact = float(CurrentValue)
|
||||
# elif CurrentOption == "-x":
|
||||
# MinX = float(CurrentValue)
|
||||
# elif CurrentOption == "-X":
|
||||
# MaxX = float(CurrentValue)
|
||||
# elif CurrentOption == "-t":
|
||||
# MinT_angle = float(CurrentValue)
|
||||
# elif CurrentOption == "-T":
|
||||
# MaxT_angle = float(CurrentValue)
|
||||
# elif CurrentOption == "-ai":
|
||||
# AStep = int(CurrentValue)
|
||||
# elif CurrentOption == "-bi":
|
||||
# BStep = int(CurrentValue)
|
||||
# elif CurrentOption == "-xi":
|
||||
# XStep = int(CurrentValue)
|
||||
# elif CurrentOption == "-ti":
|
||||
# TStep = int(CurrentValue)
|
||||
# elif CurrentOption == "-solver":
|
||||
# SolveMethod = int(CurrentValue)
|
||||
# else:
|
||||
# PrintCorrectUsage()
|
||||
# sys.exit()
|
||||
# Counter = Counter + 2
|
||||
|
||||
# if (OutFlag == 0 and ImageFlag == 1):
|
||||
# print("Output file name not set. (-out)")
|
||||
# PrintCorrectUsage()
|
||||
# sys.exit()
|
||||
# if (ImageFlag == 1 and ((PosFileFlag == 1) or (NegFileFlag == 1))):
|
||||
# print("Image(-img) can not be set with files option (-filep, -filen).")
|
||||
# print("Either set image only or files only.")
|
||||
# PrintCorrectUsage()
|
||||
# sys.exit()
|
||||
# if (ImageFlag == 0 and ((PosFileFlag == 1 and NegFileFlag == 0) or (PosFileFlag == 0 and NegFileFlag == 1))):
|
||||
# print("File inputs (-filep, -filen) should both be set if image input is not set.")
|
||||
# PrintCorrectUsage()
|
||||
# sys.exit()
|
||||
|
||||
# ARange_radCurv = []
|
||||
# a = MinA_radCurv
|
||||
# ahop = float(MaxA_radCurv - MinA_radCurv)/float(AStep-1)
|
||||
# while (a <= MaxA_radCurv):
|
||||
# ARange_radCurv.append(a)
|
||||
# a += ahop
|
||||
# if ahop == 0.0:
|
||||
# break
|
||||
# if(np.abs(MaxA_radCurv - ARange_radCurv[len(ARange_radCurv)-1] - ahop) < 0.000001 and ahop != 0.0):
|
||||
# ARange_radCurv.append(MaxA_radCurv)
|
||||
|
||||
# BRange_shapeFact = []
|
||||
# b = MinB_shapeFact
|
||||
# bhop = float(MaxB_shapeFact - MinB_shapeFact)/float(BStep-1)
|
||||
# while (b <= MaxB_shapeFact):
|
||||
# BRange_shapeFact.append(b)
|
||||
# b += bhop
|
||||
# if bhop == 0:
|
||||
# break
|
||||
# if(np.abs(MaxB_shapeFact - BRange_shapeFact[len(BRange_shapeFact)-1] - bhop) < 0.000001 and bhop != 0.0):
|
||||
# BRange_shapeFact.append(MaxB_shapeFact)
|
||||
|
||||
# XRange = []
|
||||
# x = MinX
|
||||
# xhop = float(MaxX - MinX)/float(XStep-1)
|
||||
# while (x <= MaxX):
|
||||
# XRange.append(x)
|
||||
# x += xhop
|
||||
# if xhop == 0:
|
||||
# break
|
||||
# if(np.abs(MaxX - XRange[len(XRange)-1] - xhop) < 0.000001 and xhop != 0.0):
|
||||
# XRange.append(MaxX)
|
||||
|
||||
# TRange_angle = []
|
||||
# t = MinT_angle
|
||||
# thop = float(MaxT_angle - MinT_angle)/float(TStep-1)
|
||||
# while (t <= MaxT_angle):
|
||||
# TRange_angle.append(t)
|
||||
# t += thop
|
||||
# if thop == 0.0:
|
||||
# break
|
||||
# if(np.abs(MaxT_angle - TRange_angle[len(TRange_angle)-1] - thop) < 0.000001 and thop != 0.0):
|
||||
# TRange_angle.append(MaxT_angle)
|
||||
|
||||
|
||||
# print("\n")
|
||||
# if (ImageFlag == 1):
|
||||
# print("Image File : " + ImageFilePath)
|
||||
# print("Output Name : " + OutputFileName)
|
||||
# print("Negative Cooridnate File : " + OutputFileName + "_Negative.dat")
|
||||
# print("Positive Cooridnate File : " + OutputFileName + "_Positive.dat")
|
||||
# print("Syringe Width (millimeter): " + str(SyringeWidth))
|
||||
# else:
|
||||
# print("Negative Cooridnate File : " + NegPointsFileName)
|
||||
# print("Positive Cooridnate File : " + PosPointsFileName)
|
||||
# print("Radius of Curvature Range : " + str(MinA_radCurv) + "-" + str(MaxA_radCurv) + " (interval: "+str(len(ARange_radCurv))+")")
|
||||
# print("Shape Factor Range : " + str(MinB_shapeFact) + "-" + str(MaxB_shapeFact) + " (interval: "+str(len(BRange_shapeFact))+")")
|
||||
# print("Initial X Coordinate Range: " + str(MinX) + "-" + str(MaxX) + " (interval: "+str(len(XRange))+")")
|
||||
# print("Initial Angle Range : " + str(MinT_angle) + "-" + str(MaxT_angle) + " (interval: "+str(len(TRange_angle))+")")
|
||||
# print("Parameter Combinations : " + str(len(ARange_radCurv) * len(BRange_shapeFact) * len(XRange) * len(TRange_angle)))
|
||||
# print("Number of Process to Use : " + str(ProcessCount))
|
||||
|
||||
# if (ImageFlag == 1):
|
||||
# Pos_edgePts, Neg_edgePts, De_scaledMaxWidth, Dms_diamters = ExtractEdgeCoordinate(ImageFilePath, OutputFileName, SyringeWidth)
|
||||
# HInv1 = HJuza(Dms_diamters[7]/De_scaledMaxWidth, 0.8)
|
||||
# HInv2 = HJuza(Dms_diamters[8]/De_scaledMaxWidth, 0.9)
|
||||
# HInv3 = HJuza(Dms_diamters[9]/De_scaledMaxWidth, 1.0)
|
||||
# HInv4 = HJuza(Dms_diamters[10]/De_scaledMaxWidth, 1.1)
|
||||
# HInv5 = HJuza(Dms_diamters[11]/De_scaledMaxWidth, 1.2)
|
||||
# HInvM = (0.20)*(HInv1 + HInv2 + HInv3 + HInv4 + HInv5)
|
||||
# HInvSD = math.sqrt((0.20)*( (HInv1-HInvM)**2.0 + (HInv2-HInvM)**2.0 + (HInv3-HInvM)**2.0 + (HInv4-HInvM)**2.0 + (HInv5-HInvM)**2.0))
|
||||
# print("Juza 5-Plane (1/H) Std.Dev: " + str(HInvSD))
|
||||
# else:
|
||||
# Pos_edgePts = []
|
||||
# PositivePointFile = open(PosPointsFileName,'r')
|
||||
# for Line in PositivePointFile:
|
||||
# Coordinate = Line.split()
|
||||
# #print(Coordinate)
|
||||
# Pos_edgePts.append((float(Coordinate[0]), float(Coordinate[1])))
|
||||
# PositivePointFile.close()
|
||||
# Neg_edgePts = []
|
||||
# NegativePointFile = open(NegPointsFileName,'r')
|
||||
# for Line in NegativePointFile:
|
||||
# Coordinate = Line.split()
|
||||
# #print(Coordinate)
|
||||
# Neg_edgePts.append((float(Coordinate[0]), float(Coordinate[1])))
|
||||
# NegativePointFile.close()
|
||||
|
||||
# def BruteForce():
|
||||
# PosList = []
|
||||
# NegList = []
|
||||
# for ProcessNo in range(ProcessCount):
|
||||
# PosList.append(copy.deepcopy(Pos_edgePts))
|
||||
# NegList.append(copy.deepcopy(Neg_edgePts))
|
||||
# #print(ProcessNo)
|
||||
|
||||
# ARanges = []
|
||||
# for ProcessNo in range(ProcessCount):
|
||||
# ARanges.append([])
|
||||
|
||||
# i = 0
|
||||
# for A in ARange_radCurv:
|
||||
# ARanges[i%ProcessCount].append(A)
|
||||
# i += 1
|
||||
|
||||
# BestParams = multiprocessing.Queue()
|
||||
# TicksQueue = multiprocessing.Queue()
|
||||
# Processes = []
|
||||
|
||||
# for ProcessNo in range(ProcessCount):
|
||||
# Processes.append(multiprocessing.Process(name='Search ' + str(ProcessNo), target=FindOptimalParameters, args=(PosList[ProcessNo], NegList[ProcessNo], ARanges[ProcessNo], BRange_shapeFact, XRange, TRange_angle, BestParams, TicksQueue)))
|
||||
|
||||
# for aProcess in Processes:
|
||||
# aProcess.start()
|
||||
|
||||
# sys.stdout.write("\rParameter Search Progress : 0%")
|
||||
# sys.stdout.flush()
|
||||
# Count = 0
|
||||
# while(Count < len(ARange_radCurv)):
|
||||
# t = TicksQueue.get()
|
||||
# Count += 1
|
||||
# sys.stdout.write("\rParameter Search Progress : " + str(int(100*float(Count)/float(len(ARange_radCurv)))) + "%")
|
||||
# sys.stdout.flush()
|
||||
|
||||
# for aProcess in Processes:
|
||||
# aProcess.join()
|
||||
|
||||
# BestOutput = (999999999, 1, 1, 1 ,1)
|
||||
# while not BestParams.empty():
|
||||
# Output = BestParams.get()
|
||||
# if Output[0] < BestOutput[0]:
|
||||
# BestOutput = Output
|
||||
# return BestOutput
|
||||
|
||||
# def Optimize():
|
||||
# return OptimizeParameters(Pos_edgePts, Neg_edgePts, 0.95, 0.3, 0.1, 0.2)
|
||||
|
||||
# starttime = time.time()
|
||||
|
||||
# BestOutput = Optimize() if 1 != SolveMethod else BruteForce()
|
||||
|
||||
# print("best output: " + str(BestOutput))
|
||||
|
||||
# print("\nLowest RMSD : " + str(BestOutput[0]))
|
||||
# print("Computed Surface Tension : " + str(9.8*BestOutput[1]/BestOutput[2]))
|
||||
# print("Best Radius of Curvature : " + str(BestOutput[1]))
|
||||
# print("Best Shape Factor : " + str(BestOutput[2]))
|
||||
# print("Best Initial X Coordinate : " + str(BestOutput[3]))
|
||||
# print("Best Initial Angle : " + str(BestOutput[4]))
|
||||
# print("Lapsed Time in Seconds : " + str(time.time() -starttime))
|
||||
|
@ -9,13 +9,13 @@
|
||||
</div>
|
||||
<div class="row p-4 mb-3 maindiv">
|
||||
<!-- IMAGE DISPLAY AND BUTTONS -->
|
||||
<div class="col-5">
|
||||
<div class="col-6">
|
||||
{% if file_url %}
|
||||
<div class="row mb-3 text-center imagediv">
|
||||
<img src="{{ file_url }}" style="height: 400px; width: 500px;">
|
||||
<img src="{{ file_url }}" style="height: 450px; width: 600px;">
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="row p-4 mb-3 text-center imagediv" style="height: 400px; width: 500;">
|
||||
<div class="row p-4 mb-3 text-center imagediv" style="height: 450px; width: 600;">
|
||||
No image uploaded
|
||||
</div>
|
||||
{% endif %}
|
||||
@ -38,13 +38,13 @@
|
||||
|
||||
</div>
|
||||
<!-- TENSIOMETRY RESULTS -->
|
||||
<div class="col-7 px-5">
|
||||
<div class="col px-5">
|
||||
<h4><b>Results:</b></h4>
|
||||
<div class="row">
|
||||
<div class="col-5 labels">
|
||||
Negative Cooridnate File:<br>
|
||||
Positive Cooridnate File:<br>
|
||||
Syringe Width (millimeter):<br>
|
||||
<!-- Negative Cooridnate File:<br>
|
||||
Positive Cooridnate File:<br> -->
|
||||
Syringe Width (mm):<br>
|
||||
Radius of Curvature Range:<br>
|
||||
Shape Factor Range :<br>
|
||||
Initial X Coordinate Range:<br>
|
||||
@ -52,18 +52,39 @@
|
||||
Parameter Combinations:<br>
|
||||
Number of Process to Use:<br>
|
||||
Juza 5-Plane (1/H) Std.Dev:<br>
|
||||
|
||||
best output:<br>
|
||||
</div>
|
||||
<div class="col">
|
||||
<!-- {{ results.negCoordFile }} <br>
|
||||
{{ results.posCoordFile }} <br> -->
|
||||
{{ results.syringeWidth }} <br>
|
||||
{{ results.radiusCurvatureRange }} <br>
|
||||
{{ results.shapeFactorRange }} <br>
|
||||
{{ results.initialXCoordinateRange }} <br>
|
||||
{{ results.initialAngleRange }} <br>
|
||||
{{ results.paramCombinations }} <br>
|
||||
{{ results.numProcess }} <br>
|
||||
{{ results.juza }} <br>
|
||||
</div>
|
||||
</div>
|
||||
<hr class="border-1 border-emphasis" />
|
||||
<div class="row">
|
||||
<div class="col-5 labels">
|
||||
Lowest RMSD:<br>
|
||||
Computed Surface Tension:<br>
|
||||
Best Radius of Curvature:<br>
|
||||
Best Shape Factor:<br>
|
||||
Best Initial X Coordinate:<br>
|
||||
Best Initial Angle:<br>
|
||||
Lapsed Time in Seconds:<br>
|
||||
Lapsed Time (secs)):<br>
|
||||
</div>
|
||||
<div class="col">
|
||||
asdsadsa
|
||||
{{ results.lowestRMSD }} <br>
|
||||
{{ results.computedSurfaceTension }} <br>
|
||||
{{ results.bestRadiusCurvature }} <br>
|
||||
{{ results.bestShapeFactor }} <br>
|
||||
{{ results.bestInitialXCoordinate }} <br>
|
||||
{{ results.bestInitialAngle }} <br>
|
||||
{{ results.lapsedTime }} <br>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user