From 38db107e2c95a3e1f96c08cf0445fda8ba5d71bb Mon Sep 17 00:00:00 2001 From: Abhimanyu Susobhanan Date: Thu, 20 Jun 2024 10:59:19 +0200 Subject: [PATCH 1/8] cleanup deps --- .gitignore | 2 +- Project.toml | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index f9f8b1d..4f3ada6 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,7 @@ *.jl.*.cov # Files generated by invoking Julia with --track-allocation -*.jl.mem +*.jl.*.mem # System-specific files and directories generated by the BinaryProvider and BinDeps packages # They contain absolute paths specific to the host computer, and so should not be committed diff --git a/Project.toml b/Project.toml index e7d630e..264ed0c 100644 --- a/Project.toml +++ b/Project.toml @@ -6,14 +6,19 @@ version = "0.1.1" [deps] Artifacts = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" DataInterpolations = "82cc6244-b520-54b8-b5a6-8a565e85f1d0" -FiniteDifferences = "26cc04aa-876d-5657-8c51-4c34ba976000" HypergeometricFunctions = "34004b35-14d8-5ef3-9330-4cdb6864b03a" JLD = "4138dd39-2aa7-5051-a626-17a0bb65d9c8" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" -NumericalIntegration = "e7bfaba1-d571-5449-8927-abc22e82249b" PhysicalConstants = "5ad8b20f-a522-5ce9-bfc9-ddf1d5bda6ab" +Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" +UnitfulAstro = "6112ee07-acf9-5e0f-b108-d242c714bf9f" + +[extras] +FiniteDifferences = "26cc04aa-876d-5657-8c51-4c34ba976000" +NumericalIntegration = "e7bfaba1-d571-5449-8927-abc22e82249b" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" UnPack = "3a884ed6-31ef-47d7-9d2a-63182c4928ed" -Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" -UnitfulAstro = "6112ee07-acf9-5e0f-b108-d242c714bf9f" + +[targets] +test = ["FiniteDifferences", "NumericalIntegration", "Statistics", "Test", "UnPack"] \ No newline at end of file From aa944f641cf3f7c67dc13e7917d87c7176b2d3b7 Mon Sep 17 00:00:00 2001 From: Abhimanyu Susobhanan Date: Thu, 20 Jun 2024 10:59:28 +0200 Subject: [PATCH 2/8] remove unnecessary alloc --- src/residual.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/residual.jl b/src/residual.jl index 67303c6..7970c3b 100644 --- a/src/residual.jl +++ b/src/residual.jl @@ -99,13 +99,13 @@ function residuals( tref::Time, tEs::Vector{Time}, ) - dts = [tE - tref for tE in tEs] + # dts = [tE - tref for tE in tEs] coeffs = EvolvCoeffs(mass, n_init, e_init) ap = AntennaPattern(psrpos, gwpos) Δp = pulsar_term_delay(ap, dp) - ss = [residual(mass, coeffs, l0p, proj, ap, terms, Δp, dt) for dt in dts] + ss = [residual(mass, coeffs, l0p, proj, ap, terms, Δp, tE - tref) for tE in tEs] return ss end From 2db300441d1db9bc726d56da8226a3544055b103 Mon Sep 17 00:00:00 2001 From: Abhimanyu Susobhanan Date: Thu, 20 Jun 2024 11:20:18 +0200 Subject: [PATCH 3/8] ci --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 102a38d..0889a02 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -88,7 +88,6 @@ jobs: - name: Run examples run: | cd examples - julia benchmark.jl julia lbar_gammabar_vs_e.jl julia residuals_1psr.jl julia residuals_components.jl @@ -96,6 +95,7 @@ jobs: julia residuals_terms_px.jl julia tau_vs_e.jl julia waveform_residuals_px.jl + julia benchmark.jl python simulation_example.py python enterprise_example.py cd .. From ed55ee6538112a564843733ee3941f06b1eb141a Mon Sep 17 00:00:00 2001 From: Abhimanyu Susobhanan Date: Thu, 20 Jun 2024 11:44:18 +0200 Subject: [PATCH 4/8] update ci --- .github/workflows/ci.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0889a02..9109dea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,8 +17,7 @@ jobs: matrix: version: - '1.8' - - '1' - - 'nightly' + - '1.9' os: - ubuntu-latest arch: @@ -51,7 +50,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.8", "3.9", "3.10"] + python-version: ["3.10"] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} @@ -68,7 +67,7 @@ jobs: pip install . - name: Test with pytest run: | - pytest --full-trace --cov-report xml --cov enterprise_gwecc + pytest --full-trace --cov-report xml --cov test/test_enterprise_gwecc.py # - name: Codecov # uses: codecov/codecov-action@v3 From 3ef07a52e2db79ef33be4199e9d8da021c7cb09a Mon Sep 17 00:00:00 2001 From: Abhimanyu Susobhanan Date: Thu, 20 Jun 2024 13:22:52 +0200 Subject: [PATCH 5/8] fixture --- test/test_enterprise_gwecc.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/test/test_enterprise_gwecc.py b/test/test_enterprise_gwecc.py index c4607ef..26df25b 100644 --- a/test/test_enterprise_gwecc.py +++ b/test/test_enterprise_gwecc.py @@ -25,9 +25,12 @@ ) testdatadir = pathlib.Path(__file__).resolve().parent / "testdata" -par = str(testdatadir / "J1909-3744_NANOGrav_12yv4.gls.par") -tim = str(testdatadir / "J1909-3744_NANOGrav_12yv4.tim") -psr = Pulsar(par, tim) + +@pytest.fixture +def psr(): + par = str(testdatadir / "J1909-3744_NANOGrav_12yv4.gls.par") + tim = str(testdatadir / "J1909-3744_NANOGrav_12yv4.tim") + return Pulsar(par, tim, timing_package="pint") year = 365.25 * 24 * 3600 @@ -136,7 +139,7 @@ def test_eccentric_pta_signal_target(psrTerm, spline): "psrTerm, tie_psrTerm, spline", it.product([True, False], [True, False], [True, False]), ) -def test_gwecc_block(psrTerm, tie_psrTerm, spline): +def test_gwecc_block(psr, psrTerm, tie_psrTerm, spline): tref = max(psr.toas) tm = MarginalizingTimingModel() @@ -180,7 +183,7 @@ def test_gwecc_block(psrTerm, tie_psrTerm, spline): @pytest.mark.parametrize("psrTerm, spline", it.product([True, False], [True, False])) -def test_gwecc_1psr_block(psrTerm, spline): +def test_gwecc_1psr_block(psr, psrTerm, spline): tref = max(psr.toas) tm = MarginalizingTimingModel() @@ -218,7 +221,7 @@ def test_gwecc_1psr_block(psrTerm, spline): "psrTerm, tie_psrTerm, spline", it.product([True, False], [True, False], [True, False]), ) -def test_gwecc_target_block(psrTerm, tie_psrTerm, spline): +def test_gwecc_target_block(psr, psrTerm, tie_psrTerm, spline): tref = max(psr.toas) tm = MarginalizingTimingModel() @@ -266,7 +269,7 @@ def test_gwecc_target_block(psrTerm, tie_psrTerm, spline): assert lnprior_fn(x0) == -np.inf -def test_psrdist_prior(): +def test_psrdist_prior(psr): parfiles = sorted(glob.glob(f"{testdatadir}/*.par")) timfiles = sorted(glob.glob(f"{testdatadir}/*.tim")) From 4ff9799cfd0e761c9ed5797a056da0df448f2e63 Mon Sep 17 00:00:00 2001 From: Abhimanyu Susobhanan Date: Tue, 25 Jun 2024 07:52:47 +0200 Subject: [PATCH 6/8] parallel residual computation --- Project.toml | 3 ++- src/residual.jl | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 264ed0c..066735b 100644 --- a/Project.toml +++ b/Project.toml @@ -10,6 +10,7 @@ HypergeometricFunctions = "34004b35-14d8-5ef3-9330-4cdb6864b03a" JLD = "4138dd39-2aa7-5051-a626-17a0bb65d9c8" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" PhysicalConstants = "5ad8b20f-a522-5ce9-bfc9-ddf1d5bda6ab" +ThreadsX = "ac1d9e8a-700a-412c-b207-f0111f4b6c0d" Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" UnitfulAstro = "6112ee07-acf9-5e0f-b108-d242c714bf9f" @@ -21,4 +22,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" UnPack = "3a884ed6-31ef-47d7-9d2a-63182c4928ed" [targets] -test = ["FiniteDifferences", "NumericalIntegration", "Statistics", "Test", "UnPack"] \ No newline at end of file +test = ["FiniteDifferences", "NumericalIntegration", "Statistics", "Test", "UnPack"] diff --git a/src/residual.jl b/src/residual.jl index 7970c3b..aab9d4f 100644 --- a/src/residual.jl +++ b/src/residual.jl @@ -1,5 +1,7 @@ export waveform, residual, residuals, residual_and_waveform, residuals_and_waveform +import ThreadsX + "PTA waveform." function waveform( mass::Mass, @@ -105,7 +107,8 @@ function residuals( ap = AntennaPattern(psrpos, gwpos) Δp = pulsar_term_delay(ap, dp) - ss = [residual(mass, coeffs, l0p, proj, ap, terms, Δp, tE - tref) for tE in tEs] + resid_fn = tE -> residual(mass, coeffs, l0p, proj, ap, terms, Δp, tE - tref) + ss = ThreadsX.map(resid_fn, tEs) return ss end From 1c29b6bbd432a5af3124afaea708c4bb0df813f7 Mon Sep 17 00:00:00 2001 From: Abhimanyu Susobhanan Date: Tue, 25 Jun 2024 07:56:44 +0200 Subject: [PATCH 7/8] cleanup --- src/residual.jl | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/residual.jl b/src/residual.jl index aab9d4f..0555f39 100644 --- a/src/residual.jl +++ b/src/residual.jl @@ -101,8 +101,6 @@ function residuals( tref::Time, tEs::Vector{Time}, ) - # dts = [tE - tref for tE in tEs] - coeffs = EvolvCoeffs(mass, n_init, e_init) ap = AntennaPattern(psrpos, gwpos) Δp = pulsar_term_delay(ap, dp) From ec3d73c2abc46b83a743ea0bc841d2316250645a Mon Sep 17 00:00:00 2001 From: Abhimanyu Susobhanan Date: Tue, 25 Jun 2024 08:04:21 +0200 Subject: [PATCH 8/8] 0 --- src/antennapattern.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/antennapattern.jl b/src/antennapattern.jl index eacf061..3abe25a 100644 --- a/src/antennapattern.jl +++ b/src/antennapattern.jl @@ -41,7 +41,7 @@ function gw_polarization_tensors(pos::SkyLocation) e32c = cos(λ) * cos(β) e13c = -sin(λ) * cos(β) e23c = cos(λ) * cos(β) - e33c = 0 + e33c = 0.0 ep = [e11p e12p e13p; e21p e22p e23p; e31p e32p e33p] ec = [e11c e12c e13c; e21c e22c e23c; e31c e32c e33c]