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

Open
wants to merge 36 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. Allowing Enterprise to be useful without a timing package was a big plus, but with libstempo/PINT optional I guess that's less of an advantage now

Todo:

  • Create unit 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

Attention: Patch coverage is 98.62069% with 2 lines in your changes missing coverage. Please review.

Project coverage is 73.31%. Comparing base (e82c676) to head (49180cc).
Report is 17 commits behind head on dev.

Files with missing lines Patch % Lines
enterprise/pulsar.py 94.44% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##              dev     #361      +/-   ##
==========================================
+ Coverage   71.53%   73.31%   +1.77%     
==========================================
  Files          13       13              
  Lines        3246     3391     +145     
==========================================
+ Hits         2322     2486     +164     
+ Misses        924      905      -19     
Files with missing lines Coverage Δ
enterprise/signals/utils.py 85.29% <100.00%> (+3.18%) ⬆️
enterprise/pulsar.py 36.61% <94.44%> (+8.04%) ⬆️

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 53a258b...49180cc. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@vhaasteren vhaasteren marked this pull request as ready for review March 28, 2025 14:44
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