-
Notifications
You must be signed in to change notification settings - Fork 0
/
Protocols2D.py
114 lines (106 loc) · 5.03 KB
/
Protocols2D.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import numpy as np
from Utilities import SaveArrayTXT, ArrayToXML, SampleReciprocals, SortArray
def CreateDDN(nElec:int=64, nMax:int=6, parralelizeMin:int=None):
'''This function creates a dipole-dipole array for an in-line measurement
The input parameters are :
- nElec: the number of electrodes in the line (default = 64)
- nMax: the maximum n factor (default = 6)
- parralelizeMin: the minimum number of measures per injection to keep (default=None)
It outputs a numpy array that contains the array and can be saved in a simple txt file.
'''
array = []
for A in np.arange(start = 1, stop = nElec+1):
for a in np.arange(start = 1, stop = int(nElec/2)):
B = A + a
for n in np.arange(start = 1, stop = nMax+1):
M = B + n*a
N = M + a
if np.max([A, B, M, N]) <= nElec:
array.append([A, B, N, M])
array = np.asarray(array)
if parralelizeMin is not None:
if parralelizeMin > nMax:
print('Impossible to measure more at least {} dipoles per injection with a maximum n factor of {}.'.format(parralelizeMin, nMax))
parralelizeMin = nMax
uniqueAB, countsAB = np.unique(array[:,:2], axis=0, return_counts=True)
valKeep = uniqueAB[countsAB==parralelizeMin]
array = []
for AB in valKeep:
A, B = AB[0], AB[1]
a = B - A
for n in np.arange(start=1, stop = parralelizeMin+1):
M = B + n*a
N = M + a
array.append([A, B, N, M])
array = np.asarray(array)
return array
def CreateGradient(nElec:int=32, s:int=8):
'''This function creates a gradient array for an in-line measurement
The input parameters are :
- nElec: the number of electrodes in the line (default = 64)
- s: the s factor (default = 7)
- parralelizeMin: the minimum number of measures per injection to keep (default=None)
It outputs a numpy array that contains the array and can be saved in a simple txt file.
'''
array = []
for A in np.arange(start = 1, stop = nElec+1):
for a in np.arange(start = 1, stop = int(nElec/2)):
B = A + (s+2)*a
for M in np.arange(start = A+a, stop = A + (s+1)*a, step = a):
N = M + a
if np.max([A, B, M, N]) <= nElec:
array.append([A, B, M, N])
array = np.asarray(array)
return array
def makeBorehole(array, nElecSurface:int=64, posBorehole:int=32.5, nElecBorehole:int=32):
addArray = []
for abmn in array:
A, B, M, N = abmn[0], abmn[1], abmn[2], abmn[3]
if (M > posBorehole) or (N > posBorehole):
Madd, Nadd = M, N
if M > posBorehole: Madd = M + np.floor(posBorehole)
if N > posBorehole: Nadd = N + np.floor(posBorehole)
addArray.append([A, B, Madd, Nadd])
if (A+B)/2 != posBorehole:
Aadd, Badd = A, B
if M < posBorehole: Madd = nElecSurface+1 - M
if N < posBorehole: Nadd = nElecSurface+1 - N
if A < posBorehole: Aadd = nElecSurface+1 - A
if B < posBorehole: Badd = nElecSurface+1 - B
addArray.append([Aadd, Badd, Madd, Nadd])
addArray = np.asarray(addArray)
array = SortArray(np.vstack((array, addArray)).astype(int))
return array
if __name__=='__main__':
n = 6
nElec = 64
DDNArray = CreateDDN(nMax = n, nElec = nElec, parralelizeMin=6)
print('Default DDN6 array (length = {}):'.format(len(DDNArray)))
print(DDNArray)
DDN6Bore = makeBorehole(DDNArray)
print('Default DDN6 with borehole array (length = {}):'.format(len(DDN6Bore)))
print(DDN6Bore)
SaveArrayTXT('DDN6Borehole.txt', DDN6Bore)
DDN6BoreRecip = SampleReciprocals(DDN6Bore)
SaveArrayTXT('DDN6BoreholeReciprocals.txt', DDN6BoreRecip)
s = 7
GradientArray = CreateGradient(s = s, nElec = nElec)
print('Default Gradient (s=7) array (length = {})'.format(len(GradientArray)))
GradientBore = makeBorehole(GradientArray)
print('Default DDN6 with borehole array (length = {}):'.format(len(GradientBore)))
print(GradientBore)
SaveArrayTXT('Gradient7Borehole.txt', GradientBore)
GradientBoreRecip = SampleReciprocals(GradientBore)
SaveArrayTXT('GradientBoreholeReciprocals.txt', GradientBoreRecip)
# ArrayToXML(DDNArray)
# DDNArrayReciprocals = SampleReciprocals(DDNArray)
# print('The corresponding DDN6 sampled reciprocal array (length = {}):'.format(len(DDNArrayReciprocals)))
# ArrayToXML(DDNArrayReciprocals)
# s = 7
# GradientArray = CreateGradient(s = s, nElec = nElec)
# print('Default Gradient (s=7) array (length = {})'.format(len(GradientArray)))
# #print(GradientArray)
# ArrayToXML(GradientArray)
# GradientArrayReciprocals = SampleReciprocals(GradientArray)
# print('The corresponding Gradient (s=7) sampled reciprocal array (length = {}):'.format(len(GradientArrayReciprocals)))
# ArrayToXML(GradientArrayReciprocals)