Skip to content

Commit f30054a

Browse files
authored
Merge pull request #213 from astro-group-bristol/fergus/lineprofile-docs
Line profile documentation
2 parents fd2478c + f12e0f6 commit f30054a

15 files changed

+626
-16
lines changed

docs/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
[deps]
22
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
3+

docs/make.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ makedocs(
2020
"Problems and solvers" => "problems-and-solvers.md",
2121
"Point functions" => "point-functions.md",
2222
"Disc emissivity" => "emissivity.md",
23+
"Line profiles" => "lineprofiles.md",
2324
],
2425
"Geodesics and integration" => [
2526
"Implementing new metrics" => "custom-metrics.md",

docs/src/example-figures/lp.lamp-post-emissivity.svg

Lines changed: 55 additions & 0 deletions
Loading

docs/src/example-figures/lp.pre-computed-tfs.svg

Lines changed: 53 additions & 0 deletions
Loading

docs/src/example-figures/lp.shallower-emissivity.svg

Lines changed: 53 additions & 0 deletions
Loading

docs/src/example-figures/lp.simple-lineprofile.svg

Lines changed: 49 additions & 0 deletions
Loading

docs/src/example-figures/lp.with-binning.svg

Lines changed: 57 additions & 0 deletions
Loading

docs/src/geodesic-integration.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,23 @@ where the dot refers to the derivative with respect to ``\lambda``. In general,
2828
Gradus.constrain_time
2929
```
3030

31-
## Using callbacks
31+
## Methods
32+
33+
```@docs
34+
TransferFunctionMethod
35+
BinningMethod
36+
```
37+
38+
## Image planes
39+
40+
```@docs
41+
AbstractImagePlane
42+
PolarPlane
43+
CartesianPlane
44+
```
45+
46+
```@docs
47+
Gradus.image_plane
48+
Gradus.trajectory_count
49+
Gradus.unnormalized_areas
50+
```

docs/src/lineprofiles.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Line profiles
2+
3+
Line profiles are kernels that represent the blurring of spectral lines from e.g. an accretion disc around a black hole. They show how the flux is smeared over a range of energies relative to the rest energy due to relativistic effects and Doppler shifts.
4+
5+
Gradus.jl has various methods for calculating line profiles (see
6+
[`Methods`](@ref)). Here we will explore how to compute line profiles with
7+
Gradus using the [`BinningMethod`](@ref) and the
8+
[`TransferFunctionMethod`](@ref).
9+
10+
As with any Gradus.jl simulation, we start by picking the basic components of our model:
11+
```julia
12+
using Gradus
13+
14+
m = KerrMetric(M = 1.0, a = 0.998)
15+
# an infinite thin disc in the equatorial plane
16+
d = ThinDisc(0.0, Inf)
17+
x = SVector(0.0, 10_000.0, deg2rad(60), 0.0)
18+
```
19+
20+
We can compute a line profile directly using the [`lineprofile`](@ref) method:
21+
22+
```@docs
23+
lineprofile
24+
```
25+
26+
We can invoke this directly
27+
```julia
28+
bins, flux = lineprofile(m, x, d)
29+
```
30+
31+
If a custom (enregy) bins is desired, it can be passed using the keyword arguments. We can plot these vectors directly:
32+
```julia
33+
using Plots
34+
plot(bins, flux; xlabel = "g", ylabel = "flux")
35+
```
36+
37+
![](./example-figures/lp.simple-lineprofile.svg)
38+
39+
To pass a custom emissivity function, we can use a different dispatch that takes the `bins` and the emissivity function as the first argument. Here is a shallower power-law, reusing the same bins:
40+
```julia
41+
emissivity(r) = r^-2
42+
bins, flux = lineprofile(bins, emissivity, m, x, d)
43+
plot!(bins, flux)
44+
```
45+
46+
![](./example-figures/lp.shallower-emissivity.svg)
47+
48+
To use the emissivity calcualted via an [`AbstractDiscProfile`](@ref) from a coronal model, we can do something like
49+
```julia
50+
model = LampPostModel(h = 10.0)
51+
profile = emissivity_profile(m, d, model)
52+
bins, flux = lineprofile(m, x, d, profile; bins = bins)
53+
plot!(bins, flux)
54+
```
55+
56+
![](./example-figures/lp.with-binning.svg)
57+
58+
We can at any point switch to the [`BinningMethod`](@ref) dispatches, which have largely the same functions calls. These methods take significantly longer to execute, and often give slightly lower resolution, however are much more flexible in the underlying assumptions of the model:
59+
```julia
60+
bins, flux = lineprofile(m, x, d, profile; bins = bins, method = BinningMethod())
61+
plot!(bins, flux)
62+
```
63+
64+
![](./example-figures/lp.lamp-post-emissivity.svg)
65+
66+
The defaults have been chosen to balance accuracy and speed. The above [`TransferFunctionMethod`](@ref) calculations only take a handful of seconds to compute from scratch. If all we are changing are properties of the disc, we do not necessarily need to recompute the transfer functions, and can make use of caches instead. Here is an example recipe using the [`transferfunctions`](@ref) utility:
67+
68+
```julia
69+
tfs = transferfunctions(m, x, d)
70+
71+
f1 = integrate_lineprofile(r -> r^-3, tfs, bins)
72+
f2 = integrate_lineprofile(profile, tfs, bins)
73+
74+
plot(bins, f1)
75+
plot!(bins, f2)
76+
```
77+
78+
![](./example-figures/lp.pre-computed-tfs.svg)
79+
80+
Similar pre-computation can be done with the binning method, however there are currently no utility functions available in the same way as with the transfer functions.
81+
82+
```@docs
83+
integrate_lineprofile
84+
```
85+
86+
87+

src/Gradus.jl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,37 @@ struct EnsembleEndpointThreads end
401401

402402

403403
abstract type AbstractComputationalMethod end
404+
405+
"""
406+
TransferFunctionMethod()
407+
408+
Computing the underlying relativistic effects using Cunningham transfer
409+
functions. This method has a number of limitations related to the assumptions:
410+
- The disc must be axis-symmetric.
411+
- The accretion disc must have a velocity structure that depends only on radius.
412+
- The domain of integration must be in or above the equatorial plane (no false
413+
images).
414+
415+
The transfer function approach is often faster and converges to higher numerical
416+
accuracy than the other methods. They can also be pre-computed for use in
417+
spectral models for fitting.
418+
"""
404419
struct TransferFunctionMethod <: AbstractComputationalMethod end
420+
421+
"""
422+
BinningMethod()
423+
424+
Compute the underlying relativistic effects by 'binning' the observer's plane
425+
into a number of regions, and tracing a single geodesic for each photon.
426+
Conceptually, this is like tracing a single photon for each pixel, however the
427+
regions need not be equi-rectangular, and may take on other shapes, see
428+
[`AbstractImagePlane`](@ref).
429+
430+
This method is slow and computationally expensive, but has the benefit that it
431+
makes no assumptions about the model being computed.
432+
433+
It is internally used for testing conceptually more complex integration methods.
434+
"""
405435
struct BinningMethod <: AbstractComputationalMethod end
406436

407437
include("orthonormalization.jl")

0 commit comments

Comments
 (0)