My code is doing some math and saving output in multiple NumPy arrays.
At the end, I am writing the output to disk, for which I wish to use the name of the arrays as individual filenames, in which each array will be written.
For instance, if I have the following multidimensional arrays
time = [...]
force = [...]
pressure = [...]
energy = [...]
etc, and I do
for array in [time, force, pressure, energy, ....]:
with open(**filename**, 'w') as file:
pickle.dump(array, file)
But how to set the filename, so that it takes on the array names.
I have gone through many similar questions (although asked for other motives). The answers have suggested that array(or any variable) names are merely tags and not made to be retrieved like this. But my motive for naming files here seems like a genuine need (to me at least), so asking. If that is possible, I can perhaps go fancier and write in HDF5 format and use the array names as different datasets. All this could be achieved manually though, but then why do we code?