I have some data represented in a 1300×1341 matrix. I would like to split this matrix in several pieces (e.g. 9) so that I can loop over and process them. The data needs to stay ordered in the sense that x[0,1] stays below (or above if you like) x[0,0] and besides x[1,1].
Just like if you had imaged the data, you could draw 2 vertical and 2 horizontal lines over the image to illustrate the 9 parts.
If I use numpys reshape (eg. matrix.reshape(9,260,745) or any other combination of 9,260,745) it doesn’t yield the required structure since the above mentioned ordering is lost…
Did I misunderstand the reshape method or can it be done this way?
What other pythonic/numpy way is there to do this?
Sounds like you need to use
numpy.split()which has its documentation here … or perhaps its siblingnumpy.array_split()here. They are for splitting an array into equal subsections without re-arranging the numbers like reshape does,I haven’t tested this but something like:
should do the trick.