Commit 5ac77bee authored by Jadracka's avatar Jadracka
Browse files

Initial commit

parent 0c27b31c
Hor_Left_Top PQL6_8 1408.862014 399.989162 100.059013
Hor_Left_Top PQL6_2 2068.352084 399.983805 100.085585
Hor_Left_Top PQK62_8 129.302065 0.000000 100.000000
Hor_Left_Top PQK62_2 509.382050 0.019160 100.048445
Hor_Left_Top PQK36_8 2998.812002 399.997208 100.063751
Hor_Left_Top PQK36_2 3379.232068 399.996077 100.055971
Hor_Top_Left MD_TUL 1735.859769 0.054064 100.027971
Hor_Top_Left MD_TDL 2395.649778 0.057877 100.029289
Hor_Top_Left UP_TUL 456.129967 0.000000 100.000000
Hor_Top_Left UP_TDL 835.749805 0.069976 100.017143
Hor_Top_Left DN_TUL 3326.789880 0.043239 100.013060
Hor_Top_Left DN_TDL 3706.809774 0.051841 100.022802
Hor_Top_Right MD_TUR 1347.433236 0.379660 100.104089
Hor_Top_Right MD_TDR 2007.083175 0.370033 100.098843
Hor_Top_Right UP_TUR 67.024153 0.000000 100.000000
Hor_Top_Right UP_TDR 447.063234 0.376379 100.037071
Hor_Top_Right DN_TUR 2937.623138 0.365499 100.081491
Hor_Top_Right DN_TDR 3318.363085 0.356695 100.081374
Hor_Right_Top MD_RUT 1611.800022 0.017594 100.004346
Hor_Right_Top MD_RDT 2271.429996 0.020763 100.016376
Hor_Right_Top UP_RUT 332.010052 399.969623 100.000719
Hor_Right_Top UP_RDT 712.010144 399.983731 99.984032
Hor_Right_Top DN_RUT 3201.500143 0.002058 100.000642
Hor_Right_Top DN_RDT 3581.670193 0.000000 100.000000
Hor_Right_Bottom DN_RDB 3381.992053 399.989859 99.966048
Hor_Right_Bottom DN_RUB 3002.092000 399.984692 99.978413
Hor_Right_Bottom MD_RDB 2071.542002 399.991288 99.978931
Hor_Right_Bottom MD_RUB 1412.092116 0.000000 100.000000
Hor_Right_Bottom UP_RDB 512.222157 399.976654 99.928094
Hor_Right_Bottom UP_RUB 132.432055 399.956272 99.926508
Hor_Left_Bottom MD_LDB 2169.320079 399.987985 100.004056
Hor_Left_Bottom MD_LUB 1509.640094 0.000000 100.000000
Hor_Left_Bottom UP_LDB 610.510026 399.981705 99.998824
Hor_Left_Bottom UP_LUB 230.430066 399.952462 99.963354
Hor_Left_Bottom DN_LDB 3480.700065 399.987817 99.999011
Hor_Left_Bottom DN_LUB 3101.000020 399.983518 99.990033
Hor_Left_Top MD_LUT 1408.862214 399.989162 100.059013
Hor_Left_Top MD_LDT 2068.353084 399.983805 100.085585
Hor_Left_Top UP_LUT 129.302165 0.000000 100.000000
Hor_Left_Top UP_LDT 509.385050 0.019160 100.048445
Hor_Left_Top DN_LUT 2998.812012 399.997208 100.063751
Hor_Left_Top DN_LDT 3379.233068 399.996077 100.055971
Hor_Top_Left MD_TUL 1735.859869 0.054064 100.027971
Hor_Top_Left MD_TDL 2395.649678 0.057877 100.029289
Hor_Top_Left UP_TUL 456.129999 0.000000 100.000000
Hor_Top_Left UP_TDL 835.749825 0.069976 100.017143
Hor_Top_Left DN_TUL 3326.789980 0.043239 100.013060
Hor_Top_Left DN_TDL 3706.809974 0.051841 100.022802
Hor_Top_Right MD_TUR 1347.434236 0.379660 100.104089
Hor_Top_Right MD_TDR 2007.084175 0.370033 100.098843
Hor_Top_Right UP_TUR 67.024453 0.000000 100.000000
Hor_Top_Right UP_TDR 447.064234 0.376379 100.037071
Hor_Top_Right DN_TUR 2937.633138 0.365499 100.081491
Hor_Top_Right DN_TDR 3318.363185 0.356695 100.081374
Hor_Right_Top MD_RUT 1611.801022 0.017594 100.004346
Hor_Right_Top MD_RDT 2271.43 0.020763 100.016376
Hor_Right_Top UP_RUT 332.012052 399.969623 100.000719
Hor_Right_Top UP_RDT 712.010144 399.983731 99.984032
Hor_Right_Top DN_RUT 3201.501143 0.002058 100.000642
Hor_Right_Top DN_RDT 3581.672193 0.000000 100.000000
Hor_Right_Bottom DN_RDB 3381.993012 399.989859 99.966048
Hor_Right_Bottom DN_RUB 3002.092356 399.984692 99.978413
Hor_Right_Bottom MD_RDB 2071.542685 399.991288 99.978931
Hor_Right_Bottom MD_RUB 1412.092234 0.000000 100.000000
Hor_Right_Bottom UP_RDB 512.222222 399.976654 99.928094
Hor_Right_Bottom UP_RUB 132.432155 399.956272 99.926508
Hor_Left_Bottom MD_LDB 2169.325169 399.987985 100.004056
Hor_Left_Bottom MD_LUB 1509.643252 0.000000 100.000000
Hor_Left_Bottom UP_LDB 610.510321 399.981705 99.998824
Hor_Left_Bottom UP_LUB 230.430648 399.952462 99.963354
Hor_Left_Bottom DN_LDB 3480.700642 399.987817 99.999011
Hor_Left_Bottom DN_LUB 3101.000354 399.983518 99.990033
Hor_Left_Top MD_LUT 1408.862014 399.989162 100.059013
Hor_Left_Top MD_LDT 2068.352084 399.983805 100.085585
Hor_Left_Top UP_LUT 129.302065 0.000000 100.000000
Hor_Left_Top UP_LDT 509.382050 0.019160 100.048445
Hor_Left_Top DN_LUT 2998.812002 399.997208 100.063751
Hor_Left_Top DN_LDT 3379.232068 399.996077 100.055971
Hor_Top_Left MD_TUL 1735.859769 0.054064 100.027971
Hor_Top_Left MD_TDL 2395.649778 0.057877 100.029289
Hor_Top_Left UP_TUL 456.129967 0.000000 100.000000
Hor_Top_Left UP_TDL 835.749805 0.069976 100.017143
Hor_Top_Left DN_TUL 3326.789880 0.043239 100.013060
Hor_Top_Left DN_TDL 3706.809774 0.051841 100.022802
Hor_Top_Right MD_TUR 1347.433236 0.379660 100.104089
Hor_Top_Right MD_TDR 2007.083175 0.370033 100.098843
Hor_Top_Right UP_TUR 67.024153 0.000000 100.000000
Hor_Top_Right UP_TDR 447.063234 0.376379 100.037071
Hor_Top_Right DN_TUR 2937.623138 0.365499 100.081491
Hor_Top_Right DN_TDR 3318.363085 0.356695 100.081374
Hor_Right_Top MD_RUT 1611.800022 0.017594 100.004346
Hor_Right_Top MD_RDT 2271.429996 0.020763 100.016376
Hor_Right_Top UP_RUT 332.010052 399.969623 100.000719
Hor_Right_Top UP_RDT 712.010144 399.983731 99.984032
Hor_Right_Top DN_RUT 3201.500143 0.002058 100.000642
Hor_Right_Top DN_RDT 3581.670193 0.000000 100.000000
Hor_Right_Bottom DN_RDB 3381.992053 399.989859 99.966048
Hor_Right_Bottom DN_RUB 3002.092000 399.984692 99.978413
Hor_Right_Bottom MD_RDB 2071.542002 399.991288 99.978931
Hor_Right_Bottom MD_RUB 1412.092116 0.000000 100.000000
Hor_Right_Bottom UP_RDB 512.222157 399.976654 99.928094
Hor_Right_Bottom UP_RUB 132.432055 399.956272 99.926508
Hor_Left_Bottom MD_LDB 2169.320079 399.987985 100.004056
Hor_Left_Bottom MD_LUB 1509.640094 0.000000 100.000000
Hor_Left_Bottom UP_LDB 610.510026 399.981705 99.998824
Hor_Left_Bottom UP_LUB 230.430066 399.952462 99.963354
Hor_Left_Bottom DN_LDB 3480.700065 399.987817 99.999011
Hor_Left_Bottom DN_LUB 3101.000020 399.983518 99.990033
Girder_17 3580.0332 319.2296 -450.0000
Girder_15 3200.3054 319.1768 -450.0000
Girder_11 2266.3983 319.0814 -450.0001
Girder_7 1606.9622 319.2989 -450.0001
Girder_3 702.9308 319.2946 -450.0000
Girder_1 323.1475 318.6504 -450.0000
Girder_2 323.2252 -319.2821 -450.0000
Girder_4 702.6763 -318.7309 -450.0001
Girder_8 1607.7318 -319.0473 -450.0000
Girder_12 2267.5061 -319.2039 -450.0000
Girder_16 3200.5821 -318.7688 -450.0000
Girder_18 3580.6768 -318.6828 -450.0000
Girder_13 2744.5550 319.1234 -259.6821
Girder_5 1169.5550 319.0670 -259.7249
Girder_6 1169.5549 -318.9865 -259.5156
Girder_14 2744.5548 -318.8855 -259.2571
Girder_10 1932.2860 -318.9328 -445.8040
Girder_9 1931.9852 319.0037 -446.5225
PQK36_1 3580.1294 319.1680 -259.5614
PQK36_2 3580.3919 318.9997 260.1757
PQK36_3 3580.8512 190.7336 381.6511
PQK36_4 3580.3099 -189.7807 381.6179
PQK36_5 3579.9814 -319.0230 260.1766
PQK36_6 3580.4897 -318.7743 -258.9590
PQK36_7 3200.3299 319.1432 -259.6021
PQK36_8 3200.3969 319.0515 260.1284
PQK36_9 3200.7969 190.1483 381.5622
PQK36_10 3200.6803 -190.3799 381.2250
PQK36_11 3199.9170 -319.2283 259.8524
PQK36_12 3200.4036 -318.8921 -259.5136
PQK62_1 703.1960 319.3136 -260.0235
PQK62_2 703.9230 319.3658 260.7164
PQK62_3 703.3925 189.9108 381.5140
PQK62_4 702.9911 -189.4704 381.8484
PQK62_5 703.8201 -318.9195 260.0304
PQK62_6 702.9835 -318.7815 -259.3361
PQK62_7 323.3100 318.8284 -259.5053
PQK62_8 323.7539 319.3146 260.7217
PQK62_9 322.6448 190.0499 381.4287
PQK62_10 322.9863 -190.1227 381.2161
PQK62_11 323.4082 -319.0943 260.3574
PQK62_12 323.2741 -319.2318 -259.9535
PQL6_1 2266.6580 319.0100 -260.0714
PQL6_2 2267.3698 318.8141 260.5527
PQL6_3 2267.3081 189.9880 381.2811
PQL6_4 2267.4610 -189.9583 381.4642
PQL6_5 2267.1597 -318.6378 260.3398
PQL6_6 2267.4131 -319.0519 -259.2477
PQL6_7 1607.1649 319.1058 -259.4590
PQL6_8 1607.7177 318.5788 260.4426
PQL6_9 1607.6688 189.9519 381.4232
PQL6_10 1607.6655 -190.1636 381.5662
PQL6_11 1607.6781 -318.4554 259.7479
PQL6_12 1607.7174 -318.8883 -259.3180
# -*- coding: utf-8 -*-
"""
Created on Thu Feb 11 10:50:35 2021
@author: jbarker
"""
#import scipy as sp
import numpy as np
#import matplotlib as mp
#import sys
#import string
#import math as m
import re
import config as cg
import functions as fc
from operator import itemgetter
#from collections import namedtuple
Coords_file = open(cg.Coords_file_name,'r')
Nominal_coords = {}
for line in Coords_file.readlines():
"""Reads in and parses coordinates file. Ignores point notes at the end.
It can handle multiple occurences of delimeters,
but not a combination of them."""
words = re.split(';+|,+|\t+| +',line.strip())
Nominal_coords[words[0]] = (float(words[1]), float(words[2]), float(words[3]))
del line
Coords_file.close()
if cg.Using_CAD_compare:
#Calculates nominal distances in ideal lines as seen in config file
nominal_distances_in_lines = {}
for line, Tupple_of_points in cg.Lines_of_sight.items():
First_point_Coords = Nominal_coords[Tupple_of_points[0]]
distances_list = []
for point in Tupple_of_points[1:]:
distance = fc.slope_distance(First_point_Coords,Nominal_coords[point])
distances_list.append(distance)
nominal_distances_in_lines[line] = distances_list
Meas_file = open(cg.Measurements_file_name,'r')
Meas = {}
Measured_lines = []
Points_on_measured_lines = {}
measured_distances = {}
full_measurement_matrix = {}
for row in Meas_file.readlines():
"""
- Reads in and parses Meas_file.
- The format is string Group name (aka Line of sight) 'space'
string Point name 'space' float Distance [mm] 'space'
float Hz angle [gon] 'space' float V angle [gon].
- Ignores point notes at the end.
- It can handle multiple occurences of delimeters but not a combination of
them.
- It creates
- Meas - Dictionary of list of Tuples where the name of the Line of
sight is the key and tuples are measured values to the points
- full measurement matrix - a Dictionary of lines which contains a
Dictionary of points, where Point name is
a key and measured values are triplet tuple
- measured_distances - Dictionary of measured disances"""
words = re.split(';+|,+|\t+| +',row.strip())
if str(words[0]) not in Measured_lines:
Measured_lines.append(words[0])
if words[0] not in Meas:
Meas[words[0]] = [(float(words[2]), float(words[3]), float(words[4]))]
measured_distances[words[0]] = (words[2],)
full_measurement_matrix[words[0]] = {}
full_measurement_matrix[words[0]][words[1]] = \
(float(words[2]), float(words[3]), float(words[4]))
else:
Meas[words[0]]= Meas[words[0]]+[(float(words[2]), float(words[3]), \
float(words[4]))]
measured_distances[words[0]] = measured_distances[words[0]] + \
(words[2],)
full_measurement_matrix[words[0]][words[1]] = \
(float(words[2]), float(words[3]), float(words[4]))
del words, row
# =============================================================================
# Finfing the minimal distance measured in each line and storing it, together
# in dictionary of lists. Dictionary keys = line names, values = list of pairs:
# Point_name, measured distance (first of the triplet tuple of measurements)
# =============================================================================
minimal_distances_in_line = {}
for line in full_measurement_matrix:
"""itemgetter(which position I want to consider)[returns what is needed
- without [] whole tuple]"""
minimal_distances_in_line[line] = []
distance = min(Meas[line],key=itemgetter(0))[0]
"""some pretty cool mumbo jumbo! Using the .values() and .keys()
for a nested dictionary [line], searching for key of the nested
dictionary (point name) using .index(), where the index value is the
minimum distance found from the value=tuple of measured triplet of the
key=point"""
minimal_distance_point_name = \
(list(full_measurement_matrix[line].keys()) \
[list(full_measurement_matrix[line].values()).index(min(Meas[line],\
key=itemgetter(0)))])
minimal_distances_in_line[line] = [minimal_distance_point_name, distance]
del minimal_distance_point_name, distance
for dictionary in full_measurement_matrix:
# Points on measured lines dictionary of key = line name and list = points
Points_on_measured_lines[dictionary] = \
list(full_measurement_matrix[dictionary].keys())
del dictionary
# =============================================================================
# Calculating the nominal and real differential distances for each point
# of the line except the one closest to the tracker (=beginning of the line).
# Storing those in dictionary of lists. Key is the line's name.
# =============================================================================
nominal_distances_measured = {}
for line in measured_distances:
distances_list = []
for point in Points_on_measured_lines[line]:
if point != minimal_distances_in_line[line][0]:
delta_distance = fc.slope_distance(Nominal_coords \
[minimal_distances_in_line[line][0]],Nominal_coords[point])
distances_list.append(delta_distance)
nominal_distances_measured[line] = distances_list
del distances_list, delta_distance, line, point
real_distances_measured = {}
for line in measured_distances:
distances_list = []
for distance in measured_distances[line]:
if float(distance) != float(minimal_distances_in_line[line][1]):
delta_distance = float(distance) - \
float(minimal_distances_in_line[line][1])
distances_list.append(delta_distance)
real_distances_measured[line] = distances_list
del distances_list, delta_distance, line, distance
differences_real_nominal_distances = {}
for line in nominal_distances_measured:
diff = np.subtract((nominal_distances_measured[line]), \
(real_distances_measured[line]))
differences_real_nominal_distances[line] = list(diff)
if cg.Line_differences_checking:
if diff[0] > 1:
print('discrapancy in:',line,'\n')
else:
print('It looks ok')
del line, diff
# -*- coding: utf-8 -*-
"""
Created on Thu Feb 11 10:54:43 2021
@author: jbarker
"""
"""
_____ __ _ _ _ __ _ _
/ ____| / _(_) | | (_) / _(_) |
| | ___ _ __ | |_ _ __ _ _ _ _ __ __ _| |_ _ ___ _ __ | |_ _| | ___
| | / _ \| '_ \| _| |/ _` | | | | '__/ _` | __| |/ _ \| '_ \ | _| | |/ _ \
| |___| (_) | | | | | | | (_| | |_| | | | (_| | |_| | (_) | | | | | | | | | __/
\_____\___/|_| |_|_| |_|\__, |\__,_|_| \__,_|\__|_|\___/|_| |_| |_| |_|_|\___|
__/ |
|___/
"""
"""Data analysis tools"""
Comparing_nominal2real = False
Which_epochs = (0,) #the comma must stay, otherwise the variable will be just int
Using_CAD_compare = False
Line_differences_checking = False
"""Nominal CAD coordinates of Fiducials
Standard SA format with spaces as delimiters and no comments:
Point name 'space' X [mm] 'space' Y [mm] 'space' Z [mm]
"""
Coords_file_name = "PtOut.txt"
"""Measured Lines
Standard SA format with spaces as delimiters and no comments:
Group aka Line name 'space' Point name 'space' Sd [mm] 'space' Hz [gon] 'space' V [gon]
"""
Epochs_dictionary = {}
Epochs_dictionary[0] = "Epoch1.txt"
Epochs_dictionary[1] = "Epoch2.txt"
if len(Which_epochs) == 1:
Measurements_file_name = Epochs_dictionary[Which_epochs[0]]
elif len(Which_epochs) == 2:
Measurements_file_name = Epochs_dictionary[Which_epochs[0]]
Measurements_file_name_2 = Epochs_dictionary[Which_epochs[1]]
elif len(Which_epochs) == 0:
print('No epoch(s) were chosen to analyse. Go to config.py and change it in a variable Which_epochs')
else:
print('Too many epochs are chosen, choose just two. Go and correct it in Which_epochs in config.py.')
Lines_of_sight = {
'Hor_Left_Bottom': ('PQK62_7', 'PQK62_1','Girder_5','PQL6_7', 'PQL6_1','Girder_13', 'PQK36_7', 'PQK36_1'),
'Hor_Left_Top': ('PQK62_8', 'PQK62_2','PQL6_8', 'PQL6_2','PQK36_8', 'PQK36_2'),
'Hor_Top_Left': ('PQK62_9', 'PQK62_3','PQL6_9', 'PQL6_3','PQK36_9', 'PQK36_3'),
'Hor_Top_Right': ('PQK62_10', 'PQK62_4','PQL6_10', 'PQL6_4','PQK36_10', 'PQK36_4'),
'Hor_Right_Top': ('PQK62_11', 'PQK62_5','PQL6_11', 'PQL6_5','PQK36_11', 'PQK36_5'),
'Hor_Right_Bottom': ('PQK62_12', 'PQK62_6','Girder_6','PQL6_12', 'PQL6_6','Girder_14', 'PQK36_12', 'PQK36_6'),
'IFM_Left_DN': ('PQL6_1','Girder_11'),
'IFM_Left_UP': ('PQL6_7','Girder_7'),
'IFM_Right_UP': ('PQL6_12','Girder_8'),
'IFM_Right_DN': ('PQL6_6','Girder_12'),
'Ver_Left_DN_DN': ('PQK36_2','PQK36_1','Girder_17'),
'Ver_Left_DN_UP': ('PQK36_8','PQK36_7','Girder_15'),
'Ver_Left_MD_DN': ('PQL6_2','PQL6_1','Girder_11'),
'Ver_Left_MD_UP': ('PQL6_8','PQL6_7','Girder_7'),
'Ver_Left_UP_DN': ('PQK62_2','PQK62_1','Girder_3'),
'Ver_Left_UP_UP': ('PQK62_8','PQK62_7','Girder_1'),
'Ver_Right_DN_DN': ('PQK36_5','PQK36_6','Girder_18'),
'Ver_Right_DN_UP': ('PQK36_11','PQK36_12','Girder_16'),
'Ver_Right_MD_DN': ('PQL6_5','PQL6_6','Girder_12'),
'Ver_Right_MD_UP': ('PQL6_11','PQL6_12','Girder_8'),
'Ver_Right_UP_DN': ('PQK62_5','PQK62_6','Girder_4'),
'Ver_Right_UP_UP': ('PQK62_11','PQK62_12','Girder_2'),
'Diag_Left_DN': ('PQK36_8','PQL6_1','Girder_9'),
'Diag_Left_UP': ('PQK62_2','PQL6_7','Girder_9'),
'Diag_Right_DN': ('PQK36_11','PQL6_6','Girder_10'),
'Diag_Right_UP': ('PQK62_5','PQL6_12','Girder_10'),
'Diag_Top_DN': ('PKQ36_10','PQL6_3'),
'Diag_Top_UP': ('PKQ62_4','PQL6_9')
}
\ No newline at end of file
# -*- coding: utf-8 -*-
"""
Created on Thu Feb 11 12:53:33 2021
@author: jbarker
"""
import math as m
from numpy import pi
"""
______ _ _
| ___| | | (_)
| |_ _ _ _ __ ___| |_ _ ___ _ __ ___
| _| | | | '_ \ / __| __| |/ _ \| '_ \/ __|
| | | |_| | | | | (__| |_| | (_) | | | \__ \
\_| \__,_|_| |_|\___|\__|_|\___/|_| |_|___/
"""
def slope_distance(X1,Y1,Z1,X2,Y2,Z2):
"""Function calculates slope distance from point 1 to point 2
from given X1, Y1, Z1, X2, Y2, Z2
THIS IS MY FIRST OVERLOADED FUNCTION!!!!"""
dX = X2 - X1
dY = Y2 - Y1
dZ = Z2 - Z1
sd = m.sqrt(pow(dX,2)+pow(dY,2)+pow(dZ,2))
return sd
def slope_distance(Point_From,Point_To):
"""Function calculates slope distance from point 1 to point 2
from given Tupples (X1, Y1, Z1) and (X2, Y2, Z2)"""
dX = Point_To[0] - Point_From[0]
dY = Point_To[1] - Point_From[1]
dZ = Point_To[2] - Point_From[2]
sd = m.sqrt(pow(dX,2)+pow(dY,2)+pow(dZ,2))
return sd
def gon2rad(gons):
"""Function takes an angle in gons, transforms to a float and converts
to radians"""
rads = float(gons)*pi/200
return rads
def rad2gon(rads):
"""Function takes an angle in gons, transforms to a float and converts
to radians"""
gons = float(rads)*200/pi
return gons
def cosg(angle):
"""Function takes angle in gons and calculates cosinus"""
result = m.cos(gon2rad(angle))
return result
def sing(angle):
"""Function takes angle in gons and calculates sinus"""
result = m.sin(gon2rad(angle))
return result
\ 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