I wat to search for indices of an array in two other arrays and want to find out where they match. Firstly, I have a variable which says how many points will be matched It is called brk. This brk equals the length of my search array (searched). In my simple case brk = 2 which means I will have 4 match points (brk * 2). So, I must split my search arry into brk halves and then search each half in each main array (main_x_arr and main_y_arr). I have always one search array and two main arrays, but brk changes and says ho to search for indices. At the moment I am creating each match manually but I am trying to create matches auromatically. This is my code:
searched=np.array([[1., 2.], [-3., 1.]])
brk=len(searched)
main_y_arr=np.array([[1., 5.], [8., 3.], [-3., 8.], [2., 4.]])
main_x_arr=np.array([[1., 7.], [-3., 1.], [4., 7.], [2., 4.]])
match1= np.min (np.unique (np.where((main_y_arr==searched[:int (len(searched)/2)].reshape (-1,1)[:,None]).any(-1))[1]))
match2= np.max (np.unique (np.where((main_x_arr==searched[:int (len(searched)/2):].reshape (-1,1)[:,None]).any(-1))[1]))
match3= np.min (np.unique (np.where((main_y_arr==searched[int (len(searched)/2):].reshape (-1,1)[:,None]).any(-1))[1]))
match4= np.max (np.unique (np.where((main_x_arr==searched[int (len(searched)/2):].reshape (-1,1)[:,None]).any(-1))[1]))
As it can be seen, I am creating each match but I want to find a way to firstly kno I will have 2 * brk matches. Then, split searched array into the number of brk and after that search for each split in each array which makes 4 matches. If the length of my searched array equals 3, then I will have thre splits and finall 6 (eactly like repeating match1 and match2 for three slices to make 6 matches). Or if it is 1, I will have only 2 matches (exactly like having match1 and match2 for only one single slide) because it cannot be splitted anymore.
In advance I do appreciate any help and feedback.
searchedin my main arrays. But the point is that it is not always simple. Sometimes I need to splitsearchedrray and look for each split separately and find the mathed index.searchedarray.