Skip to content

Code to override bank approximant is buggy #5215

@tdent

Description

@tdent

In waveform/bank.py :

        # if approximant is specified, override whatever was in the file
        # (if anything was in the file)
        if approximant is not None:
            # get the approximant for each template
            apprxs = self.parse_approximant(approximant)
            if 'approximant' not in self.table.fieldnames:
                self.table = self.table.add_fields(apprxs, 'approximant')
            else:
                self.table['approximant'] = apprxs

The problem here seems to be that if the bank file already contains an approximant field / dataset / column, the data type is set to strings of whatever length is in the bank file for each template. Then any attempt to override the WaveformArray content with a command-line approximant results in the approximant string being truncated to the length of the bank approximant.

E.g. TaylorF2 and SPAtmplt have 8 characters but SEOBNRv4_ROM has 12 .. however, if truncated to 8 we get SEOBNRv4 😵‍💫
Then the inspiral code tries to use SEOBNR time domain templates ...

This has now happened three separate times in SSM analyses since O3, each time we have to go back and figure out what went wrong and change the bank file by hand because the code does something we do not want but does not give a useful error message.

The right thing to do would be to remove the existing table['approximant'] object and create a new one, but I can't see how to do that for a FieldArray and we need a FieldArray expert for that. The next best thing to do is just to throw an error, ie

            else:
                raise RuntimeError("I'm not going to put a new approximant inside the array of an existing one from the bank because this is extremely failure prone! Better remake the bank without the approximant!")

Metadata

Metadata

Labels

bugBUG - FIX ASAPcode-qualityImprovements to code qualitytemplate bankv23_release_branchPRs applied to the v2.3.X release branch or to be cherry-picked if merging to master

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions