...
 
Commits (3)
# file containing output folder path
MyPath: "/Xnfs/convection/Stage_LG_2020/"
......@@ -59,9 +59,9 @@ class TLCExperiment:
"""
A,B = Calibration.AB
A = A.repeat(H.shape[0]//grain, axis=0).repeat(H.shape[1]//grain, axis=1)
B = B.repeat(H.shape[0]//grain, axis=0).repeat(H.shape[1]//grain, axis=1)
for picture in self.pictures:
A = A.repeat(Calibration.grain, axis=0).repeat(Calibration.grain, axis=1)
B = B.repeat(Calibration.grain, axis=0).repeat(Calibration.grain, axis=1)
for picture in self.pictures():
H = cv2.cvtColor(picture,cv2.COLOR_BGR2HSV)[:,:,0]
yield A*H + B
......@@ -85,9 +85,10 @@ class TLCCalibration:
"""
Class which assembles all calibration points used for a TLC calibration
"""
def __init__(self,Name,ListFixedTemperaturePoints):
def __init__(self,Name,ListFixedTemperaturePoints,grain):
self.Name = Name
self.ListFixedTemperaturePoints = ListFixedTemperaturePoints
self.grain = grain
# We create calibration folder if it doesn't exist
if not os.path.isdir("{}Processed_DATA/{}/".format(MyPath,self.Name)):
......@@ -221,22 +222,37 @@ class TLCCalibration:
index = 0
for manip in self.ListFixedTemperaturePoints:
H[:,:,index] = manip.MeanHSV[:,:,0]
T[:,:,index] = np.ones((self.ListFixedTemperaturePoints[0].shape[0]//grain,self.ListFixedTemperaturePoints[0].shape[1]//grain))*manip.MeanT
T[:,:,index] = (np.ones((self.ListFixedTemperaturePoints[0].shape[0]//grain,self.ListFixedTemperaturePoints[0].shape[1]//grain))*manip.MeanT).T
index+=1
print(H[300,300,:])
print(T[300,300,:])
A = np.zeros((H.shape[0],H.shape[1]))
B = np.zeros((H.shape[0],H.shape[1]))
for i in range(H.shape[0]):
for j in range(H.shape[1]):
a0,a_err, b0, b_err, plat = fit_affine(H[i,j,:], T[i,j,:],1e-9,1e-9)
a0,a_err, b0, b_err, plat = fit_affine(H[i,j,:], T[i,j,:],1e-5,1e-5)
A[i,j] = a0
B[i,j] = b0
if plat == 1 :
print((i,j))
# if (i,j)==(300,300): #debug
# print(a0,b0) #debug
# if plat == 1 :
# print((i,j))
with h5py.File("{}Processed_DATA/{}/Calibration.h5".format(MyPath,self.Name),'a') as f:
try:
del f['A']
print('Old data suppressed')
except KeyError as e:
print('No old data to suppress')
f.create_dataset('A',data=A)
f.create_dataset('B',data=B)
try:
del f['B']
print('Old data suppressed')
except KeyError as e:
print('No old data to suppress')
f.create_dataset('B',data=B)
@property
def AB(self):
......@@ -280,7 +296,7 @@ class TLCTempCalibrate(TLCExperiment):
"""
Return Mean HSV picture for this experiment
"""
with h5py.File("{}Processed_DATA/{}/MeanHSV.h5".format(MyPath,self.CalibrationName),'a') as f:
with h5py.File("{}Processed_DATA/{}/MeanHSV.h5".format(MyPath,self.CalibrationName),'r') as f:
return f['ImHSV_{}_degre'.format(self.Temperature)][()]
@property
......@@ -288,7 +304,7 @@ class TLCTempCalibrate(TLCExperiment):
"""
Return mean T vertical profil
"""
with h5py.File("{}Processed_DATA/{}/MeanT.h5".format(MyPath,self.CalibrationName),'a') as f:
with h5py.File("{}Processed_DATA/{}/MeanT.h5".format(MyPath,self.CalibrationName),'r') as f:
return f['T_{}_degre'.format(self.Temperature)][()]
......@@ -484,7 +500,15 @@ CalibrationTotale = TLCCalibration('CalibrationTemperature',
CalibrationTemperature_22a_C,
CalibrationTemperature_22b_C,
CalibrationTemperature_23_C,
CalibrationTemperature_24_C])
CalibrationTemperature_24_C],
10)
CalibrationPasTotale = TLCCalibration('CalibrationTemperature2',
[CalibrationTemperature_20_C,
CalibrationTemperature_21_C,
CalibrationTemperature_22a_C,
CalibrationTemperature_22b_C,
CalibrationTemperature_23_C],
10)
#############################################################################################################################################
......