Commit f7a9f15c authored by Dominique Piche's avatar Dominique Piche

new tools designs

parent 1c05b9a8
......@@ -269,14 +269,6 @@ class MecaRobotForDosimetry(MecaRobot):
np.savetxt('Data/x_calibration_data.txt', x_axis_signal, delimiter = ',')
np.savetxt('Data/y_calibration_data.txt', y_axis_signal, delimiter = ',')
np.savetxt('Data/z_calibration_data.txt', z_axis_signal, delimiter = ',')
# with open('Data/x_calibration_data.txt', 'w+') as fichier:
# fichier.write(np.array2string(x_axis_signal))
# with open('Data/y_calibration_data.txt', 'w+') as fichier:
# fichier.write(np.array2string(y_axis_signal))
# with open('Data/z_calibration_data.txt', 'w+') as fichier:
# fichier.write(np.array2string(z_axis_signal))
self.source_offset = np.array([x_max, y_max, z_max])
......
No preview for this file type
......@@ -8,13 +8,11 @@ def get_spherical_coordinates(x, y, z):
theta = np.arccos(z/r) * 180 / np.pi
return r, theta
def export_tg43_dose_rate(number_of_scintillators=1):
def export_tg43_dose_rate(number_of_scintillators=1, show_figure=False):
# Exports the dose rate corresponding to each dwell position in the Data folder calculatead using the TG43 formalism.
seed = pytg43.Seed('Flexisource')
scintillators_positions = []
for scintillator in range(number_of_scintillators):
cart_coords = np.genfromtxt('Data/scintillator_{}_position_relative_to_source.txt'.format(scintillator+1), delimiter=',') / 10
x, y, z = cart_coords[:, 0], cart_coords[:, 1], cart_coords[:, 2]
......@@ -24,34 +22,63 @@ def export_tg43_dose_rate(number_of_scintillators=1):
np.savetxt('Data/scintillator_{}_tg43_dose_rate.txt'.format(scintillator+1), dose, delimiter=',')
def export_trajectory_graph(scintillator_to_plot=1, show_figure=True):
if show_figure:
plt.plot(dose)
plt.title('Scintillator {} TG43 dose rate'.format(scintillator+1))
plt.xlabel('Dwell position')
plt.ylabel('Dose []')
plt.show()
def export_measured_dose_rate(show_figure=False):
calibration_matrix = np.array([[1,0,0,0],[0,1,0,0],[0,0,1,0]])
scintillators_signal = np.loadtxt('Data/scintillators_signal.txt', delimiter=',')
try:
dose = np.matmul(calibration_matrix, np.transpose(scintillators_signal))
except ValueError:
print('Calibration matrix for experimental dose rate only implemented for 4 signals channels.')
for scintillator in range(3):
np.savetxt('Data/scintillator_{}_measured_dose_rate.txt'.format(scintillator+1), dose[scintillator, :], delimiter=',')
if show_figure:
plt.plot(dose[scintillator, :], label='Scintillator {}'.format(scintillator+1))
if show_figure:
plt.legend()
plt.show()
def export_trajectory_graph(number_of_scintillators=1, show_figure=False):
# Exports a PNG of the robot trajectory graph correspoding to the positions in the Data folder.
data = np.genfromtxt('Data/scintillator_{}_position_relative_to_source.txt'.format(scintillator_to_plot), delimiter=',')
for scintillator in range(number_of_scintillators):
data = np.genfromtxt('Data/scintillator_{}_position_relative_to_source.txt'.format(scintillator+1), delimiter=',')
x, y, z = data[:,0], data[:,1], data[:,2]
x, y, z = np.round(x, 10), np.round(y, 10), np.round(z, 10)
x, y, z = data[:,0], data[:,1], data[:,2]
x, y, z = np.round(x, 10), np.round(y, 10), np.round(z, 10)
NPOINTS = len(x)
COLOR='blue'
NPOINTS = len(x)
COLOR='blue'
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
for i in range(NPOINTS-1):
ax.plot(x[i:i+2],y[i:i+2],z[i:i+2], alpha=float(i+int(NPOINTS/10))/(NPOINTS+int(NPOINTS/10+1)),color=COLOR)
for i in range(NPOINTS-1):
ax.plot(x[i:i+2],y[i:i+2],z[i:i+2], alpha=float(i+int(NPOINTS/10))/(NPOINTS+int(NPOINTS/10+1)),color=COLOR)
ax.scatter(0,0,0, color = 'red', label = 'Source')
ax.set_xlabel('x [mm]')
ax.set_ylabel('y [mm]')
ax.set_zlabel('z [mm]')
ax.scatter(0,0,0, color = 'red', label = 'Source')
ax.set_xlabel('x [mm]')
ax.set_ylabel('y [mm]')
ax.set_zlabel('z [mm]')
ax.set_title('Scintillator {} trajectory'.format(scintillator+1))
ax.legend()
ax.legend()
plt.savefig('Data/trajectory_scint_{}.png'.format(scintillator_to_plot), dpi=600)
plt.savefig('Data/trajectory_scint_{}.png'.format(scintillator+1), dpi=600)
if show_figure:
plt.show()
if show_figure:
plt.show()
def export_list_of_commands():
# Writes in the list_of_movement_commands.txt file all of the movement commands in the log.txt file. These can then be copy pasted
......@@ -71,4 +98,9 @@ def export_list_of_commands():
break
else:
export_file.write(line[6:])
\ No newline at end of file
def export_all(number_of_scintillators=1, show_figure=False):
export_tg43_dose_rate(number_of_scintillators=number_of_scintillators, show_figure=show_figure)
export_measured_dose_rate(show_figure=show_figure)
export_trajectory_graph(number_of_scintillators=number_of_scintillators,show_figure=show_figure)
export_list_of_commands()
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment