mirror of https://github.com/m-labs/artiq.git
artiq_run: HDF5 output support
This commit is contained in:
parent
f308bf6c12
commit
0e65f71705
|
@ -6,6 +6,8 @@ from inspect import isclass
|
||||||
from operator import itemgetter
|
from operator import itemgetter
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
|
|
||||||
|
import h5py
|
||||||
|
|
||||||
from artiq.language.db import *
|
from artiq.language.db import *
|
||||||
from artiq.protocols import pyon
|
from artiq.protocols import pyon
|
||||||
from artiq.protocols.file_db import FlatFileDB
|
from artiq.protocols.file_db import FlatFileDB
|
||||||
|
@ -44,6 +46,9 @@ def get_argparser():
|
||||||
help="run ELF binary")
|
help="run ELF binary")
|
||||||
parser.add_argument("-u", "--unit", default=None,
|
parser.add_argument("-u", "--unit", default=None,
|
||||||
help="unit to run")
|
help="unit to run")
|
||||||
|
parser.add_argument("-o", "--hdf5", default=None,
|
||||||
|
help="write results to specified HDF5 file"
|
||||||
|
" (default: print them)")
|
||||||
parser.add_argument("file",
|
parser.add_argument("file",
|
||||||
help="file containing the unit to run")
|
help="file containing the unit to run")
|
||||||
parser.add_argument("arguments", nargs="*",
|
parser.add_argument("arguments", nargs="*",
|
||||||
|
@ -107,11 +112,18 @@ def main():
|
||||||
unit_inst = unit(dbh, **arguments)
|
unit_inst = unit(dbh, **arguments)
|
||||||
unit_inst.run()
|
unit_inst.run()
|
||||||
|
|
||||||
if rdb.data.read or rdb.realtime_data.read:
|
if args.hdf5 is not None:
|
||||||
print("Results:")
|
f = h5py.File(args.hdf5, "w")
|
||||||
for k, v in chain(rdb.realtime_data.read.items(),
|
try:
|
||||||
rdb.data.read.items()):
|
rdb.write_hdf5(f)
|
||||||
print("{}: {}".format(k, v))
|
finally:
|
||||||
|
f.close()
|
||||||
|
else:
|
||||||
|
if rdb.data.read or rdb.realtime_data.read:
|
||||||
|
print("Results:")
|
||||||
|
for k, v in chain(rdb.realtime_data.read.items(),
|
||||||
|
rdb.data.read.items()):
|
||||||
|
print("{}: {}".format(k, v))
|
||||||
finally:
|
finally:
|
||||||
dbh.close()
|
dbh.close()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue