This addresses the enhancement part of issue #176. Users can now append new columns to an existing lgdo.Table in an lh5 file by using the append_column argument of the wo_mode parameter.
If the user tries to append_column with a table that has any of the same fields as the existing table, or if the new table is a different size than the existing table, then the function will raise an error.
>>> import pygama.lgdo as lh5
>>> import numpy as np
>>> tb1 = lh5.Table(col_dict={'dset1': lh5.Array(np.zeros(10))})
>>> tb2 = lh5.Table(col_dict={'dset2': lh5.Array(np.ones(10))}) # second table with new field name
>>> store = lh5.LH5Store()
>>> store.write_object(tb1, name='my_table', lh5_file="my_output.lh5")
>>> store.write_object(tb2, name='my_table', lh5_file="my_output.lh5", wo_mode="append_column")
>>> tb_dat, _ = store.read_object("my_table", "/tmp/my_output.lh5")
>>> tb_dat['dset1'].nda
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
>>> tb_dat['dset2'].nda
[1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]
This addresses the enhancement part of issue #176. Users can now append new columns to an existing
lgdo.Table
in anlh5
file by using theappend_column
argument of thewo_mode
parameter.If the user tries to
append_column
with a table that has any of the same fields as the existing table, or if the new table is a different size than the existing table, then the function will raise an error.