Skip to content

Commit 9c00373

Browse files
authored
Merge pull request #76 from JuliaAstro/documenter
Add the documentation site and the logo
2 parents 3371c98 + 3213163 commit 9c00373

18 files changed

Lines changed: 528 additions & 3 deletions

File tree

‎.github/workflows/Docs.yml‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Docs
2+
on:
3+
push:
4+
branches:
5+
- main
6+
tags: ['*']
7+
pull_request:
8+
workflow_dispatch:
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
12+
jobs:
13+
docs:
14+
name: Documentation
15+
runs-on: ubuntu-latest
16+
timeout-minutes: 30
17+
permissions:
18+
contents: write
19+
pull-requests: read
20+
statuses: write
21+
steps:
22+
- uses: actions/checkout@v7
23+
- uses: julia-actions/setup-julia@v3
24+
with:
25+
version: '1'
26+
- uses: julia-actions/cache@v3
27+
- name: Install the dependencies
28+
run: julia --project=docs -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
29+
- name: Build and deploy
30+
run: julia --project=docs docs/make.jl
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

‎.gitignore‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@
44
/src/atom_.jl
55
/src/atomicDB.jl
66
/src/compton.jl
7-
/src/lte_rates.jl
7+
/src/lte_rates.jl
8+
/docs/build/
9+
/docs/Manifest*.toml

‎README.md‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1+
<p align="center">
2+
<picture>
3+
<source media="(prefers-color-scheme: dark)" srcset="docs/src/assets/logo-dark.svg">
4+
<img src="docs/src/assets/logo.svg" alt="Radix" width="160">
5+
</picture>
6+
</p>
7+
18
# Radix.jl
29

10+
[![Docs](https://img.shields.io/badge/docs-dev-blue.svg)](https://juliaastro.org/Radix.jl/dev/)
11+
[![CI](https://github.com/JuliaAstro/Radix.jl/actions/workflows/CI.yml/badge.svg)](https://github.com/JuliaAstro/Radix.jl/actions/workflows/CI.yml)
12+
313
A spectral simulator for photo-ionized plasmas at X-ray frequencies
414

515
This package is based on Tim Kallman's XSTAR program that is written in FORTRAN. We believe that a Julia version will be more modular, extendable, and performant.
@@ -13,5 +23,5 @@ run = slab(model; density=1e4, column=1e21, logξ=1.0, luminosity=1e46, equilibr
1323
[(z.T, z.xee, z.Δr) for z in run.zones] # the zones: temperature (10⁴ K), electron fraction and thickness (cm)
1424
```
1525

16-
See [docs/usage.md](docs/usage.md) for the options, the results and how Radix compares with XSTAR.
26+
See the [documentation](https://juliaastro.org/Radix.jl/dev/) (the sources are in [docs/src/usage.md](docs/src/usage.md)) for the options, the results and how Radix compares with XSTAR.
1727

‎docs/Project.toml‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[deps]
2+
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
3+
Radix = "91324510-8a80-4dcc-8f77-32500317c0e2"
4+
5+
[sources]
6+
Radix = {path = "/Users/paul/.julia/dev/Radix"}
7+
8+
[compat]
9+
Documenter = "1"

‎docs/logo/fek.csv‎

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
energy,model,observed
2+
5605.0,12.42,17
3+
5613.7,12.56,7
4+
5622.5,14.11,13
5+
5631.2,18.68,18
6+
5639.9,13.03,9
7+
5648.7,16.26,14
8+
5657.5,18.67,20
9+
5666.2,15.84,11
10+
5675.0,12.57,11
11+
5683.8,40.75,57
12+
5692.7,12.69,11
13+
5701.5,12.33,5
14+
5710.4,12.31,9
15+
5719.2,12.29,8
16+
5728.1,12.29,16
17+
5737.0,12.28,12
18+
5745.9,12.27,17
19+
5754.8,12.27,9
20+
5763.8,12.26,12
21+
5772.7,12.26,11
22+
5781.7,12.25,16
23+
5790.6,12.25,8
24+
5799.6,12.24,22
25+
5808.6,12.24,15
26+
5817.7,12.23,10
27+
5826.7,12.23,14
28+
5835.7,12.23,6
29+
5844.8,12.22,10
30+
5853.9,12.22,10
31+
5863.0,12.22,12
32+
5872.1,12.39,9
33+
5881.2,12.32,11
34+
5890.3,13.31,14
35+
5899.5,13.06,8
36+
5908.6,14.0,12
37+
5917.8,24.84,31
38+
5927.0,14.81,8
39+
5936.2,27.55,21
40+
5945.4,12.24,7
41+
5954.6,12.2,11
42+
5963.9,12.22,9
43+
5973.1,12.24,13
44+
5982.4,12.25,8
45+
5991.7,12.26,6
46+
6001.0,12.28,12
47+
6010.3,12.63,10
48+
6019.6,12.27,19
49+
6029.0,12.5,7
50+
6038.3,12.25,14
51+
6047.7,12.18,10
52+
6057.1,12.19,7
53+
6066.5,12.18,15
54+
6075.9,12.37,9
55+
6085.4,12.17,14
56+
6094.8,12.15,17
57+
6104.3,12.2,18
58+
6113.8,12.81,15
59+
6123.2,14.94,12
60+
6132.8,12.24,9
61+
6142.3,13.13,9
62+
6151.8,15.43,11
63+
6161.4,13.2,15
64+
6170.9,12.57,13
65+
6180.5,21.41,27
66+
6190.1,13.16,16
67+
6199.7,12.16,10
68+
6209.3,12.28,12
69+
6219.0,12.48,17
70+
6228.6,12.15,17
71+
6238.3,12.16,14
72+
6248.0,12.2,12
73+
6257.7,12.2,6
74+
6267.4,12.21,20
75+
6277.1,12.22,8
76+
6286.9,12.24,16
77+
6296.6,12.26,16
78+
6306.4,12.29,6
79+
6316.2,12.34,15
80+
6326.0,12.42,14
81+
6335.8,12.55,14
82+
6345.7,12.76,11
83+
6355.5,13.04,7
84+
6365.4,14.05,14
85+
6375.3,18.08,11
86+
6385.2,166.13,190
87+
6395.1,223.75,218
88+
6405.0,412.0,439
89+
6415.0,25.44,23
90+
6424.9,17.77,18
91+
6434.9,13.53,7
92+
6444.9,18.01,21
93+
6454.9,12.93,17
94+
6464.9,13.2,14
95+
6475.0,13.68,12
96+
6485.0,15.23,6
97+
6495.1,13.77,12
98+
6505.2,13.96,13
99+
6515.3,13.0,11
100+
6525.4,13.46,17
101+
6535.5,14.85,18
102+
6545.7,24.84,22
103+
6555.8,14.39,11
104+
6566.0,12.98,18
105+
6576.2,19.44,17
106+
6586.4,44.16,43
107+
6596.6,18.76,22
108+
6606.9,12.71,12
109+
6617.1,13.0,13
110+
6627.4,92.91,86
111+
6637.7,45.23,48
112+
6648.0,12.43,9
113+
6658.3,12.23,7
114+
6668.7,12.62,11
115+
6679.0,50.17,46
116+
6689.4,13.87,10
117+
6699.8,12.12,9
118+
6710.2,12.1,9
119+
6720.6,12.09,9
120+
6731.0,12.08,13
121+
6741.5,12.08,15
122+
6751.9,12.08,6
123+
6762.4,12.07,8
124+
6772.9,12.07,20
125+
6783.4,12.07,12
126+
6794.0,12.13,14
127+
6804.5,12.08,11
128+
6815.1,12.06,12
129+
6825.7,12.06,14
130+
6836.3,12.06,7
131+
6846.9,12.07,8
132+
6857.5,12.07,7
133+
6868.1,12.07,13
134+
6878.8,12.07,14
135+
6889.5,12.08,11
136+
6900.2,12.09,12
137+
6910.9,12.4,6
138+
6921.6,12.77,17
139+
6932.4,13.51,13
140+
6943.1,13.32,13
141+
6953.9,126.78,136
142+
6964.7,14.84,18
143+
6975.5,224.88,238
144+
6986.4,14.08,10
145+
6997.2,12.27,10
146+
7008.1,12.19,9
147+
7018.9,15.58,16
148+
7029.8,15.11,15
149+
7040.8,12.71,9
150+
7051.7,14.21,13
151+
7062.6,17.86,6
152+
7073.6,31.0,23
153+
7084.6,97.37,108
154+
7095.6,31.01,37
155+
7106.6,18.91,13
156+
7117.6,13.4,10
157+
7128.7,12.54,11
158+
7139.8,12.18,11
159+
7150.8,12.12,11
160+
7161.9,12.12,7
161+
7173.1,13.84,15
162+
7184.2,12.24,11
163+
7195.3,13.12,11

‎docs/logo/logo.jl‎

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# The logo of Radix: the Chandra observatory points at an accreting black hole and records the Fe K lines of the gas (the spectrum that `spectrum.jl`
2+
# computes with Radix, with noise).
3+
#
4+
# julia docs/logo/logo.jl
5+
#
6+
# writes `logo.svg` and `logo-dark.svg` to docs/src/assets.
7+
using Printf
8+
9+
const assets = joinpath(@__DIR__, "..", "src", "assets")
10+
const plot_x = (22.0, 222.0)
11+
const baseline = 166.0 # the y of zero counts
12+
const tallest = 140.0 # the height of the strongest line (three quarters of the logo or more)
13+
14+
function read_spectrum(path)
15+
rows = [parse.(Float64, split(line, ',')) for line in readlines(path)[2:end]]
16+
first.(rows), getindex.(rows, 2), getindex.(rows, 3)
17+
end
18+
19+
xof(e) = plot_x[1] + (e - energy_range[1])/(energy_range[2] - energy_range[1])*(plot_x[2] - plot_x[1])
20+
yof(c) = baseline - c*tallest/peak
21+
f(x) = @sprintf("%.1f", x)
22+
23+
function logo(; ink, spectrum_ink, model, ring, glow, hot, body, panel, panel_line, dark_core, jet, energy, smooth, observed)
24+
w = (plot_x[2] - plot_x[1])/(length(energy) - 1)
25+
# the observation: a histogram with a step in each bin
26+
steps = "M" * f(xof(energy[1]) - w/2) * "," * f(yof(observed[1]))
27+
for i in eachindex(energy)
28+
steps *= " H" * f(xof(energy[i]) + w/2)
29+
i < length(energy) && (steps *= " V" * f(yof(observed[i + 1])))
30+
end
31+
ticks = join((@sprintf("<path d=\"M%s,168 L%s,173\" stroke=\"%s\" stroke-opacity=\"0.6\" stroke-width=\"2\" stroke-linecap=\"round\"/>", f(xof(e)), f(xof(e)), ink) for e in (6404.0, 6700.0, 6970.0) if energy_range[1] < e < energy_range[2]))
32+
axis = @sprintf("<path d=\"M%s,168 L%s,168\" stroke=\"%s\" stroke-opacity=\"0.6\" stroke-width=\"2\" stroke-linecap=\"round\"/>", f(plot_x[1] - 4), f(plot_x[2] + 4), ink)
33+
34+
# the black hole (upper right): the disk behind it, the shadow, the ring of the light that it bends and the disk in front
35+
bx, by = 189.0, 46.0
36+
hole = """
37+
<g transform="translate($bx $by) scale(1.4) translate($(-bx) $(-by)) rotate(-9 $bx $by)">
38+
<ellipse cx="$bx" cy="$by" rx="30" ry="7.5" fill="none" stroke="url(#disk)" stroke-width="6"/>
39+
<path d="M$(bx-16),$(by-1) A16,16 0 0 1 $(bx+16),$(by-1)" fill="none" stroke="$ring" stroke-width="3" stroke-linecap="round" stroke-opacity="0.85"/>
40+
<circle cx="$bx" cy="$by" r="11" fill="$dark_core" stroke="$ring" stroke-width="1.6"/>
41+
<path d="M$(bx-30),$by A30,7.5 0 0 0 $(bx+30),$by" fill="none" stroke="url(#disk)" stroke-width="6"/>
42+
</g>"""
43+
44+
# Chandra (upper left): the barrel with the mirrors at the front, the science instruments at the back and two solar arrays
45+
tx, ty, angle = 57.0, 68.0, -9.0
46+
chandra = """
47+
<g transform="translate($tx $ty) scale(1.4) rotate($angle)">
48+
<path d="M-31,-8 L-17,-8 L-12,-32 L-26,-32 Z" fill="$panel"/>
49+
<path d="M-31,8 L-17,8 L-12,32 L-26,32 Z" fill="$panel"/>
50+
<path d="M-28.5,-8 L-23.5,-32 M-25.5,-8 L-20.5,-32 M-22,-8 L-17,-32 M-18.7,-14.6 L-27,-14.6 M-17.3,-21.2 L-27.7,-21.2 M-15.8,-27.8 L-26.7,-27.8" stroke="$panel_line" stroke-width="0.9" fill="none"/>
51+
<path d="M-28.5,8 L-23.5,32 M-25.5,8 L-20.5,32 M-22,8 L-17,32 M-18.7,14.6 L-27,14.6 M-17.3,21.2 L-27.7,21.2 M-15.8,27.8 L-26.7,27.8" stroke="$panel_line" stroke-width="0.9" fill="none"/>
52+
<rect x="-36" y="-6.5" width="42" height="13" rx="2.5" fill="url(#body)"/>
53+
<rect x="4" y="-8.5" width="32" height="17" rx="3" fill="url(#body)"/>
54+
<rect x="-12" y="-6.5" width="1.6" height="13" fill="$panel_line" fill-opacity="0.5"/>
55+
<ellipse cx="36" cy="0" rx="2.8" ry="8.5" fill="$dark_core" stroke="$hot" stroke-width="1"/>
56+
<rect x="14" y="-8.5" width="1.6" height="17" fill="$panel_line" fill-opacity="0.5"/>
57+
</g>"""
58+
defs = """<defs>
59+
<linearGradient id="body" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="$(body[1])"/><stop offset="1" stop-color="$(body[2])"/></linearGradient>
60+
<linearGradient id="disk" x1="0" x2="1"><stop offset="0" stop-color="$hot" stop-opacity="0.15"/><stop offset="0.5" stop-color="$glow"/><stop offset="1" stop-color="$hot" stop-opacity="0.15"/></linearGradient>
61+
<linearGradient id="jet" x1="0" y1="1" x2="0" y2="0"><stop offset="0" stop-color="$glow" stop-opacity="0.7"/><stop offset="1" stop-color="$hot" stop-opacity="0"/></linearGradient>
62+
</defs>"""
63+
"""<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 240 182"><title>Radix</title>$defs$hole$chandra<path d="$steps" fill="none" stroke="$spectrum_ink" stroke-width="0.9" stroke-linejoin="miter"/>$axis$ticks</svg>
64+
"""
65+
end
66+
67+
energy, smooth, observed = read_spectrum(joinpath(@__DIR__, "fek.csv"))
68+
const energy_range = (energy[1], energy[end]) # eV
69+
const peak = maximum(smooth) # the counts of the strongest line of the model
70+
common = (; energy, smooth, observed)
71+
write(joinpath(assets, "logo.svg"), logo(; common..., ink="#24508f", spectrum_ink="#000000", model="#e8833a", ring="#f0a04b", glow="#ffd27a", hot="#e8833a",
72+
body=("#dfe6f2", "#8e9db8"), panel="#2c4f86", panel_line="#9db8e0", dark_core="#0d1220", jet="#e8833a"))
73+
write(joinpath(assets, "logo-dark.svg"), logo(; common..., ink="#a9c8f5", spectrum_ink="#ffffff", model="#ff9a4d", ring="#ffb35e", glow="#ffe2a8", hot="#ff9a4d",
74+
body=("#f0f4fb", "#aab8d0"), panel="#4f7bc0", panel_line="#cfe0fb", dark_core="#05070d", jet="#ff9a4d"))

‎docs/logo/spectrum.jl‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# The synthetic spectrum of the logo: the emission lines of the Fe K complex of two slabs of gas that Radix computes (a few minutes to half an hour with
2+
# 8 threads), with noise.
3+
#
4+
# julia -t 8 --project=. docs/logo/spectrum.jl atdb.fits coheat.dat
5+
#
6+
# writes `fek.csv`: the energy (eV), the model and one observation of it (the counts in each bin, with Poisson noise). The gas is two slabs of 10²² cm⁻² and a
7+
# density of 10¹⁰ cm⁻³ that a power law E⁻⁰·⁹ illuminates, at log ξ = 1 (the fluorescence of the cold iron: Kα at 6.40 keV and Kβ at 7.06 keV) and at
8+
# log ξ = 3 (the recombination lines of Fe XXV near 6.7 keV and Fe XXVI at 6.97 keV), seen without the direct continuum, as an obscured nucleus is, over a
9+
# weak scattered continuum.
10+
using Radix, Random
11+
12+
const peak_counts = 400.0 # the counts in the bin of the strongest line (Kα)
13+
const continuum_fraction = 0.03 # the scattered continuum, in units of that peak
14+
const hot_weight = 0.6 # the emission of the log ξ = 3 slab, relative to the log ξ = 1 slab
15+
const window = (5605.0, 7205.0) # eV: centred on the Fe Kα line at 6.405 keV
16+
17+
# the emission (the lines and the continuum of the zones) that leaves the slab, in units of its incident continuum
18+
emission(spectrum, bins) = (spectrum.diffuse_outward[bins] .+ spectrum.lines_outward[bins]) ./ spectrum.incident[bins]
19+
20+
# the Poisson deviate: the product of uniform deviates for a mean below 30 and the Gaussian limit above
21+
function poisson(rng, λ)
22+
λ < 30 || return max(0, round(Int, λ + sqrt(λ)*randn(rng)))
23+
limit, k, p = exp(-λ), 0, 1.0
24+
while true
25+
p *= rand(rng)
26+
p <= limit && return k
27+
k += 1
28+
end
29+
end
30+
31+
# the energy, the model and the observation (counts) in the window from the `spectrum` of `tables` of the two slabs
32+
function observation(cold, hot; seed=6400)
33+
bins = findall(e -> window[1] <= e <= window[2], cold.energy)
34+
energy = cold.energy[bins]
35+
lines = emission(cold, bins) .+ hot_weight .* emission(hot, bins)
36+
model = peak_counts .* (lines ./ maximum(lines) .+ continuum_fraction)
37+
rng = Xoshiro(seed)
38+
energy, model, [poisson(rng, m) for m in model]
39+
end
40+
41+
function write_csv(path, (energy, model, observed))
42+
open(path, "w") do io
43+
println(io, "energy,model,observed")
44+
for i in eachindex(energy)
45+
println(io, round(energy[i]; digits=1), ",", round(model[i]; digits=2), ",", observed[i])
46+
end
47+
end
48+
end
49+
50+
if abspath(PROGRAM_FILE) == @__FILE__
51+
atdb, coheat = ARGS
52+
gas = Model(atdb, coheat)
53+
spectra = map(((ξ, T),) -> tables(gas, slab(gas; density=1e10, column=1e22, logξ=ξ, luminosity=1e38, α=-0.9, equilibrium=true, T, emult=1.0, steps=3,
54+
vturb=100.0, ncn2=9999)).spectrum, ((1.0, 100.0), (3.0, 1000.0)))
55+
write_csv(joinpath(@__DIR__, "fek.csv"), observation(spectra...))
56+
end

0 commit comments

Comments
 (0)