Skip to content

Commit 9f87d19

Browse files
committed
Fix formatting
1 parent 71ddd45 commit 9f87d19

File tree

9 files changed

+70
-115
lines changed

9 files changed

+70
-115
lines changed

examples/coordinate-example.jl

Lines changed: 16 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -26,29 +26,19 @@ set_theme!(merge!(curr_theme, theme_latexfonts()))
2626
# A region spanned by radii between the horizon and 10M at varying inclinations will be ray traced onto the 15x15
2727
# screen of the observer.
2828

29-
metric = Krang.Kerr(0.01); # Kerr metric with a spin of 0.99
29+
metric = Krang.Kerr(0.99); # Kerr metric with a spin of 0.99
3030
θo = 45 * π / 180; # inclination angle of the observer. θo ∈ (0, π)
31-
ro = 20.0
32-
sze = 40; # resolution of the screen is sze x sze
31+
sze = 400; # resolution of the screen is sze x sze
3332
rmin = Krang.horizon(metric); # minimum radius to be ray traced
34-
rmax = 6.0; # maximum radius to be ray traced
35-
ρmax = 10/ro; # horizontal and vertical limits of the screen
36-
33+
rmax = 10.0; # maximum radius to be ray traced
34+
ρmax = 15.0; # horizontal and vertical limits of the screen
3735

3836
# Initialize Camera and pre-allocate memory for data to be plotted
3937
coordinates = (zeros(sze, sze) for _ = 1:3)
40-
camera = Krang.SlowLightIntensityCamera(metric, θo, ro, -ρmax, ρmax, -ρmax, ρmax, sze);
41-
camera2 = Krang.SlowLightIntensityCamera(metric, θo, -10, 10, -10, 10, sze);
38+
camera = Krang.SlowLightIntensityCamera(metric, θo, -ρmax, ρmax, -ρmax, ρmax, sze);
4239
colormaps = (:afmhot, :afmhot, :hsv)
4340
colorrange = ((-20, 20), (0, rmax), (0, 2π))
4441

45-
46-
[i.screen_coordinate[1] for i in camera2.screen.pixels] .≈ [i.screen_coordinate[1] .* ro for i in camera.screen.pixels]
47-
48-
maximum([abs.(camera2.screen.pixels[i].η - camera.screen.pixels[i].η) for i in range(1, length(camera.screen.pixels))])
49-
maximum([abs.(camera2.screen.pixels[i].λ - camera.screen.pixels[i].λ) for i in range(1, length(camera.screen.pixels))])
50-
51-
5242
## Defining a function to get the coordinates of the geometry
5343
# Let's define a function that will return the coordinates of a ray when it intersects with a cone of opening angle $\theta_s$.
5444
# Coordinate information can be accessed using the `emission_coordinates(pixel, θs, isindir, n)` function, which returns the
@@ -87,12 +77,11 @@ function draw!(axes_list, camera, coordinates, rmin, rmax, θs)
8777
for (i, geometry) in enumerate(geometries)
8878
rendered_scene = coordinate_point.(camera.screen.pixels, Ref(geometry))
8979
for I in CartesianIndices(rendered_scene)
90-
temp = rendered_scene[I][1]
91-
times[I] = temp
80+
times[I] = rendered_scene[I][1]
9281
radii[I] = rendered_scene[I][2]
93-
azimuths[I] = mod2pi(rendered_scene[I][4]) # azimuths are in radians
82+
azimuths[I] = rendered_scene[I][4]
9483
end
95-
coordinates = (times, radii, azimuths)
84+
coordinates = (times, radii, mod2pi.(azimuths))
9685
for j = 1:3
9786
heatmap!(
9887
axes_list[i][j],
@@ -104,33 +93,6 @@ function draw!(axes_list, camera, coordinates, rmin, rmax, θs)
10493
end
10594
end
10695

107-
function draw2!(axes_list, camera, coordinates, rmin, rmax, θs)
108-
times, radii, azimuths = coordinates
109-
map(axes -> empty!.(axes), axes_list)
110-
111-
geometries = (Krang.ConeGeometry(θs, (i, rmin, rmax)) for i = 0:2)
112-
113-
for (i, geometry) in enumerate(geometries)
114-
rendered_scene = coordinate_point.(camera.screen.pixels, Ref(geometry))
115-
for I in CartesianIndices(rendered_scene)
116-
temp = rendered_scene[I][1]
117-
times[I] = temp == 0 ? 0 : temp - 2log(ro) -ro
118-
radii[I] = rendered_scene[I][2]
119-
azimuths[I] = mod2pi(rendered_scene[I][4]) # azimuths are in radians
120-
end
121-
coordinates = (times, radii, azimuths)
122-
for j = 1:3
123-
heatmap!(
124-
axes_list[i][j],
125-
coordinates[j],
126-
colormap = colormaps[j],
127-
colorrange = colorrange[j],
128-
)
129-
end
130-
end
131-
end
132-
133-
13496
# Create Figure
13597
fig = Figure(resolution = (700, 700));
13698
axes_list = [
@@ -147,38 +109,15 @@ axes_list = [
147109
] for i = 1:3
148110
]
149111

150-
draw2!(axes_list, camera, coordinates, rmin, rmax, π/2)
151-
display(fig)
152-
153-
fig = Figure(resolution = (700, 700));
154-
axes_list = [
155-
[
156-
Axis(
157-
fig[i, 1],
158-
title = (i == 1 ? "Regularized Time" : ""),
159-
titlesize = 20,
160-
ylabel = (i == 1 ? L"n=0" : i == 2 ? L"n=1" : L"n=2"),
161-
ylabelsize = 20,
162-
),
163-
Axis(fig[i, 2], title = (i == 1 ? "Radius" : ""), titlesize = 20),
164-
Axis(fig[i, 3], title = (i == 1 ? "Azimuth" : ""), titlesize = 20),
165-
] for i = 1:3
166-
]
167-
168-
draw!(axes_list, camera2, coordinates, rmin, rmax, π/2)
169-
display(fig)
170-
171-
172-
173112
# Create the animation of Cone of Emission Coordinates
174-
#recording = CairoMakie.record(
175-
# fig,
176-
# "coordinate.gif",
177-
# range(0.0, π, length = 180),
178-
# framerate = 12,
179-
#) do θs
180-
# draw!(axes_list, camera, coordinates, rmin, rmax, θs)
181-
#end
113+
recording = CairoMakie.record(
114+
fig,
115+
"coordinate.gif",
116+
range(0.0, π, length = 180),
117+
framerate = 12,
118+
) do θs
119+
draw!(axes_list, camera, coordinates, rmin, rmax, θs)
120+
end
182121

183122
# ![Emission coordinates of cones](coordinate.gif)
184123

examples/custom-material-example.jl

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ end
3939
# The emission to be ray traced is
4040
metric = Krang.Kerr(0.99);
4141
θo = 85 * π / 180;
42-
ro = 20.0
42+
ro = 20.0
4343
ρmax = 15/20;
4444
n = 0; # sub-image to ray trace
4545

@@ -71,7 +71,7 @@ CMk.set_theme!(CMk.merge!(theme, CMk.theme_latexfonts()))
7171
fig = CMk.Figure(resolution = (700, 700));
7272
ax = CMk.Axis(fig[1, 1], title = "Emission_radius", titlesize = 20, aspect = 1)
7373
hm = CMk.heatmap!(ax, redshifts, colormap = :afmhot)
74-
CMk.contour!(ax, redshifts, levels =20, colormap=:viridis)
74+
CMk.contour!(ax, redshifts, levels = 20, colormap = :viridis)
7575
CMk.Colorbar(fig[1, 2], hm, label = "Redshifts", labelsize = 20)
7676
display(fig)
7777
CMk.save("redshifts.png", fig)
@@ -83,24 +83,16 @@ function draw!(ax, ro)
8383
#empty!(ax)
8484
empty!(fig)
8585
ax = CMk.Axis(fig[1, 1], title = "Emission_radius", titlesize = 20, aspect = 1)
86-
hm = CMk.heatmap!(
87-
ax,
88-
redshifts,
89-
colormap = :afmhot,
90-
)
91-
CMk.contour!(ax, redshifts, levels =20, colormap=:viridis)
86+
hm = CMk.heatmap!(ax, redshifts, colormap = :afmhot)
87+
CMk.contour!(ax, redshifts, levels = 20, colormap = :viridis)
9288
CMk.Colorbar(fig[1, 2], hm, label = "emission_radius", labelsize = 20)
9389
end
9490

9591

96-
recording = CMk.record(
97-
fig,
98-
"coordinate.gif",
99-
range(1000, 20, length = 360),
100-
framerate = 12,
101-
) do ro
102-
draw!(ax, ro)
103-
end
92+
recording =
93+
CMk.record(fig, "coordinate.gif", range(1000, 20, length = 360), framerate = 12) do ro
94+
draw!(ax, ro)
95+
end
10496

10597
# ![redshifts](redshifts.png)
10698

examples/mino-time-example.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ recording =
8282
colorrange = colorrange[i],
8383
)
8484
cb = GLMk.Colorbar(
85-
fig[(i > 2 ? 2 : 1), (iszero(i % 2) ? 3 : 1)+1],
85+
fig[(i > 2 ? 2 : 1), (iszero(i%2) ? 3 : 1)+1],
8686
hm;
8787
labelsize = 30,
8888
ticklabelsize = 20,

examples/raytracing-mesh-example.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ sphere = GLMk.Sphere(GLMk.Point(0.0, 0.0, 0.0), horizon(metric)) # Sphere to rep
8484
lines_to_plot = Krang.generate_ray.(camera.screen.pixels, 100) # 100 is the number of steps to take along the ray
8585

8686
img = zeros(sze, sze)
87-
recording = GLMk.record(fig, "mesh.mp4", 1:sze*sze, framerate = 120) do i
87+
recording = GLMk.record(fig, "mesh.mp4", 1:(sze*sze), framerate = 120) do i
8888
line = lines_to_plot[i]
8989

9090
img[i] = intersections[i]

src/geometries/geometry_types.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,12 @@ end
6666
Intersection(zero(rs), rs, θs, zero(rs), νr, νθ), issuccess
6767
else
6868
rs, ϕs, νr, νθ, issuccess =
69-
@inline emission_coordinates_fast_light(pix, θs, isindir, n)
69+
@inline emission_coordinates_fast_light(pix, θs, isindir, n)
7070
Intersection(zero(rs), rs, θs, ϕs, νr, νθ), issuccess
7171
end
7272
else
73-
ts, rs, ϕs, νr, νθ, issuccess = @inline emission_coordinates(pix, θs, isindir, n)
73+
ts, rs, ϕs, νr, νθ, issuccess =
74+
@inline emission_coordinates(pix, θs, isindir, n)
7475
Intersection(ts, rs, θs, ϕs, νr, νθ), issuccess
7576
end
7677

src/materials/ElectronSynchrotronPowerLawPolarization.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Returns the screen polarization associated with a killing spinor κ as seen seen
1515
end
1616

1717
function evpa(fα, fβ)
18-
atan(-fα, fβ)
18+
atan(-fα, fβ)
1919
end
2020

2121
"""

src/metrics/Kerr/emission_coordinates.jl

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,7 @@ Returns 0 if the emission coordinates do not exist for that screen coordinate.
2929
- `isindir` : Is emission to observer direct or indirect
3030
- `n` : Image index
3131
"""
32-
@inline function emission_radius(
33-
pix::Krang.AbstractPixel,
34-
θs::T,
35-
isindir,
36-
n,
37-
) where {T}
32+
@inline function emission_radius(pix::Krang.AbstractPixel, θs::T, isindir, n) where {T}
3833
α, β = screen_coordinate(pix)
3934
θo = inclination(pix)
4035
met = @inline metric(pix)
@@ -124,7 +119,15 @@ Emission azimuth for point at Mino time τ whose image appears at screen coordin
124119
- `τ` : Mino Time
125120
- `νr` : Sign of radial velocity direction at emission. This is always positive for case 3 and case 4 geodesics.
126121
"""
127-
@inline function emission_azimuth(pix::AbstractPixel, θs, rs, τ::T, νr, isindir, n) where {T}
122+
@inline function emission_azimuth(
123+
pix::AbstractPixel,
124+
θs,
125+
rs,
126+
τ::T,
127+
νr,
128+
isindir,
129+
n,
130+
) where {T}
128131
met = metric(pix)
129132
θo = inclination(pix)
130133

@@ -150,7 +153,12 @@ coordinate (`α`, `β`) for an observer located at inclination θo.
150153
- `isindir` : Whether emission to observer is direct or indirect
151154
- `n` : Image index
152155
"""
153-
@inline function emission_coordinates_fast_light(pix::AbstractPixel, θs::T, isindir, n) where {T}
156+
@inline function emission_coordinates_fast_light(
157+
pix::AbstractPixel,
158+
θs::T,
159+
isindir,
160+
n,
161+
) where {T}
154162
# NB: I do not return θs since it is already known, and returning it might encourage bad coding errors
155163
α, β = screen_coordinate(pix)
156164
θo = inclination(pix)

src/metrics/Kerr/misc.jl

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,14 @@ See [`r_potential(x)`](@ref) for an implementation of \$\\mathcal{R}(r)\$.
966966
return It_w_I0_terms_case4(metric, rs, τ, roots, λ)
967967
end
968968

969-
@inline function It_w_I0_terms_case2(metric::Kerr{T}, rs, τ, roots::NTuple{4}, λ, νr) where {T}
969+
@inline function It_w_I0_terms_case2(
970+
metric::Kerr{T},
971+
rs,
972+
τ,
973+
roots::NTuple{4},
974+
λ,
975+
νr,
976+
) where {T}
970977
r1, r2, r3, r4 = roots
971978
_, r31, r32, r41, r42, _ = _get_root_diffs(roots...)
972979
r43 = r4 - r3
@@ -1306,7 +1313,13 @@ Returns the radial integrals for the case where there are no real roots in the r
13061313
return I1o_m_I0_terms, I2o_m_I0_terms, Ipo_m_I0_terms, Imo_m_I0_terms
13071314
end
13081315

1309-
@inline function radial_w_I0_terms_integrals(met::Kerr{T}, rs, roots::NTuple{4}, τ, νr) where {T}
1316+
@inline function radial_w_I0_terms_integrals(
1317+
met::Kerr{T},
1318+
rs,
1319+
roots::NTuple{4},
1320+
τ,
1321+
νr,
1322+
) where {T}
13101323
numreals = sum(_isreal2.(roots))
13111324
if numreals == 4
13121325
I1, I2, Ip, Im =
@@ -1702,7 +1715,12 @@ See [`θ_potential(x)`](@ref) for an implementation of \$\\Theta(\theta)\$.
17021715
- `isindir` : Is the path direct or indirect?
17031716
- `n` : nth image ordered by minotime
17041717
"""
1705-
@inline function (pix::AbstractPixel, θs::T, isindir, n)::Tuple{T,T,T,T,Bool,Bool} where {T}
1718+
@inline function (
1719+
pix::AbstractPixel,
1720+
θs::T,
1721+
isindir,
1722+
n,
1723+
)::Tuple{T,T,T,T,Bool,Bool} where {T}
17061724
_, β = screen_coordinate(pix)
17071725
met = metric(pix)
17081726
θo = inclination(pix)

test/kerr_misc_tests.jl

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,7 @@
346346

347347
θturning = acos(up) * (1 + 1e-10)
348348
@testset "" begin
349-
@testset "θs:$θs" for θs in
350-
clamp.(
349+
@testset "θs:$θs" for θs in clamp.(
351350
(1, 3) .* (acos(-√up) - acos(up)) ./ 4 .+ acos(up),
352351
0.0,
353352
π,
@@ -393,8 +392,7 @@
393392
end
394393
end
395394
@testset "" begin
396-
@testset "θs:$θs" for θs in
397-
clamp.(
395+
@testset "θs:$θs" for θs in clamp.(
398396
(1, 3) .* (acos(-√up) - acos(up)) ./ 4 .+ acos(up),
399397
0.0,
400398
π,
@@ -441,8 +439,7 @@
441439
end
442440
end
443441
@testset "Gt" begin
444-
@testset "θs:$θs" for θs in
445-
clamp.(
442+
@testset "θs:$θs" for θs in clamp.(
446443
(1, 3) .* (acos(-√up) - acos(up)) ./ 4 .+ acos(up),
447444
0.0,
448445
π,

0 commit comments

Comments
 (0)