Save vectors to file in Python with NumPy -
i have variable numeric value, variable string value, , 2 vectors defined numpy
a = 10 b = "text string" positions = np.array([]) forces = np.array([])
i want save these values file. i've used http://docs.scipy.org/doc/numpy/reference/generated/numpy.savetxt.html save 2 vectors with
np.savetxt('test.out', (positions,forces))
but need store values of a
, b
.
how possible?
personally recommend using numpy.savez
, numpy.load
. example:
numpy.savez('test.npz', a=a, b=b, positions=positions, forces=forces)
you can load again this:
data = numpy.load('test.npz') = data['a']
Comments
Post a Comment