diff --git a/CHANGELOG-unreleased.md b/CHANGELOG-unreleased.md index 8812dc3dd..10566b480 100644 --- a/CHANGELOG-unreleased.md +++ b/CHANGELOG-unreleased.md @@ -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 diff --git a/src/pint/simulation.py b/src/pint/simulation.py index 92a9c71d1..a8dcfeeca 100644 --- a/src/pint/simulation.py +++ b/src/pint/simulation.py @@ -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) @@ -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) diff --git a/tests/test_random_models.py b/tests/test_random_models.py index 2cc716bb0..b2bc34088 100644 --- a/tests/test_random_models.py +++ b/tests/test_random_models.py @@ -3,6 +3,9 @@ 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 @@ -10,6 +13,27 @@ 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", [