I am trying to stack a few 2-D arrays to obtain a 3-D array in python. My motivation behind doing this is to plot the spatial dependence of a variable: var(x,y) where x and y are two different dimensions, for different parameter values param. A minimum reproducible example for the same has been attached below:
while (param<=2):
var(x,y)= fun # fun is a function which returns var(x,y) as mentioned above
param+=1
I want to keep on stacking the 2-D arrays var(x,y) for different values of param, along a 3rd dimension. My output should be of the form :- For param=0 : var(x,y), For param=1 : var(x,y), For param=2 : var(x,y). Any help regarding the construction of the 3-D array would be highly appreciated.
Please note that var(x,y) is a 2-D array.
np.array,np.stackor one of the other variations onnp.concatenatedepends on the desired shape(s).