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

New features

- Polar coordinates input added,
- Read in made into function rather than code.
parent debda21d
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 7 08:02:05 2021
@author: jbarker
"""
#import scipy as sp
import re
import numpy as np
#import sys
#import string
#import math as m
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()
LoS_Meas_file = open(cg.Measurements_file_name_2,'r')
LoS_measurements_1 = {}
for row in LoS_Meas_file.readlines():
"""
- Reads in and parses Meas_file.
- The format is string Line name 'space'
string Point name 'space' float Distance [mm] 'space'
float Hz angle [gon] 'space' float Z angle [gon].
- Ignores point notes at the end.
- It can handle multiple occurences of delimeters but not a
combination of them.
- LoS_measurements_1 - a Dictionary of lines which contains a
Dictionary of points, where Point
name is a key and measured values
are triplet tuple"""
words = re.split(';+|,+|\t+| +',row.strip())
if words[0] not in LoS_measurements_1.keys():
LoS_measurements_1[words[0]] = {}
LoS_measurements_1[words[0]][words[1]] = \
(float(words[2]), float(words[3]), float(words[4]))
else:
LoS_measurements_1[words[0]][words[1]] = \
(float(words[2]), float(words[3]), float(words[4]))
del words, row
LoS_Meas_file.close()
# =============================================================================
# Initial checks for LoS measurements.
# If you want to print, change: Print_typos to True
# =============================================================================
# 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 = {}
all_measured_points = []
measured_lines_all_good = True
measured_points_all_good = True
#nominal_lines_all_measured = True #not checking at the moment
nominal_points_all_measured = True
all_points_in_lines_measured = True
for line in LoS_measurements_1:
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("Line %s was measured, but not expected." % (line))
measured_lines_all_good = False
else:
line_points_sorted = []
for point in cg.Lines_of_sight[line]:
if point in LoS_measurements_1[line].keys():
line_points_sorted.append(point)
sorted_measured_points_in_lines[line] = tuple(line_points_sorted)
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))
del line_points_sorted
for point in LoS_measurements_1[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))
measured_points_all_good = False
if point not in cg.Lines_of_sight[line]:
measured_points_all_good = False
if cg.Print_typos:
print("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))
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.")
if (cg.Print_typos) and (measured_points_all_good):
print("All measured points are correct, in correct lines, no typos found.")
if (cg.Print_typos) and (nominal_points_all_measured):
print("All nominal points 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.")
del all_measured_points, nominal_points_all_measured,\
all_points_in_lines_measured
measured_distances_in_lines = {}
if cg.Using_nominal_compare:
nominal_distances_in_line = {}
differences_in_distances = {}
StDev_distances_in_lines = {}
if measured_lines_all_good and measured_points_all_good:
del measured_lines_all_good, measured_points_all_good
# Calculating distance deltas
for line in LoS_measurements_1:
deltas = ()
if cg.Using_nominal_compare:
deltas_nominal = ()
for i in range (1,len(sorted_measured_points_in_lines[line])):
delta = (LoS_measurements_1[line][
sorted_measured_points_in_lines[line][i]][0]\
- LoS_measurements_1[line][
sorted_measured_points_in_lines[line][i-1]][0],)
deltas = deltas + delta
if cg.Using_nominal_compare:
d = fc.slope_distance(
Nominal_coords[
sorted_measured_points_in_lines[line][i-1]],
Nominal_coords[
sorted_measured_points_in_lines[line][i]])
deltas_nominal = deltas_nominal + (d,)
measured_distances_in_lines[line] = deltas
if cg.Using_nominal_compare:
nominal_distances_in_line[line] = deltas_nominal
del deltas_nominal
del line, i, delta, deltas, d
if cg.Using_nominal_compare:
for line in LoS_measurements_1:
differences_in_distances[line] = np.asarray(
nominal_distances_in_line[line])\
- np.asarray(
measured_distances_in_lines[line])
StDev_distances_in_lines[line] = np.std(
differences_in_distances[line])
if StDev_distances_in_lines[line] == 0:
StDev_distances_in_lines[line] = None
differences_in_distances[line] = tuple(
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.")
print(differences_in_distances, StDev_distances_in_lines)
print('End of the script')
\ No newline at end of file
......@@ -6,8 +6,6 @@ Created on Wed Apr 7 08:02:05 2021
"""
#import scipy as sp
import re
import numpy as np
#import sys
......@@ -20,48 +18,17 @@ 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()
LoS_Meas_file = open(cg.Measurements_file_name,'r')
LoS_measurements = {}
for row in LoS_Meas_file.readlines():
"""
- Reads in and parses Meas_file.
- The format is string Line name 'space'
string Point name 'space' float Distance [mm] 'space'
float Hz angle [gon] 'space' float Z angle [gon].
- Ignores point notes at the end.
- It can handle multiple occurences of delimeters but not a
combination of them.
- LoS_measurements - a Dictionary of lines which contains a
Dictionary of points, where Point
name is a key and measured values
are triplet tuple"""
words = re.split(';+|,+|\t+| +',row.strip())
if words[0] not in LoS_measurements.keys():
LoS_measurements[words[0]] = {}
LoS_measurements[words[0]][words[1]] = \
(float(words[2]), float(words[3]), float(words[4]))
else:
LoS_measurements[words[0]][words[1]] = \
(float(words[2]), float(words[3]), float(words[4]))
del words, row
LoS_Meas_file.close()
# =============================================================================
# Loading measurement files and Coordinates
# =============================================================================
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(
cg.LoS_Measurements_file_name_1)
Pol_measurements_1 = fc.Measurements_read_in(
cg.Pol_Measurements_file_name_1)
# =============================================================================
# Initial checks for LoS measurements.
......@@ -177,6 +144,4 @@ else:
"To help troubleshoot, change Print_typos in config.py to True.")
print('End of the script')
\ No newline at end of file
Instrument_0 PQK36_4 2392.232 23.3521 90.8281
Instrument_0 PQL6_6 1827.207 -13.9568 110.3317
Instrument_0 PQK62_11 2344.069 -74.2079 93.8212
Instrument_0 PQK62_5 2114.108 -65.5147 93.1734
Instrument_0 PQK62_6 2123.918 -65.5400 108.8129
Instrument_0 PQK62_12 2352.835 -74.2054 107.9531
Instrument_0 PQK62_10 2264.483 -76.6349 90.1851
Instrument_0 PQK62_4 2025.419 -67.8080 89.0132
Instrument_0 PQK62_3 1735.219 -76.0525 87.1927
Instrument_0 Girder_5 1353.736 -64.0997 114.1327
Instrument_0 Girder_6 1916.134 -52.5513 109.9680
Instrument_0 PQL6_10 1681.989 -38.2288 86.8007
Instrument_0 PQL6_11 1787.300 -37.5281 91.9756
Instrument_0 PQL6_12 1798.910 -37.5453 110.4647
Instrument_0 Girder_10 1826.021 -25.9160 117.3271
Instrument_0 PQL6_4 1711.854 -12.8040 87.0743
Instrument_0 PQL6_5 1815.820 -13.9279 92.1149
Instrument_0 Girder_14 1983.828 0.9049 109.6235
Instrument_0 Girder_13 1449.650 13.8721 113.3478
Instrument_0 PQK36_12 2229.037 13.0390 108.5031
Instrument_0 PQK36_10 2136.028 15.4449 89.7142
Instrument_0 Girder_TP 1738.730 23.3771 118.5032
Instrument_0 PQK36_5 2467.864 20.9053 94.2581
Instrument_0 PQK36_6 2476.091 20.8870 107.6508
Instrument_0 PQK36_9 1862.634 23.8895 88.2036
Instrument_0 Girder_18 2508.625 20.8411 112.3602
Instrument_0 Girder_12 1868.373 -13.9689 116.7243
Instrument_0 Girder_8 1838.661 -37.5476 116.9392
Instrument_0 Girder_4 2157.177 -65.5873 114.3772
Instrument_0 Girder_2 2381.013 -74.2638 112.9809
Instrument_1 PQK62_8 1912.868 -88.4077 92.4529
Instrument_1 PQL6_7 1184.455 -42.6261 116.0673
Instrument_1 PQK36_9 1862.621 23.8894 88.2035
Instrument_1 PQK36_10 2136.028 15.4446 89.7148
Instrument_1 PQK36_8 1759.266 27.3143 91.9634
Instrument_1 PQK36_3 2152.053 31.6737 89.8183
Instrument_1 PQK36_2 2063.496 34.8810 93.1692
Instrument_1 PQK36_1 2072.912 34.8412 109.2065
Instrument_1 PQK36_7 1770.548 27.2686 110.7741
Instrument_1 Girder_TP 1738.710 23.3771 118.5030
Instrument_1 Girder_13 1449.653 13.8719 113.3475
Instrument_1 Girder_14 1983.839 0.9051 109.6234
Instrument_1 PQL6_1 1226.675 -6.2772 115.5865
Instrument_1 PQL6_2 1210.552 -6.1871 88.1910
Instrument_1 PQL6_3 1355.806 -8.3210 83.6573
Instrument_1 PQL6_9 1317.696 -41.1433 83.1178
Instrument_1 PQL6_8 1167.827 -42.5619 87.7079
Instrument_1 Girder_9 1224.324 -24.3657 126.3338
Instrument_1 Girder_5 1353.735 -64.0990 114.1322
Instrument_1 Girder_6 1916.134 -52.5511 109.9677
Instrument_1 PQK62_4 2025.408 -67.8079 89.0131
Instrument_1 PQK62_3 1735.212 -76.0529 87.1933
Instrument_1 PQK62_2 1623.359 -79.5245 91.1212
Instrument_1 PQK62_1 1636.245 -79.5332 111.5432
Instrument_1 PQK62_7 1923.893 -88.3896 109.7665
Instrument_1 PQK62_9 2009.041 -85.0673 88.9428
Instrument_1 Girder_1 1957.041 -88.6061 115.8255
Instrument_1 Girder_3 1675.760 -79.7623 118.5953
Instrument_1 Girder_7 1240.519 -42.7766 125.5583
Instrument_1 Girder_11 1281.459 -6.1841 124.7730
Instrument_1 Girder_17 2107.861 34.8774 114.8400
......@@ -20,8 +20,9 @@ Created on Thu Feb 11 10:54:43 2021
Which_epochs = (0,) #the comma must stay, otherwise the variable will be just int
Using_nominal_compare = True
Line_differences_checking = False
IFM_StDev = 0.001 #mm, from 2-5m based on Leica's MPEs and typical errors
ADM_StDev = 0.007 #mm, from 2-5m based on Leica's typical errors
IFM_StDev_sys = 0.0004 #mm, +- 0,2um based on Leica's white paper
IFM_StDev_ppm = 0.00015 #mm, 0,15um based on Leica's white paper
ADM_StDev = 0.010 #mm, from 2-5m based on Leica's typical errors
Print_FIDs = False
Print_typos = False
Print_real2nominal_checks = True
......@@ -32,21 +33,25 @@ Point name 'space' X [mm] 'space' Y [mm] 'space' Z [mm]
"""
Coords_file_name = "BetterCoords.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] = "Testing_measurements_Epoch0.txt"
Epochs_dictionary[1] = "Testing_measurements_Epoch1.txt"
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_0.txt"
"""Which Epochs gonna be used and adding the data into the code"""
if len(Which_epochs) == 1:
Measurements_file_name = Epochs_dictionary[Which_epochs[0]]
LoS_Measurements_file_name = Epochs_dictionary['LoS'][Which_epochs[0]]
Pol_Measurements_file_name = Epochs_dictionary['Pol'][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]]
LoS_Measurements_file_name = Epochs_dictionary['LoS'][Which_epochs[0]]
LoS_Measurements_file_name_1 = Epochs_dictionary['LoS'][Which_epochs[1]]
Pol_Measurements_file_name = Epochs_dictionary['Pol'][Which_epochs[0]]
Pol_Measurements_file_name_1 = Epochs_dictionary['Pol'][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:
......
......@@ -6,6 +6,8 @@ Created on Thu Feb 11 12:53:33 2021
"""
import math as m
from numpy import pi
import re
"""
______ _ _
| ___| | | (_)
......@@ -53,4 +55,61 @@ def cosg(angle):
def sing(angle):
"""Function takes angle in gons and calculates sinus"""
result = m.sin(gon2rad(angle))
return result
\ No newline at end of file
return result
def polar2cart3D(S, Hz, Z):
return [
S * sing(Hz) * cosg(Z),
S * sing(Hz) * sing(Z),
S * cosg(Hz)
]
def polar2cart3D(PointID):
return [
PointID[0] * sing(PointID[1]) * cosg(PointID[2]),
PointID[0] * sing(PointID[1]) * sing(PointID[2]),
PointID[0] * cosg(PointID[1])
]
def Measurements_read_in(Meas_filename):
Meas_file = open(Meas_filename,'r')
Measurements = {}
for row in Meas_file.readlines():
"""
- Reads in and parses Meas_file.
- The format is string Line name 'space'
string Point name 'space' float Distance [mm] 'space'
float Hz angle [gon] 'space' float Z angle [gon].
- Ignores point notes at the end.
- It can handle multiple occurences of delimeters but not a
combination of them.
- LoS_measurements_1 - a Dictionary of lines which contains a
Dictionary of points, where Point
name is a key and measured values
are triplet tuple"""
words = re.split(';+|,+|\t+| +',row.strip())
if words[0] not in Measurements.keys():
Measurements[words[0]] = {}
Measurements[words[0]][words[1]] = \
(float(words[2]), float(words[3]), float(words[4]))
else:
Measurements[words[0]][words[1]] = \
(float(words[2]), float(words[3]), float(words[4]))
del words, row
Meas_file.close()
return Measurements
def Coords_read_in(Coords_file_name):
Coords_file = open(Coords_file_name,'r')
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())
Coords[words[0]] = (float(words[1]),
float(words[2]),
float(words[3]))
del line, words
Coords_file.close()
return Coords
\ 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