Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add any provided key to lal_pars for waveform generation #4728

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

hoyc1
Copy link
Contributor

@hoyc1 hoyc1 commented May 1, 2024

The purpose of this PR is to pass any non default flags provided to pycbc's waveform generation to the relevant lalsimulation functions by adding them to lal_pars. The code first checks to see if the provided key can be added, and then it tries a camelcase version. The keys are added via the lalsimulation.SimInspiralWaveformParamsInsert{key} function. This code was inspired from bilby: https://git.ligo.org/lscsoft/bilby/-/blob/master/bilby/gw/source.py?ref_type=heads#L583-586.

I opted to try both e.g. modes_choice and ModesChoice as the prior is more convenient to add to configs/HDF. This change is particularly useful for modifying the default behaviour of waveform models (for example turning off multi-banding in IMRPhenomXPHM). This change will affect all pipelines that provide additional flags to the waveform generator.

  • The author of this pull request confirms they will adhere to the code of conduct

@hoyc1
Copy link
Contributor Author

hoyc1 commented May 1, 2024

cc @spxiwh.

@spxiwh spxiwh requested a review from ahnitz May 1, 2024 08:40
@spxiwh
Copy link
Contributor

spxiwh commented May 1, 2024

@hoyc1 Looks like there are some genuine test failures here! @ahnitz Any thoughts about this? The idea is to avoid having to maintain a long list of possible lal_dict arguments to LALSim (similar to how Bilby does it).

@hoyc1
Copy link
Contributor Author

hoyc1 commented May 1, 2024

@spxiwh, I think I have fixed the test failures by only adding non-default flags to the lal_pars. I think the issue was that there exists functions such as lalsimulation.SimInspiralWaveformParamsInsertMass1, and mass1 is included in the provided dictionary. I am happy to hear other suggestions though!

@spxiwh
Copy link
Contributor

spxiwh commented May 1, 2024

Wait, what!? Why is there a lalsimulation.SimInspiralWaveformParamsInsertMass1 if mass1 has to be provided explicitly to the waveform generator anyway?

for key, value in p.items():
if (value is None) or (key in default_args.keys()):
continue
camelcase = "".join([subkey.capitalize() for subkey in key.split("_")])
Copy link
Member

Choose a reason for hiding this comment

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

Can any of the following lines be removed then if this is added? It would seem to serve in large part a similar purpose. Not all of course (modes for example would not work), but some of the nongr params probably could be not explicitly given now.

Copy link
Contributor Author

@hoyc1 hoyc1 May 1, 2024

Choose a reason for hiding this comment

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

@ahnitz, I would need to change the logic to account for the nongr params, or potentially deprecate the existing pycbc names and change them to new names. For example, the current nongr params in pycbc follow the convention e.g. dchi0 but the lalsimulation function requires them to be NonGRDChi0. I could remove frame_axis and modes_choice, but they would also need to be removed from the default_args (in order to prevent the issue above).

Copy link
Member

Choose a reason for hiding this comment

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

No, I don't think we want to change the standardized names. One could remove code duplication with a dict, though, no?

Also, have you checked how slow this procedure is? What sort of overhead does it introduce?

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, the LALDict internally uses exactly the same field name as pycbc anyway (https://git.ligo.org/lscsoft/lalsuite/-/blob/master/lalsimulation/lib/LALSimInspiralWaveformParams.c#L1326) - it is only the name of the 'Insert' function that is unpredictable.

After importing lalsimulation it is possible to get a mapping from the dictionary key to the Insert function in any case - LVK people can see here how to do that via dir(lalsimulation) (it's not anything that should be secret ...)
https://git.ligo.org/waveforms/new-waveforms-interface/-/issues/49#note_1028009

@tdent
Copy link
Contributor

tdent commented May 16, 2024

FWIW, the redundant looking InsertMass1 (etc) functions are part of the 'New Waveform Interface', see here
https://git.ligo.org/lscsoft/lalsuite/-/commit/5dec1651a0f28879ba5a2f7015744300935f3839?page=2

@tdent
Copy link
Contributor

tdent commented May 16, 2024

So the 'key' here is actually the last part of the SimInspiralInsert function name, rather than the LALDict key name itself, if I've understood correctly. I guess this is an inevitable consequence of the lalsim code not having a predictable mapping from the key name to the function name ...

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.

None yet

4 participants