nanograv / enterprise

ENTERPRISE (Enhanced Numerical Toolbox Enabling a Robust PulsaR Inference SuitE) is a pulsar timing analysis code, aimed at noise analysis, gravitational-wave searches, and timing model analysis.
https://enterprise.readthedocs.io
MIT License
64 stars 65 forks source link

Merge EPTA version part 1 #373

Closed siyuan-chen closed 4 months ago

siyuan-chen commented 8 months ago

This pull request is part 1/2 to merge the EPTA enterprise into the NANOGrav version.

It adds more selection functions, for EPTA work and also a general generator function to use any flag with any value as selection criteria. custom_backends_dict() takes a dictionary of {"flagname": "value"} and returns a selection based on the dictionary.

vhaasteren commented 6 months ago

Hi @siyuan-chen, this looks great. Aside from the fact that you need to lint the code first (use black), I have one comment:

I recently created a very similar selection function for my IPTA data combination project. Since I didn't want to touch the tim files, I needed a function that could work on multiple flags. So for ECORR, you can do:

ecorr_sel = selections.Selection(create_selection_stag("ecorr", {('B', 'f'): None}))

('stag' is for 'staggered', so with a fallback. Not a great name, I know)

If you only want to use NANOGrav backends, it'd be:

ecorr_sel = selections.Selection(create_selection_stag("ecorr", {('B', 'f'): ["ASP", "GASP", "GUPPI", "PUPPI", "YUPPI"]}))

or just

ecorr_sel = selections.Selection(create_selection_stag("ecorr", {'f': ["ASP", "GASP", "GUPPI", "PUPPI", "YUPPI"]}))

The syntax of what I wrote seems to be a superset of what you wrote, so all EPTA code should work with it. Is it an idea to update it? My code is very ugly though (which is why I didn't put it out there yet), but I'm happy to share if you don't judge.