Skip to content

Commit

Permalink
Merge branch 'main' into faster
Browse files Browse the repository at this point in the history
  • Loading branch information
abhisrkckl committed Jun 20, 2024
2 parents 3ef07a5 + 6e62621 commit b7913e1
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 101 deletions.
31 changes: 20 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ jobs:
fail-fast: false
matrix:
version:
- '1.8'
- '1.9'
- '1.10'
os:
- ubuntu-latest
arch:
Expand Down Expand Up @@ -50,7 +50,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10"]
python-version: ["3.9", "3.10"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -76,14 +76,24 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v1
env:
cache-name: cache-eg-artifacts
with:
path: ~/.julia/eg-artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- name: Install dependencies
run: |
sudo apt-get install libsuitesparse-dev
curl -sSL https://raw.githubusercontent.com/vallis/libstempo/master/install_tempo2.sh | sh
python -m pip install --upgrade pip setuptools wheel pytest pytest-cov libstempo
pip install -r requirements.txt
julia -e 'import Pkg; Pkg.add(path="."); Pkg.add(["BenchmarkTools", "PyPlot", "PythonCall"])'
pip install .
# sudo apt-get install libsuitesparse-dev
# curl -sSL https://raw.githubusercontent.com/vallis/libstempo/master/install_tempo2.sh | sh
# python -m pip install --upgrade pip setuptools wheel pytest pytest-cov libstempo
# pip install -r requirements.txt
julia -t 4 -e 'import Pkg; Pkg.add(path="."); Pkg.add(["BenchmarkTools", "CairoMakie"])'
# pip install .
- name: Run examples
run: |
cd examples
Expand All @@ -94,9 +104,8 @@ 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
# python simulation_example.py
# python enterprise_example.py
cd ..
format:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ examples/gwecc_sims*
.coverage
coverage.xml

*.pdf
*.pdf
*.png
13 changes: 7 additions & 6 deletions examples/lbar_gammabar_vs_e.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
Figure 3 of Susobhanan+ 2020"""

using GWecc
using PyPlot
import CairoMakie

println("Running ", PROGRAM_FILE)

es = Eccentricity.(LinRange(0.01, 0.99, 1000))
lbars = lbar_from_e.(es)
γbars = γbar_from_e.(es)

plot([e.e for e in es], [lbar.lbar for lbar in lbars])
plot([e.e for e in es], γbars)
ylabel("\$\\bar{l}\$, \$\\bar{\\gamma}\$")
xlabel("\$e\$")
show()
fig, ax, plt = CairoMakie.lines([e.e for e in es], [lbar.lbar for lbar in lbars])
CairoMakie.lines!([e.e for e in es], γbars)
ax.ylabel = "lbar, gammabar"
ax.xlabel = "e"
CairoMakie.current_figure()
CairoMakie.save("lbar_gammabar_vs_e.pdf", fig)
15 changes: 8 additions & 7 deletions examples/residuals_1psr.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import PyPlot
import CairoMakie
using GWecc

println("Running ", PROGRAM_FILE)
Expand Down Expand Up @@ -41,9 +41,10 @@ proj1 = ProjectionParams1psr(proj, ap)
Rs = residuals(mass, n_init, e_init, l0p, proj, dp, psrpos, gwpos, [EARTH], tref, tEs)
Rs1 = residuals_1psr(mass, n_init, e_init, l_init, proj1, Δp, [EARTH], tref, tEs)

PyPlot.plot(extract(tEs) / year, Rs * 1e9, label = "Full waveform")
PyPlot.plot(extract(tEs) / year, Rs1 * 1e9, label = "Single pulsar")
PyPlot.legend()
PyPlot.xlabel("t (year)")
PyPlot.ylabel("R(t) (ns)")
PyPlot.show()
fig, ax, plt = CairoMakie.lines(extract(tEs) / year, Rs * 1e9, label = "Full waveform")
CairoMakie.lines!(extract(tEs) / year, Rs1 * 1e9, label = "Single pulsar")
CairoMakie.axislegend(ax)
ax.xlabel = "t (year)"
ax.ylabel = "R(t) (ns)"
CairoMakie.current_figure()
CairoMakie.save("residuals_1psr.pdf", fig)
45 changes: 23 additions & 22 deletions examples/residuals_components.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""PTA signal components for fast likelihood"""

using GWecc
using PyPlot
using CairoMakie

println("Running ", PROGRAM_FILE)

Expand Down Expand Up @@ -39,32 +39,33 @@ sPs1 = residuals(mass, n_init, e_init, l0p, proj, dp, psrpos, gwpos, [PULSAR], t
sEs2 = residuals(mass, n_init, e_init, l0p, proj, dp, psrpos, gwpos, [EARTH], tref, tEs)
sPs2 = residuals(mass, n_init, e_init, l0p, proj, dp, psrpos, gwpos, [PULSAR], tref, tEs)

subplot(221)
fig = CairoMakie.Figure()
ax1 = CairoMakie.Axis(fig[1, 1])
for (idx, 𝒜E) in enumerate(𝒜Es)
plot(tyrs, 𝒜E, label = "\$A_{$idx,E}\$")
CairoMakie.lines!(ax1, tyrs, 𝒜E, label = "A_$idx[E]")
end
legend()
ylabel("\$A_{i,E}\$")
xlabel("t (year)")
CairoMakie.axislegend(ax1, framevisible = false)
ax1.ylabel = "A_i[E]"
ax1.xlabel = "t (year)"

subplot(222)
plot(tyrs, sEs1)
plot(tyrs, sEs2)
ylabel("\$s_E\$")
xlabel("t (year)")
ax2 = CairoMakie.Axis(fig[1, 2])
CairoMakie.lines!(ax2, tyrs, sEs1)
CairoMakie.lines!(ax2, tyrs, sEs2)
ax2.ylabel = "s_E"
ax2.xlabel = "t (year)"

subplot(223)
ax3 = CairoMakie.Axis(fig[2, 1])
for (idx, 𝒜P) in enumerate(𝒜Ps)
plot(tyrs, 𝒜P, label = "\$A_{$idx,P}\$")
CairoMakie.lines!(ax3, tyrs, 𝒜P, label = "A_$idx[P]")
end
legend()
ylabel("\$A_{i,P}\$")
xlabel("t (year)")
CairoMakie.axislegend(ax3, framevisible = false)
ax3.ylabel = "A_i[P]"
ax3.xlabel = "t (year)"

subplot(224)
plot(tyrs, sPs1)
plot(tyrs, sPs2)
ylabel("\$s_P\$")
xlabel("t (year)")
ax4 = CairoMakie.Axis(fig[2, 2])
CairoMakie.lines!(ax4, tyrs, sPs1)
CairoMakie.lines!(tyrs, sPs2)
ax4.ylabel = "s_P"
ax4.xlabel = "t (year)"

show()
CairoMakie.save("residuals_components.pdf", fig)
30 changes: 16 additions & 14 deletions examples/residuals_terms.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""PTA signals - Earth and Pulsar terms"""

using GWecc
using PyPlot
using CairoMakie

println("Running ", PROGRAM_FILE)

Expand All @@ -28,6 +28,8 @@ dp = Distance(500 * parsec)
tEs = Time.(LinRange(0, 10 * year, 5000))
tyrs = [t.t for t in tEs] / year

fig = CairoMakie.Figure()

for (idx, e_init) in enumerate(Eccentricity.([0.1, 0.4, 0.7]))

sEs = residuals(mass, n_init, e_init, l0p, proj, dp, psrpos, gwpos, [EARTH], tref, tEs)
Expand All @@ -46,20 +48,20 @@ for (idx, e_init) in enumerate(Eccentricity.([0.1, 0.4, 0.7]))
tEs,
)

subplot(330 + 3 * (idx - 1) + 1)
plot(tyrs, sEs)
ylabel("\$s_E\$")
xlabel("t (year)")
ax1 = CairoMakie.Axis(fig[idx, 1])
CairoMakie.lines!(ax1, tyrs, sEs)
ax1.ylabel = "s_E"
ax1.xlabel = "t (year)"

subplot(330 + 3 * (idx - 1) + 2)
plot(tyrs, sPs)
ylabel("\$s_P\$")
xlabel("t (year)")
ax2 = CairoMakie.Axis(fig[idx, 2])
CairoMakie.lines!(ax2, tyrs, sPs)
ax2.ylabel = "s_P"
ax2.xlabel = "t (year)"

subplot(330 + 3 * (idx - 1) + 3)
plot(tyrs, ss)
ylabel("\$s\$")
xlabel("t (year)")
ax3 = CairoMakie.Axis(fig[idx, 3])
CairoMakie.lines!(ax3, tyrs, ss)
ax3.ylabel = "s"
ax3.xlabel = "t (year)"
end

show()
CairoMakie.save("residuals_terms.pdf", fig)
48 changes: 25 additions & 23 deletions examples/residuals_terms_px.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""PTA signals - Earth and Pulsar terms and +/x polarizations"""

using GWecc
using PyPlot
using CairoMakie

println("Running ", PROGRAM_FILE)

Expand All @@ -28,6 +28,8 @@ dp = Distance(500 * parsec)
tEs = Time.(LinRange(0, 10 * year, 5000))
tyrs = [t.t for t in tEs] / year

fig = CairoMakie.Figure()

for (idx, e_init) in enumerate(Eccentricity.([0.1, 0.4, 0.7]))

spEs, sxEs =
Expand All @@ -37,27 +39,27 @@ for (idx, e_init) in enumerate(Eccentricity.([0.1, 0.4, 0.7]))
residuals_px(mass, n_init, e_init, l0p, proj, dp, psrpos, gwpos, PULSAR, tref, tEs)
sPs = residuals(mass, n_init, e_init, l0p, proj, dp, psrpos, gwpos, [PULSAR], tref, tEs)

subplot(3, 4, 4 * (idx - 1) + 1)
plot(tyrs, spEs)
plot(tyrs, sxEs)
ylabel("\$s_{E(+/x)}\$")
xlabel("t (year)")

subplot(3, 4, 4 * (idx - 1) + 2)
plot(tyrs, sEs)
ylabel("\$s_E\$")
xlabel("t (year)")

subplot(3, 4, 4 * (idx - 1) + 3)
plot(tyrs, spPs)
plot(tyrs, sxPs)
ylabel("\$s_{P(+/x)}\$")
xlabel("t (year)")

subplot(3, 4, 4 * (idx - 1) + 4)
plot(tyrs, sPs)
ylabel("\$s_P\$")
xlabel("t (year)")
ax1 = CairoMakie.Axis(fig[idx, 1])
CairoMakie.lines!(ax1, tyrs, spEs)
CairoMakie.lines!(ax1, tyrs, sxEs)
ax1.ylabel = "s_E(+/x)"
ax1.xlabel = "t (year)"

ax2 = CairoMakie.Axis(fig[idx, 2])
CairoMakie.lines!(ax2, tyrs, sEs)
ax2.ylabel = "s_E"
ax2.xlabel = "t (year)"

ax3 = CairoMakie.Axis(fig[idx, 3])
CairoMakie.lines!(ax3, tyrs, spPs)
CairoMakie.lines!(ax3, tyrs, sxPs)
ax3.ylabel = "s_P(+/x)"
ax3.xlabel = "t (year)"

ax4 = CairoMakie.Axis(fig[idx, 4])
CairoMakie.lines!(ax4, tyrs, sPs)
ax4.ylabel = "s_P"
ax4.xlabel = "t (year)"
end

show()
CairoMakie.save("residuals_terms_px.pdf", fig)
12 changes: 7 additions & 5 deletions examples/tau_vs_e.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
Figure 2 of Susobhanan+ 2020"""

using GWecc
using PyPlot
using CairoMakie

println("Running ", PROGRAM_FILE)

es = Eccentricity.(LinRange(0.01, 0.99, 1000))
τs = τ_from_e.(es)

plot([τ.τ for τ in τs], [e.e for e in es])
xlabel("τ")
ylabel("e")
show()
fig = Figure()
ax = Axis(fig[1, 1])
CairoMakie.lines!([τ.τ for τ in τs], [e.e for e in es])
ax.xlabel = "τ"
ax.ylabel = "e"
save("tau_vs_e.pdf", fig)
26 changes: 14 additions & 12 deletions examples/waveform_residuals_px.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Comparison of eccentric waveforms and residuals (+/x polarizations) for different eccentricities."""

using GWecc
using PyPlot
using CairoMakie

println("Running ", PROGRAM_FILE)

Expand All @@ -17,28 +17,30 @@ proj = ProjectionParams(1e-9, 0.0, 1.0, 0.0, 0.0)

ts = Time.(LinRange(0, 10 * year, 5000))

fig = CairoMakie.Figure()

for (idx, e_init) in enumerate(Eccentricity.([0.1, 0.4, 0.8]))
coeffs = EvolvCoeffs(mass, n_init, e_init)

hpxs = [waveform_px(mass, coeffs, l0p, proj, false, dt) for dt in ts]
hps = [hpx[1] for hpx in hpxs]
hxs = [hpx[2] for hpx in hpxs]

subplot(320 + 2 * idx - 1)
plot([t.t for t in ts] / year, hps)
plot([t.t for t in ts] / year, hxs)
ylabel("\$h_{+,\\times}\$")
xlabel("t (year)")
ax1 = CairoMakie.Axis(fig[idx, 1])
CairoMakie.lines!(ax1, [t.t for t in ts] / year, hps)
CairoMakie.lines!(ax1, [t.t for t in ts] / year, hxs)
ax1.ylabel = "h+, hx"
ax1.xlabel = "t (year)"

spxs = [residual_px(mass, coeffs, l0p, proj, false, dt) for dt in ts]
sps = [spx[1] for spx in spxs]
sxs = [spx[2] for spx in spxs]

subplot(320 + 2 * idx)
plot([t.t for t in ts] / year, sps)
plot([t.t for t in ts] / year, sxs)
ylabel("\$s_{+,\\times}\$")
xlabel("t (year)")
ax2 = CairoMakie.Axis(fig[idx, 2])
CairoMakie.lines!(ax2, [t.t for t in ts] / year, sps)
CairoMakie.lines!(ax2, [t.t for t in ts] / year, sxs)
ax2.ylabel = "s+, sx"
ax2.xlabel = "t (year)"
end

show()
save("waveform_residuals_px.pdf", fig)

0 comments on commit b7913e1

Please sign in to comment.