From f68771eb72f1e665f89515ae12802ae4b5556426 Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Mon, 16 Oct 2023 16:16:12 -0500 Subject: [PATCH 1/3] fixed units on errors --- CHANGELOG-unreleased.md | 1 + src/pint/simulation.py | 2 -- tests/test_random_models.py | 12 ++++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG-unreleased.md b/CHANGELOG-unreleased.md index 58be0054e..27a99344f 100644 --- a/CHANGELOG-unreleased.md +++ b/CHANGELOG-unreleased.md @@ -30,4 +30,5 @@ 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` respects units of errors ### 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..ac4c55564 100644 --- a/tests/test_random_models.py +++ b/tests/test_random_models.py @@ -3,6 +3,8 @@ import pytest import numpy as np +from astropy import units as u + from pint.models import get_model, get_model_and_toas from pint.toa import get_TOAs import pint.fitter @@ -10,6 +12,16 @@ from pinttestdata import datadir +@pytest.mark.parametrize("error", [1 * u.us, 1, 10 * u.ns, 1 * u.ms]) +def test_fake_errors(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( "fitter", [ From 973987f6db3e52cdff95e2c38e822d804c26a0de Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Tue, 17 Oct 2023 09:43:06 -0500 Subject: [PATCH 2/3] more tests --- tests/test_random_models.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/test_random_models.py b/tests/test_random_models.py index ac4c55564..b2bc34088 100644 --- a/tests/test_random_models.py +++ b/tests/test_random_models.py @@ -4,6 +4,7 @@ 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 @@ -13,7 +14,7 @@ @pytest.mark.parametrize("error", [1 * u.us, 1, 10 * u.ns, 1 * u.ms]) -def test_fake_errors(error): +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): @@ -22,6 +23,17 @@ def test_fake_errors(error): 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", [ From 6bf48dcf3d8f14a58bc14d8c7fd0addbe53ec577 Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Wed, 18 Oct 2023 17:31:06 -0500 Subject: [PATCH 3/3] fixed changelog --- CHANGELOG-unreleased.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG-unreleased.md b/CHANGELOG-unreleased.md index d5ab7fdd8..10566b480 100644 --- a/CHANGELOG-unreleased.md +++ b/CHANGELOG-unreleased.md @@ -34,6 +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` respects units of errors +- `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