nanograv / enterprise_extensions

A set of extension codes, utilities, and scripts for the enterprise PTA analysis framework.
MIT License
27 stars 60 forks source link

Check keywords existing in models.py before checking psr.flags #212

Open mtlam opened 1 year ago

mtlam commented 1 year ago

I met with a few folks in Europe to try to get our timing (pint_pal) and noise modeling working with simulated libstempo data. However, the simulated tim files lacked the pta and f flags needed in models.py and caused a crash: https://github.com/nanograv/enterprise_extensions/blob/541dd1f9a835f790ef4c721d83e80d206b68a941/enterprise_extensions/models.py#L320

They were able to fake it out by giving a fake pta flag but also needing a fake f flag. I was going to go in to change these to check for the existence of these flags first in the if statement but checks for 'NANOGrav' in psr.flags['pta'] are throughout the code.

While perhaps less safe, I would recommend writing a helper function somewhere along the lines of

def check_flag(psr, key, value):
    return (key in psr.flags and value in psr.flags[key])

and then replacing the if statements appropriately throughout.