I have a serie of lines and want to extract some of them. This is the number of lines:
line_no= np.arange (17, 34)
These lines are arranged in two perependicular direction. I have shown them with bluw and red lines in the fig. I know where the direction is changing, it is called sep:
sep=25 # lines from 17 to 25 are blue and from 26 to end are red
Then, I have the number of the points that create the lines. I call them chunks, because each number can be chunk:
chunk_val=np.array([1,2,3,3,4])
This chunk_val says how lines are created. I need to extract specific line numbers which are highlighted by a blue circle in the fig. For the red lines the algorithm is simpler. chunk_val[0] is 1, it means I have no red line there. chunk_val[1] is 2, so I have one line and I want that line (26) because the previous chunk gave me no line. chunk_val[2] is 3, so I have two lines here and I want the one last line (28 out of 27 and 28), because previous chunk gave me one line. chunk_val[3] is 3, there are again two line but I want none of them because the number of created red lines in this chunk is equal to previous chunk. chunk_val[3] is 4, it creates three line and I want to export the number of last one (33 out of 31, 32 and 33) because it is creating one line more than previous chunk. If chunk_val[3] was 5, then I wanted to save the last two line.
For blue lines, that connect the chunks it is a little bit more complicated. chunk_val[0] is 1and chunk_val[1] is 2, it means there is one connecting line because first chunk_value defines how many lines can be there. Meanwhile, I want that line (17), because there is only one line. If there were more lines, I wanted to pick the last one. From chunk_val[1] to chunk_val[2] I have two lines and I want the last one (19 out of 18 and 19). Then, chunk_val[2] to chunk_val[3] there are three line and I want the last one (22 out of 20, 21 and 22). From chunk_value[3] to chunk_value[4] again there are three line and I want the last one (25 out of 23, 24 and 25). There is one very important note on how to pick these connecting (blue) lines: I want to start picking them from the first chunk_val untill where values of chunk_val change. In my example until the last number of chunk_val I see a change (chunk_val[-2] is 3 while chunk_val[-1] is 4). If chunk_val[-1] was also 3, then I wanted to stop picking the blue lines after going from chunk_val[1] to chunk_val[2] (I mean I only wanted to have 17 and 19). These are the idea of my algorithm but I have no idea to code it in python. In summary I want to have the following list of numbers:
[17, 26, 19, 28, 22, 25, 33]
In advance, I do appreciate any contribution.
