Tuesday 15 April 2014

python - Creating several grids at a time -


I have a matrix that contains start and end points, and want to create a grid between them. For now it is linear, but I would also like to be able to use it for the nonlineline grid (my own). The number of grid points in the line row # row, row 1 nl = 10 # in the number # np.

  test = np.array ([[0.1, 0.5], [0.0001, 0.9]] Hstack ((np.linspace (0.1, 0.0001, nL) .Repep ((- 1,1)), N. P. Linspace (0.5, 0.9, NL). Repeat ((- 1) 1))) # Expected output array ( [[0.1, 0.5], [0.08, 0.544], [0.078, 0.589], [0.067, 0.633], [0.056, 0.678], [0.045, 0.722], [0.033, 0.767], [0.022, 0.811], [ 0.011, 0.856], [0., 0.9]]  

Right now, it depends on the linspace stacking which is not really good and readable.

What about exploitation? Import samples in the form of end points in line # 1 in NP = np.array ([[0.1, 0.5], [0.0001, 0.9]] # in the starting points, line 1 NL = 10:

  Import # number of grid points x1 = np.hstack ((np.linspace (0.1, 0.0001, nL). Reparp ((- 1,1)), NP Linspace (0.5, 0.9, nL ) .rap ((-1, 1))) # Smaller version: x2 = np.vstack ([np.linspace (T [0], T [1], NL). In test for T.]). T print (npol (x1 == x2)) # returns true  

No comments:

Post a Comment