9---------------------------------------------------------------------------
10Script to convert plots from npz format to ASCII - used for the memory testing
13> printenv | grep -i belle2
16> b2code-memoryusage -h
17> b2code-memoryusage -m record -i 0.01 -p ARICHStandAlone_memory.npz basf2 -n 1000
18 ARICHStandAlone.py -- -b -m | tee ARICHStandAlone_memory.log
19> python3 ../utility/scripts/convert_npz_to_ASCII.py --npzfile=ARICHStandAlone_memory.npz --dump
20> python3 ../utility/scripts/convert_npz_to_ASCII.py --npzfile=ARICHStandAlone_memory.npz --arrayname total_memory
21> root -l ../utility/scripts/convert_npz_ASCII_to_root.C"(\"total_memory.dat\")"
22---------------------------------------------------------------------------
25from optparse
import OptionParser
28parser = OptionParser()
29parser.add_option(
'-f',
'--npzfile', dest=
'npzfile', default=
'ARICHStandAlone_memory.npz', help=
'Name of the input npz file')
30parser.add_option(
'-a',
'--arrayname', dest=
'arrayname', default=
'total_memory',
31 help=
'Name of the array to convert in ASCII format')
32parser.add_option(
'-d',
'--dump', action=
"store_true", dest=
'dump', default=
False, help=
'Dump list of arrays')
33parser.add_option(
'-p',
'--printv', dest=
'printv', default=
'', help=
'Name of the array to print')
34(options, args) = parser.parse_args()
36npzfile = np.load(options.npzfile)
39 for myarr
in npzfile.files:
42if(len(options.arrayname) > 0):
43 outDatFile = options.arrayname +
'.dat'
44 np.savetxt(outDatFile, npzfile[options.arrayname], delimiter=
' ')
46if(len(options.printv) > 0):
47 print(npzfile[options.printv])