Commit 38f86d2d authored by Jadracka's avatar Jadracka
Browse files

Epoch 1 added

All checks and calcs as for Epoch 0 were added for Epoch 1 as well. Further cleaning of local variables to prevent cross-talk between Epochs.
parent 39580b88
......@@ -10,7 +10,7 @@ import numpy as np
#import sys
#import string
import math as m
#import math as m
import config as cg
import functions as fc
......@@ -26,16 +26,22 @@ Nominal_coords = fc.Coords_read_in(cg.Coords_file_name)
LoS_measurements = fc.Measurements_read_in(cg.LoS_Measurements_file_name)
Pol_measurements = fc.Measurements_read_in(cg.Pol_Measurements_file_name)
if len(cg.Which_epochs) > 1:
LoS_measurements_1 = fc.Measurements_read_in(
LoS_measurements_E1 = fc.Measurements_read_in(
cg.LoS_Measurements_file_name_1)
Pol_measurements_1 = fc.Measurements_read_in(
Pol_measurements_E1 = fc.Measurements_read_in(
cg.Pol_Measurements_file_name_1)
# =============================================================================
# Initial checks for LoS measurements.
# If you want to print, change: Print_typos to True
# If you want to print, change: Print_typos to True in config.py
# =============================================================================
"""
___ _ __
| __|_ __ ___ __| |_ / \
| _|| '_ \/ _ \/ _| ' \ | () |
|___| .__/\___/\__|_||_| \__/
|_|
"""
# Checking point names for typos and misspells and creating the list of
# measured points in lines sorted based on the config file definition:
sorted_measured_points_in_lines = {}
......@@ -51,7 +57,7 @@ for line in LoS_measurements:
# printing which lines are in measurements input but are not in the
# default naming either due to typo or just simply missing in the nominal
# LoS decription
print("Line %s was measured, but not expected." % (line))
print("Epoch0: Line %s was measured, but not expected." % (line))
measured_lines_all_good = False
else:
line_points_sorted = []
......@@ -62,35 +68,39 @@ for line in LoS_measurements:
if line_points_sorted != list(cg.Lines_of_sight[line]):
all_points_in_lines_measured = False
if cg.Print_typos:
print("Not all points were measured in %s line"% (line))
print("Epoch0: Not all points were measured in %s line"
% (line))
del line_points_sorted
for point in LoS_measurements[line]:
if (cg.Print_typos) and (point not in Nominal_coords):
print("Measured point with name %s in %s is not in the Nominal" \
" Coordinate file." % (point, line))
print("Epoch0: Measured point with name %s in %s is not in the "
"Nominal Coordinate file." % (point, line))
LoS_measured_points_all_good = False
if point not in cg.Lines_of_sight[line]:
LoS_measured_points_all_good = False
if cg.Print_typos:
print("Point %s does not nominally belong to %s line"
print("Epoch0: Point %s does not nominally belong to %s line"
% (point, line))
if point not in all_measured_points:
all_measured_points.append(point)
del line, point
for point in Nominal_coords.keys():
if (cg.Print_typos) and (point not in all_measured_points):
print("Point %s was not measured in any line." % (point))
print("Epoch0: Point %s was not measured in any line." % (point))
nominal_points_all_measured = False
del point
if (cg.Print_typos) and (measured_lines_all_good):
print("All measured lines were expected, no typos found.")
print("Epoch0: All measured lines were expected, no typos found.")
if (cg.Print_typos) and (LoS_measured_points_all_good):
print("All measured points are correct, in correct lines, no typos found.")
print("Epoch0: All measured points are correct, in correct lines, no typos"
" found.")
if (cg.Print_typos) and (nominal_points_all_measured):
print("All nominal points in IFM lines were measured at least once.")
print("Epoch0: All nominal points in IFM lines were measured at least "
"once.")
if (cg.Print_typos) and not (all_points_in_lines_measured):
print("Not all points in lines were measured. Continuing in analysis.")
print("Epoch0: Not all points in lines were measured. Continuing in "
"analysis.")
del all_measured_points, nominal_points_all_measured, \
......@@ -100,7 +110,7 @@ Pol_measurements_cart = {}
for instrument in Pol_measurements:
Pol_measurements_cart[instrument] = {}
for point in Pol_measurements[instrument]:
Pol_measurements_cart[instrument][point] = fc.polar2cart3D(
Pol_measurements_cart[instrument][point] = fc.polar2cart3Dgon(
Pol_measurements[instrument][point])
del instrument, point
......@@ -110,14 +120,14 @@ for instrument in Pol_measurements_cart:
Measured = fc.slope_distance(Pol_measurements_cart[instrument][
points[i]],Pol_measurements_cart[instrument][points[i-1]])
if points[i-1] not in Nominal_coords.keys() and cg.Print_typos:
print('Point %s measured by %s is not in Nominals.' %(points[i-1],
instrument))
print('Epoch0: Point %s measured by %s is not in Nominals.'
%(points[i-1], instrument))
if (points[i] in Nominal_coords.keys()) and ((points[i-1]) in
Nominal_coords.keys()):
Nominal = fc.slope_distance(Nominal_coords[points[i]],
Nominal_coords[points[i-1]])
delta = Nominal - Measured
del instrument, i
del instrument, i, points, Measured, Nominal
measured_distances_in_lines = {}
if cg.Using_nominal_compare:
......@@ -163,15 +173,152 @@ if measured_lines_all_good and LoS_measured_points_all_good:
differences_in_distances[line])
del line
else:
print("Analysis cannot be performed as there are typos and errors in "
"input data. Please correct before running the script again. "
"To help troubleshoot, change Print_typos in config.py to True.")
G17 = fc.StDev_XYZ_from_Polar(Nominal_coords['Girder_17'],cg.Dist_StDev,
cg.Ang_StDev,cg.Ang_StDev)
G18 = fc.StDev_XYZ_from_Polar(Nominal_coords['Girder_18'],cg.Dist_StDev,
cg.Ang_StDev,cg.Ang_StDev)
StDev1817 = fc.StDev_distance(Nominal_coords['Girder_17'],
Nominal_coords['Girder_18'],G17,G18)
print(StDev1817)
print("Analysis for Epoch 0 cannot be performed as there are typos and "
"errors in input data. Please correct before running the script "
"again. To help troubleshoot, change Print_typos in config.py to "
"True.")
"""___ _ _
| __|_ __ ___ __| |_ / |
| _|| '_ \/ _ \/ _| ' \ | |
|___| .__/\___/\__|_||_| |_|
|_| """
if len(cg.Which_epochs)>1:
# Checking point names for typos and misspells and creating the list of
# measured points in lines sorted based on the config file definition:
sorted_measured_points_in_lines_E1 = {}
all_measured_points_E1 = []
measured_lines_all_good_E1 = True
LoS_measured_points_all_good_E1 = True
#nominal_lines_all_measured = True #not checking at the moment
nominal_points_all_measured_E1 = True
all_points_in_lines_measured_E1 = True
for line in LoS_measurements_E1:
if (cg.Print_typos) and (line not in cg.Lines_of_sight):
# printing which lines are in measurements input but are not in the
# default naming either due to typo or just simply missing in the nominal
# LoS decription
print("Epoch1: Line %s was measured, but not expected." % (line))
measured_lines_all_good_E1 = False
else:
line_points_sorted = []
for point in cg.Lines_of_sight[line]:
if point in LoS_measurements_E1[line].keys():
line_points_sorted.append(point)
sorted_measured_points_in_lines_E1[line]= tuple(line_points_sorted)
if line_points_sorted != list(cg.Lines_of_sight[line]):
all_points_in_lines_measured_E1 = False
if cg.Print_typos:
print("Epoch 1: Not all points were measured in %s line"
% (line))
del line_points_sorted
for point in LoS_measurements_E1[line]:
if (cg.Print_typos) and (point not in Nominal_coords):
print("Epoch1: Measured point with name %s in %s is not in the"
" Nominal Coordinate file." % (point, line))
LoS_measured_points_all_good_E1 = False
if point not in cg.Lines_of_sight[line]:
LoS_measured_points_all_good_E1 = False
if cg.Print_typos:
print("Epoch1: Point %s does not nominally belong to %s "
"line" % (point, line))
if point not in all_measured_points_E1:
all_measured_points_E1.append(point)
del line, point
for point in Nominal_coords.keys():
if (cg.Print_typos) and (point not in all_measured_points_E1):
print("Epoch1: Point %s was not measured in any line." % (point))
nominal_points_all_measured_E1 = False
del point
if (cg.Print_typos) and (measured_lines_all_good_E1):
print("Epoch1: All measured lines were expected, no typos found.")
if (cg.Print_typos) and (LoS_measured_points_all_good_E1):
print("Epoch1: All measured points are correct, in correct lines, no "
"typos found.")
if (cg.Print_typos) and (nominal_points_all_measured_E1):
print("Epoch1: All nominal points in IFM lines were measured at least "
"once.")
if (cg.Print_typos) and not (all_points_in_lines_measured_E1):
print("Epoch1: Not all points in lines were measured. Continuing in "
"analysis.")
del all_measured_points_E1, nominal_points_all_measured_E1,\
all_points_in_lines_measured_E1
Pol_measurements_cart_E1 = {}
for instrument in Pol_measurements_E1:
Pol_measurements_cart_E1[instrument] = {}
for point in Pol_measurements_E1[instrument]:
Pol_measurements_cart_E1[instrument][point] = fc.polar2cart3Dgon(
Pol_measurements_E1[instrument][point])
del instrument, point
for instrument in Pol_measurements_cart_E1:
points = tuple(Pol_measurements_cart_E1[instrument].keys())
for i in range (1,len(points)):
Measured = fc.slope_distance(Pol_measurements_cart_E1[instrument][
points[i]],Pol_measurements_cart_E1[instrument][points[i-1]])
if points[i-1] not in Nominal_coords.keys() and cg.Print_typos:
print('Epoch1: Point %s measured by %s is not in Nominals.'
%(points[i-1],instrument))
if (points[i] in Nominal_coords.keys()) and ((points[i-1]) in
Nominal_coords.keys()):
Nominal = fc.slope_distance(Nominal_coords[points[i]],
Nominal_coords[points[i-1]])
delta = Nominal - Measured
del instrument, i, points, Measured, Nominal
measured_distances_in_lines_E1 = {}
if cg.Using_nominal_compare:
nominal_distances_in_line_E1 = {}
differences_in_distances_E1 = {}
StDev_distances_in_lines_E1 = {}
if measured_lines_all_good_E1 and LoS_measured_points_all_good_E1:
del measured_lines_all_good_E1, LoS_measured_points_all_good_E1
# Calculating distance deltas
for line in LoS_measurements_E1:
deltas = ()
if cg.Using_nominal_compare:
deltas_nominal = ()
for i in range (1,len(sorted_measured_points_in_lines_E1[line])):
delta = (LoS_measurements_E1[line][
sorted_measured_points_in_lines_E1[line][i]][0]
- LoS_measurements_E1[line][
sorted_measured_points_in_lines_E1[line][i-1]][0],)
deltas = deltas + delta
if cg.Using_nominal_compare:
d = fc.slope_distance(
Nominal_coords[
sorted_measured_points_in_lines_E1[line][i-1]],
Nominal_coords[
sorted_measured_points_in_lines_E1[line][i]])
deltas_nominal = deltas_nominal + (d,)
measured_distances_in_lines_E1[line] = deltas
if cg.Using_nominal_compare:
nominal_distances_in_line_E1[line] = deltas_nominal
del deltas_nominal
del line, i, delta, deltas, d
if cg.Using_nominal_compare:
for line in LoS_measurements_E1:
differences_in_distances_E1[line] = \
np.asarray(nominal_distances_in_line_E1[line]) \
- np.asarray(measured_distances_in_lines_E1[line])
StDev_distances_in_lines_E1[line] = np.std(
differences_in_distances_E1[line])
if StDev_distances_in_lines_E1[line] == 0:
StDev_distances_in_lines_E1[line] = None
differences_in_distances_E1[line] = tuple(
differences_in_distances_E1[line])
del line
else:
print("Analysis for Epoch 1 cannot be performed as there are typos and"
" errors in input data. Please correct before running the script"
" again. To help troubleshoot, change Print_typos in config.py "
"to True.")
print('End of the script')
# -*- coding: utf-8 -*-
"""
Created on Wed May 5 13:07:50 2021
@author: jbarker
"""
import functions as fc
class Point3DCart(dict):
def __init__(self, PointID, X, Y, Z):
self.PointID = PointID
self.X = X
self.Y = Y
self.Z = Z
def display(self):
print(f'PointID = {self.PointID}, X = {self.X}, '
f'Y = {self.Y}, Z = {self.Z}')
def trans2Pol(self):
return(self.PointID,fc.cart2polal3Dgon(self.X,self.Y,self.Z))
Point = Point3DCart('PQL6_12',138.13,12393.31,13.13)
class Point3DPol(dict):
def __init__(self, PointID, Sd, Hz, Z):
self.PointID = PointID
self.Sd = Sd
self.Hz = Hz
self.Z = Z
def display(self):
print(f'PointID = {self.PointID}, Sd = {self.Sd}, '
f'Hz = {self.Hz}, Z = {self.Z}')
def trans2Cart(self):
return(self.PointID,fc.polar2cart3Dgon(self.Sd,self.Hz,self.Z))
\ No newline at end of file
......@@ -17,11 +17,11 @@ Created on Thu Feb 11 10:54:43 2021
"""
"""Data analysis tools"""
"""CAN BE CHANGED"""
Which_epochs = (0,) #the comma must stay, otherwise the variable will be int
Which_epochs = (0,1) #the comma must stay, otherwise the variable will be int
Using_nominal_compare = True
Line_differences_checking = False
Print_FIDs = False
Print_typos = False
Print_typos = True
Print_real2nominal_checks = True
IFM_StDev_sys = (0.0004,0.00015) #mm, +- 0,2um based on Leica's white paper
ADM_StDev = 0.010 #mm, from 2-5m based on Leica's typical errors
......@@ -46,6 +46,7 @@ Epochs_dictionary = {'LoS':{},'Pol':{}}
Epochs_dictionary['LoS'][0] = "Testing_measurements_Epoch0.txt"
Epochs_dictionary['LoS'][1] = "Testing_measurements_Epoch1.txt"
Epochs_dictionary['Pol'][0] = "Polar_measurements_1.txt"
Epochs_dictionary['Pol'][1] = "Polar_measurements_1.txt"
"""Which Epochs gonna be used and adding the data into the code"""
if len(Which_epochs) == 1:
......
......@@ -57,20 +57,41 @@ def sing(angle):
result = m.sin(gon2rad(angle))
return result
def polar2cart3D(S, Hz, Z):
def arctang(angle):
"""Function takes angle in gons and calculates cosinus"""
result = m.atan(gon2rad(angle))
return result
def polar2cart3Dgon(S, Hz, Z):
return (
S * sing(Z) * cosg(Hz),
S * sing(Z) * sing(Hz),
S * cosg(Z)
)
def polar2cart3D(Point):
def polar2cart3Dgon(Point):
return (
Point[0] * sing(Point[2]) * cosg(Point[1]),
Point[0] * sing(Point[2]) * sing(Point[1]),
Point[0] * cosg(Point[2])
)
def cart2polal3Dgon(Point):
return (
m.sqrt(m.pow(Point[0],2) + m.pow(Point[1],2) + m.pow(Point[2],2)),
rad2gon(
arctang(m.sqrt(m.pow(Point[0],2) + m.pow(Point[1],2))/Point[2])),
rad2gon(arctang(Point[1]/Point[0]))
)
def cart2polal3Dgon(X,Y,Z):
return (
m.sqrt(m.pow(X,2) + m.pow(Y,2) + m.pow(Z,2)),
rad2gon(
arctang(m.sqrt(m.pow(X,2) + m.pow(Y,2))/Z)),
rad2gon(arctang(Y/X))
)
def Measurements_read_in(Meas_filename):
Meas_file = open(Meas_filename,'r')
Measurements = {}
......
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