Open rikigigi opened 4 years ago
The content of the default bin format is simply an object with those attributes. However, I would also avoid splitting the binary output in many files: it does not make sense.
I think we can simplify this by saving many arrays/variables in a numpy or json file (we need to test this). Like this:
tc_dict = {
'j': {
'DT_FS': j.DT_FS,
'KAPPA_SCALE': j.KAPPA_SCALE,
'psd': j.psd,
...
},
'jf': {
'DT_FS': j.DT_FS,
'KAPPA_SCALE': j.KAPPA_SCALE,
'psd': j.psd,
...
},
...
}
Or with less-readable code:
tc_dict = {
'j': {},
'jf': {},
...
}
attrs_to_save = ['DT_FS', 'KAPPA_SCALE', 'psd', ...]
for key in tc_dict.keys():
for attr in attrs_to_save:
tc_dict[key][attr] = getattr(locals()[key], attr)
(we should find a smarter solution if the dictionary is more deeply-nested)
Then save it using numpy.save('binary_output.npy', **tc_dict)
or json.dump(open('binary_output.json', 'w'))
.
We will then need functions to reconstruct the Currents objects, etc, from this binary file...
What do you think?
@lorisercole Right now, the default binary output is a pickle dumped blob that, for a first time user, I think it is difficult to understand. Its content is:
Is it used by anyone or anywhere in the code? Is it safe to change the default binary output to the one equivalent to the human readable one but with numpy arrays?