I have for after alot of days of research found no answer, so i hope that we can find a solution here.
Matrix = np.random.randint(5, size=(60, 6, 6))
arr = np.random.randint(5, size=(1, 240))
arr1 = np.random.randint(5, size=(1, 240))
arr2 = np.random.randint(5, size=(1, 240))
arr3 = np.random.randint(5, size=(1, 240))
in the original data all the arr, arr1, arr2, arr3 consists of different data and got sizes of (1,240), but is sliced to size (1,72), kkk, vvv represents placement shifts for each iteration but with the fixed size of (1,72) but might not be relevant to solving this case.
I have this code:
kkk = 3
vvv = 79
while True:
for i in range(len(Matrix)):
for j in range(len(Matrix[i])):
for z in range(len(Matrix[j])):
pass
Matrix2 = np.concatenate((arr[kkk:vvv], arr1[kkk:vvv], arr2[kkk:vvv], arr3[kkk:vvv]), axis=0)
for v in range(len(Matrix2 )):
for vv in range(len(Matrix2 [v])):
for kv in np.isclose(Matrix[i, j, z], Matrix2 [v], rtol=0.005, atol=0.0):
def array_for(x, y):
return np.asanyarray([kv for kv in np.isclose(x[i, j, z], y[v], rtol=0.005, atol=0.0)])
boolarray = array_for(Matrix, Matrix2)
if j >= 5:
kkk += 4
vvv += 4
if i == 59:
break
The thing i am looking to do is record data from my boolarray, into an array of the size that:
def array_for(x, y):
return np.asanyarray([kv for kv in np.isclose(x[i, j, z], y[v], rtol=0.005, atol=0.0)])
This gives me.
The size of Matrix, is 60,6,6 The size of Matrix2, is 4,72 The size of boolarray, is 4,1, for each value in Matrix
[False False False False]
i want to record the boolarray data into an array of 1,6,6,4,72 and end up with 60 of these arrays so it becomes 60,6,6,4,72
The problem i found is that numpy is memorybased arrays, and if i try and append i get a bunch of 4,1 arrays which wouldnt be able to concate either in the loop or outside the loop, with anything other than itself.
Also trying to use np.insert, will yield me the same result.
And appending data to a python list, would create wrong shapes, like haveing a shape 1,1 and inside it 72 values.
Is it possible to use this logic and if so how to achieve the desired result:
For values in boolarray:
append values a list[],
concate with each condition like:
if boolarray == 71:
np.concate(values, mask)
out = 2,4,72
delete mask:
continue np.concate(value, prevvalues)
print(Full array)
Out = 60,6,6,4,72
Matrix array looks like this:
[[0, 1, 0, 3, 4, 5],
[0, 2, 0, 3, 4, 5],
[2, 1, 1, 3, 4, 5],
[0, 1, 5, 3, 9, 5],
[4, 1, 0, 3, 8, 5],
[4, 1, 0, 3, 8, 5]]
Then with 60 layers of different values shown like above.
Matrix2 array looks like this:
[[1, 1, 4, 5]] x72 times with different values
Let me know if i should explain anything further, and or if you have an idea of how to put data into an array dynamicly. Your help is much appreciated.
Desired array should look like this:
[[False False False False False False],
[False True False False False False],
[False False True False True False],
[False True True False True False],
[False False False True False True ],
[False False False False False False]] 60x times = 60,6,6
[[False True True False],
[True True True False],
[False False True False],
[False True True False],
[False False False True],
[False False False False]] 72x times 4, 72
each 4 values iterates through 1 cell of 6,6 at a time, so maybe i suppose the array might look like this 72, 4, 6, 6, 1 where 1 is 1 layer out of 60
So the last is likely how it would look like, im sorry i cant represent the figure much better as it is a complex shape, compared to that of 3 dimensional object, but the Np.isclose gives this kind of relation, by 1 cell at the time. and which yield: 10,368 values in total, which is 72times,4times,6times,6,times1.