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 MockPulsar class, for easy use of Mock data with Enterprise #361

Draft
wants to merge 15 commits into
base: dev
Choose a base branch
from

Conversation

vhaasteren
Copy link
Member

@vhaasteren vhaasteren commented Sep 29, 2023

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:

  • Create unit tests
  • Add documentation for the MockPulsar class
  • Allow for pickling and write such tests
  • Add Astrometry parameters, aside from only Spindown

Additional todo, perhaps not part of this PR:

  • Add helper functions to enterprise_extensions so this class can be instantiated easily
  • Resolve unit disparity of PMRA / PMDEC between Tempo2 and PINT
  • Add documentation for Tempo2Pulsar and PintPulsar

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).

@vhaasteren vhaasteren marked this pull request as draft September 29, 2023 06:58
@vhaasteren vhaasteren changed the base branch from master to dev November 7, 2023 08:57
Copy link

codecov bot commented Nov 28, 2023

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

@@            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 Coverage Δ
enterprise/pulsar.py 92.66% <100.00%> (+0.60%) ⬆️
enterprise/signals/utils.py 89.18% <100.00%> (+2.41%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d782c29...143bb6b. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant