5 sys.path.append(
'../..')
8 def main(dest, source):
9 if not type(source)
is list: source = [source]
10 print(
'Saving spectra from {} files to {}'.
format(len(source), dest))
12 first = h5py.File(source[0],
'r') 13 groups = list(first.keys()) 23 source_spectra[g] = []
24 dest_spectra[g] =
None 32 for group, spec
in spectra:
33 source_spectra[group].
append(spec)
37 for spec
in source_spectra[g]:
39 if dest_spectra[g]
is None:
40 dest_spectra[g] = spec
44 assert str(dest_spectra[g]._df.name) ==
str(spec._df.name), \
45 'Spectra must have the same name to add them together ({} =/= {})'.
format(dest_spectra[g]._df.name, spec._df.name)
46 dest_spectra[g] = dest_spectra[g] + spec
53 if __name__ ==
'__main__':
55 if os.path.isfile(dest):
56 print(
'{} already exists. Will not overwrite'.
format(dest))
59 for arg
in sys.argv[1:]:
60 these = glob.glob(arg)
61 if type(these)
is list: source = source + these
62 else: source.append(these)
std::string format(const int32_t &value, const int &ndigits=8)
def save_tree(fname, spectra, groups, attrs=True)
def load_tree(fname, groups, attrs=True)