I am not sure why I can not concatenate multiple dimensions of an array together using the the numpy.concatenate function. For example:
array_2d.shape = [1200,1200]
array2_2d.shape = [1200,1200]
final_array1 = numpy.concatenate((array_2d,array2_2d),axes=0) # shape = (2400,1200)
final_array2 = numpy.concatenate((array_2d,array2_2d),axes=1) # shape = (1200,2400)
Is there a way I can get the 2 arrays to concatenate both axes to yield a shape of (2400,2400)? Or am I just thinking of this approach incorrectly with the concatenation of arrays? Some help would be much appreciated!!!
Let's think about what you're trying to accomplish, let's call array1 A, and array2 B, and some unknown array as X. Like you said, the following is 2400 x 1200:
| A |
| B |
But this would be a 2400 by 2400 array:
| A | X |
| X | B |
and so would this:
| A | X |
| B | X |
and this...:
| A | A |
| B | B |
The real question is how many times you want to concatenate each array and in which dimension or if you want to zero pad:
| A | 0 |
| 0 | B |
Which would be accomplished by using numpy to create an array of zeros and concatenating in the appropriate direction on both A and B before concatenating the results together.
You should use numpy.tile(). Read this link for more information.
example:
a = np.array(([1,2],[3,4]))
b = np.tile(a, (2,2))
will create a 4x4 array from a 2x2 array, by repeating both axis.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With