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

Fixed units on errors in fake TOAs #1653

Merged
merged 4 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG-unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ the released changes.
- Fixed an incorrect docstring in `pbprime()` functions.
- Fix ICRS -> ECL conversion when parameter uncertainties are not set.
- `get_TOAs` raises an exception upon finding mixed narrowband and wideband TOAs in a tim file. `TOAs.is_wideband` returns True only if *ALL* TOAs have the -pp_dm flag.
- `make_fake_toas_uniform` and `make_fake_toas_fromMJDs` respects units of errors
- `TimingModel.designmatrix()` method will fail with an informative error message if there are free unfittable parameters in the timing model.
### Removed
2 changes: 0 additions & 2 deletions src/pint/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ def make_fake_toas_uniform(
include_gps=clk_version["include_gps"],
planets=model["PLANET_SHAPIRO"].value if "PLANET_SHAPIRO" in model else False,
)
ts.table["error"] = error

if wideband:
ts = update_fake_dms(model, ts, wideband_dm_error, add_noise)
Expand Down Expand Up @@ -412,7 +411,6 @@ def make_fake_toas_fromMJDs(
include_gps=clk_version["include_gps"],
planets=model["PLANET_SHAPIRO"].value,
)
ts.table["error"] = error

if wideband:
ts = update_fake_dms(model, ts, wideband_dm_error, add_noise)
Expand Down
24 changes: 24 additions & 0 deletions tests/test_random_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,37 @@
import pytest
import numpy as np

from astropy import units as u
from astropy.time import Time

from pint.models import get_model, get_model_and_toas
from pint.toa import get_TOAs
import pint.fitter
from pint import simulation
from pinttestdata import datadir


@pytest.mark.parametrize("error", [1 * u.us, 1, 10 * u.ns, 1 * u.ms])
def test_fake_errors_uniform(error):
m = get_model(os.path.join(datadir, "NGC6440E.par"))
t = simulation.make_fake_toas_uniform(50000, 51000, 10, m, error=error)
if isinstance(error, u.Quantity):
assert np.all(t["error"].data * t["error"].unit == error)
else:
assert np.all(t["error"].data * t["error"].unit == error * u.us)


@pytest.mark.parametrize("error", [1 * u.us, 1, 10 * u.ns, 1 * u.ms])
def test_fake_errors_fromMJDs(error):
m = get_model(os.path.join(datadir, "NGC6440E.par"))
mjds = Time(np.arange(50000, 51000, 10), format="mjd", scale="tdb")
t = simulation.make_fake_toas_fromMJDs(mjds, m, error=error)
if isinstance(error, u.Quantity):
assert np.all(t["error"].data * t["error"].unit == error)
else:
assert np.all(t["error"].data * t["error"].unit == error * u.us)


@pytest.mark.parametrize(
"fitter",
[
Expand Down
Loading