Skip to content

Allow TemplateBank/FilterBank to read/write from a named group within… - #5398

Open
ahnitz wants to merge 1 commit into
gwastro:masterfrom
ahnitz:pr-bank-relocatable
Open

Allow TemplateBank/FilterBank to read/write from a named group within…#5398
ahnitz wants to merge 1 commit into
gwastro:masterfrom
ahnitz:pr-bank-relocatable

Conversation

@ahnitz

@ahnitz ahnitz commented Aug 6, 2026

Copy link
Copy Markdown
Member

This is a new feature to our basic bank class. It allows the bank to be located within an hdf5 file group of your choice rather than the assumed top level / root layout. This is required for #5395, but might be useful for other things if you say wanted multiple banks in a file.

… a shared HDF5 file

Adds group_key and file_handler parameters to TemplateBank.__init__ and
TemplateBank.write_to_hdf, so a bank's parameters (and compressed
waveforms) can live in a named subgroup of an HDF5 file instead of only
at the file root, and so multiple banks can share one already-open file
handle instead of each opening the file separately. This lets a single
HDF5 file hold more than one related template bank (e.g. two banks that
reference each other) without needing separate files on disk.

@GarethCabournDavies GarethCabournDavies left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, there is a minor question about how this relates to the HGroup in pycbc.io.hdf. It may be that this is handled fine, and if your tests work then the proof is in that pudding.

Also if the file handler is given is filename actually needed?

Comment thread pycbc/waveform/bank.py
extra_args : {None, dict}
Any extra keyword arguments that were provided on initialization.
"""
def __init__(self, filename, approximant=None, parameters=None,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if file_handler or file is given, should filename become an optional argument?

Comment thread pycbc/waveform/bank.py
# 1. Resolve Root File Object
if file_handler is not None:
# If passed a Group, get its file. If passed a File, use it.
if isinstance(file_handler, h5py.Group):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be a HGroup from pycbc.io, but it may be best to check. We would also need to check whether isinstance(..., h5py.Group) would be true if it is a HGroup, as that is a subclass of h5py.Group

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants