I would like to generate a 2-by-N array in python for use with scipy.optimize.curve_fit
.
I have a function of two independent variables stored as 1-D arrays, and the data in a 2-D array. curve_fit
requires that the data be flattened, which is easy with data.ravel()
.
However, this is the hack I'm using to generate the 2xN array of ordinate values:
ordinate = np.array([[l,t] for l in length for t in time]).T
which works, but is slow. What's the (vectorized?) faster way?