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

Add MockPulsar class, for easy use of Mock data with Enterprise #361

Open vhaasteren opened 11 months ago

vhaasteren commented 11 months ago

This adds a very rudimentary MockPulsar class: a class that can be easily instantiated without a timing package (PINT/Tempo2). All Enterprise models can be run on this type of pulsar object, but it can be instantiated from mock data very quickly. This is useful for anyone who wants to use Enterprise on fake data. Previously, one had to rely on fake par/tim files, created through libstempo.toasim or otherwise.

Note: this is coded up as part of Enterprise, and not Enterprise_extensions, because the pulsar class is essential for usage of Enterprise. By allowing Enterprise to be useful without a timing package is a big plus

Todo:

Additional todo, perhaps not part of this PR:

As in the test suite, a typical way to add this pulsar is:

toas = np.linspace(53000.0, 58000.0, 4005)
flags = {"f": np.array(["nosystem"] * 4005), "fe": np.array(["nofrontend"] * 4005)}
decj, raj = (0.16848694562363042, 4.9533700839400492)
# Can also define elong/elat

psr = MockPulsar(
    obs_times_mjd=toas,
    raj=raj,
    decj=decj,
    ssbfreqs=1440.0 * np.ones_like(toas),
    residuals=np.zeros_like(toas),
    toaerrs=1e-6 * np.ones_like(toas),
    sort=True,
    flags=flags,
    telescope="GBT",
    spindown_order=2,
    inc_astrometry=True,
)

This pulsar now has psr.name == 'J1855+0939', and the design matrix contains astrometry and spin models (so 8 parameters). Residuals can be set with:

psr.set_residuals(residuals)

This pulsar is extremely fast to make, and can be combined with most Enterprise functionality. Astrometry parameters depend on Astropy (optional dependency).

codecov[bot] commented 9 months ago

Codecov Report

Merging #361 (143bb6b) into dev (d782c29) will increase coverage by 0.51%. The diff coverage is 100.00%.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/nanograv/enterprise/pull/361/graphs/tree.svg?width=650&height=150&src=pr&token=7Sjk8cLA85&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nanograv)](https://app.codecov.io/gh/nanograv/enterprise/pull/361?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nanograv) ```diff @@ Coverage Diff @@ ## dev #361 +/- ## ========================================== + Coverage 88.42% 88.94% +0.51% ========================================== Files 13 13 Lines 3033 3174 +141 ========================================== + Hits 2682 2823 +141 Misses 351 351 ``` | [Files](https://app.codecov.io/gh/nanograv/enterprise/pull/361?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nanograv) | Coverage Δ | | |---|---|---| | [enterprise/pulsar.py](https://app.codecov.io/gh/nanograv/enterprise/pull/361?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nanograv#diff-ZW50ZXJwcmlzZS9wdWxzYXIucHk=) | `92.66% <100.00%> (+0.60%)` | :arrow_up: | | [enterprise/signals/utils.py](https://app.codecov.io/gh/nanograv/enterprise/pull/361?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nanograv#diff-ZW50ZXJwcmlzZS9zaWduYWxzL3V0aWxzLnB5) | `89.18% <100.00%> (+2.41%)` | :arrow_up: | ------ [Continue to review full report in Codecov by Sentry](https://app.codecov.io/gh/nanograv/enterprise/pull/361?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nanograv). > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nanograv) > `Δ = absolute (impact)`, `ø = not affected`, `? = missing data` > Powered by [Codecov](https://app.codecov.io/gh/nanograv/enterprise/pull/361?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nanograv). Last update [d782c29...143bb6b](https://app.codecov.io/gh/nanograv/enterprise/pull/361?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nanograv). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nanograv).