forked from Stephan/geometryfactor
Compare commits
2 commits
aa3e554744
...
0e8b09c2af
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0e8b09c2af | ||
|
|
c0d71bbe99 |
1 changed files with 84 additions and 88 deletions
172
det_signal.py
172
det_signal.py
|
|
@ -5,98 +5,94 @@ import argparse
|
|||
import numpy as np
|
||||
import random
|
||||
|
||||
|
||||
def read_csv_1(file_path):
|
||||
with open(file_path, newline='') as csvfile:
|
||||
reader = csv.reader(csvfile, delimiter=',')
|
||||
unique_points = set()
|
||||
for row in reader:
|
||||
point = (float(row[0]), float(row[1]), float(row[2]))
|
||||
unique_points.add(point)
|
||||
unique_points = list(unique_points)
|
||||
unique_points = np.array(unique_points)
|
||||
point_list = np.ones((len(unique_points),5))
|
||||
point_list[:, 0:3] = unique_points
|
||||
point_list[:,3] = 0
|
||||
point_list[:,4] = 0
|
||||
file = open(file_path, newline='')
|
||||
unique_points = set()
|
||||
for line in file:
|
||||
row = line.strip().split(',')
|
||||
point = (float(row[0]), float(row[1]), float(row[2]))
|
||||
unique_points.add(point)
|
||||
unique_points = list(unique_points)
|
||||
unique_points = np.array(unique_points)
|
||||
point_list = np.ones((len(unique_points),5))
|
||||
point_list[:, 0:3] = unique_points
|
||||
point_list[:,3] = 0
|
||||
point_list[:,4] = 0
|
||||
return point_list
|
||||
|
||||
def read_csv_2(file_path, slope_sc, slope_stop, Ind_A, Ind_S, point_list):
|
||||
with open(file_path, newline='') as csvfile:
|
||||
reader = csv.reader(csvfile, delimiter=',')
|
||||
for row in reader:
|
||||
point = (float(row[0]), float(row[1]), float(row[2]))
|
||||
matches = np.all(point_list[:, 0:3] == point, axis=1)
|
||||
position = np.where(matches)[0]
|
||||
an = []
|
||||
ta = np.arcsin(Ind_A/Ind_S)
|
||||
for i in range(3):
|
||||
x = float(row[13+8*i])
|
||||
y = float(row[14+8*i])
|
||||
z = float(row[15+8*i])
|
||||
v=np.array((x,y,z))
|
||||
norm = np.array((0,1,0))
|
||||
an.append(np.arccos(abs(np.dot(v,norm))/(np.linalg.norm(norm)*np.linalg.norm(v))))
|
||||
if int(float(row[8])) == 1 :
|
||||
u = random.random()
|
||||
v = random.random()
|
||||
sc = np.exp(-slope_sc*(int(float(row[11]))))
|
||||
p = np.exp(-slope_stop*(int(float(row[12]))))
|
||||
if u <= sc and v <= p and an[0] < ta:
|
||||
if int(float(row[9])) == 1:
|
||||
point_list[position,3] += 1
|
||||
else:
|
||||
point_list[position,4] += 1
|
||||
elif int(float(row[8])) == 2:
|
||||
u = random.random()
|
||||
u2 = random.random()
|
||||
v = random.random()
|
||||
v2 = random.random()
|
||||
sc = np.exp(-slope_sc*(int(float(row[11]))))
|
||||
sc2 = np.exp(-slope_sc*int(float(row[19])))
|
||||
p = np.exp(-slope_stop*(int(float(row[12]))))
|
||||
p2 = np.exp(-slope_stop*(int(float(row[20]))))
|
||||
if u <= sc and v <= p and an[0] < ta:
|
||||
if int(float(row[9])) == 1:
|
||||
point_list[position,3] += 1
|
||||
else:
|
||||
point_list[position,4] += 1
|
||||
elif u2 <= sc2 and v2 <= p2 and an[1] < ta:
|
||||
if int(float(row[17])) == 1:
|
||||
point_list[position,3] += 1
|
||||
else:
|
||||
point_list[position,4] += 1
|
||||
elif int(float(row[8])) == 3:
|
||||
u = random.random()
|
||||
u2 = random.random()
|
||||
u3 = random.random()
|
||||
v = random.random()
|
||||
v2 = random.random()
|
||||
v3 = random.random()
|
||||
sc = np.exp(-slope_sc*(int(float(row[11]))))
|
||||
sc2 = np.exp(-slope_sc*int(float(row[19])))
|
||||
sc3 = np.exp(-slope_sc*int(float(row[27])))
|
||||
p = np.exp(-slope_stop*(int(float(row[12]))))
|
||||
p2 = np.exp(-slope_stop*(int(float(row[20]))))
|
||||
p3 = np.exp(-slope_stop*(int(float(row[28]))))
|
||||
if u <= sc and v <= p and an[0] < ta:
|
||||
if int(float(row[9])) == 1:
|
||||
point_list[position,3] += 1
|
||||
else:
|
||||
point_list[position,4] += 1
|
||||
#first_det_to_hit.append(int(float(row[9])))
|
||||
elif u2 <= sc2 and v2 <= p2 and an[1] < ta:
|
||||
if int(float(row[17])) == 1:
|
||||
point_list[position,3] += 1
|
||||
else:
|
||||
point_list[position,4] += 1
|
||||
#first_det_to_hit.append(int(float(row[17])))
|
||||
elif u3 <= sc3 and v3 <= p3 and an[2] < ta:
|
||||
if int(float(row[25])) == 1:
|
||||
point_list[position,3] += 1
|
||||
else:
|
||||
point_list[position,4] += 1
|
||||
#first_det_to_hit.append(int(float(row[25])))
|
||||
file = open(file_path, newline='')
|
||||
for line in file:
|
||||
row = line.strip().split(',')
|
||||
point = (float(row[0]), float(row[1]), float(row[2]))
|
||||
matches = np.all(point_list[:, 0:3] == point, axis=1)
|
||||
position = np.where(matches)[0]
|
||||
an = []
|
||||
ta = np.arcsin(Ind_A/Ind_S)
|
||||
for i in range(3):
|
||||
x = float(row[13+8*i])
|
||||
y = float(row[14+8*i])
|
||||
z = float(row[15+8*i])
|
||||
v=np.array((x,y,z))
|
||||
norm = np.array((0,1,0))
|
||||
an.append(np.arccos(abs(np.dot(v,norm))/(np.linalg.norm(norm)*np.linalg.norm(v))))
|
||||
if int(float(row[8])) == 1 :
|
||||
u = random.random()
|
||||
v = random.random()
|
||||
sc = np.exp(-slope_sc*(int(float(row[11]))))
|
||||
p = np.exp(-slope_stop*(int(float(row[12]))))
|
||||
if u <= sc and v <= p and an[0] < ta:
|
||||
if int(float(row[9])) == 1:
|
||||
point_list[position,3] += 1
|
||||
else:
|
||||
point_list[position,4] += 1
|
||||
elif int(float(row[8])) == 2:
|
||||
u = random.random()
|
||||
u2 = random.random()
|
||||
v = random.random()
|
||||
v2 = random.random()
|
||||
sc = np.exp(-slope_sc*(int(float(row[11]))))
|
||||
sc2 = np.exp(-slope_sc*int(float(row[19])))
|
||||
p = np.exp(-slope_stop*(int(float(row[12]))))
|
||||
p2 = np.exp(-slope_stop*(int(float(row[20]))))
|
||||
if u <= sc and v <= p and an[0] < ta:
|
||||
if int(float(row[9])) == 1:
|
||||
point_list[position,3] += 1
|
||||
else:
|
||||
point_list[position,4] += 1
|
||||
elif u2 <= sc2 and v2 <= p2 and an[1] < ta:
|
||||
if int(float(row[17])) == 1:
|
||||
point_list[position,3] += 1
|
||||
else:
|
||||
point_list[position,4] += 1
|
||||
elif int(float(row[8])) == 3:
|
||||
u = random.random()
|
||||
u2 = random.random()
|
||||
u3 = random.random()
|
||||
v = random.random()
|
||||
v2 = random.random()
|
||||
v3 = random.random()
|
||||
sc = np.exp(-slope_sc*(int(float(row[11]))))
|
||||
sc2 = np.exp(-slope_sc*int(float(row[19])))
|
||||
sc3 = np.exp(-slope_sc*int(float(row[27])))
|
||||
p = np.exp(-slope_stop*(int(float(row[12]))))
|
||||
p2 = np.exp(-slope_stop*(int(float(row[20]))))
|
||||
p3 = np.exp(-slope_stop*(int(float(row[28]))))
|
||||
if u <= sc and v <= p and an[0] < ta:
|
||||
if int(float(row[9])) == 1:
|
||||
point_list[position,3] += 1
|
||||
else:
|
||||
point_list[position,4] += 1
|
||||
elif u2 <= sc2 and v2 <= p2 and an[1] < ta:
|
||||
if int(float(row[17])) == 1:
|
||||
point_list[position,3] += 1
|
||||
else:
|
||||
point_list[position,4] += 1
|
||||
elif u3 <= sc3 and v3 <= p3 and an[2] < ta:
|
||||
if int(float(row[25])) == 1:
|
||||
point_list[position,3] += 1
|
||||
else:
|
||||
point_list[position,4] += 1
|
||||
return point_list
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue