Skip to content

Commit ec4bd10

Browse files
authored
Update and fix docs (#47)
1 parent a8dcb12 commit ec4bd10

31 files changed

+760
-274
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,7 @@ scripts/
1919
test/benchmarks
2020
!.github/**
2121
docs/src/*.ipynb
22+
docs/build
23+
docs/src-staging/0*
24+
profiling
2225
posts

Dockerfile

+3-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ RUN apt-get update \
2828

2929
## install julia
3030
RUN mkdir /opt/julia \
31-
&& curl -L https://julialang-s3.julialang.org/bin/linux/x64/1.5/julia-1.5.1-linux-x86_64.tar.gz | tar zxf - -C /opt/julia --strip=1 \
31+
&& curl -L https://julialang-s3.julialang.org/bin/linux/x64/1.5/julia-1.5.3-linux-x86_64.tar.gz | tar zxf - -C /opt/julia --strip=1 \
3232
&& chown -R 1000 /opt/julia \
3333
&& ln -s /opt/julia/bin/julia /usr/local/bin
3434

@@ -53,14 +53,13 @@ RUN curl https://pyenv.run | bash \
5353
RUN pip install --no-cache-dir \
5454
cython \
5555
julia \
56-
jupyterlab \
56+
jupyterlab==3 \
5757
jupytext \
5858
matplotlib \
5959
"nbconvert<6" \
6060
numpy \
6161
scipy \
6262
setuptools \
63-
&& jupyter labextension install @jupyterlab/toc \
6463
&& rm -rf $HOME/.cache
6564

6665
## install CAMB
@@ -89,7 +88,7 @@ COPY --chown=1000 Project.toml $HOME/CMBLensing/
8988
COPY --chown=1000 docs/Project.toml $HOME/CMBLensing/docs/
9089
RUN mkdir $HOME/CMBLensing/src && touch $HOME/CMBLensing/src/CMBLensing.jl
9190
ENV JULIA_PROJECT=$HOME/CMBLensing/docs
92-
RUN julia -e 'using Pkg; pkg"dev ~/CMBLensing; instantiate; precompile"' \
91+
RUN julia -e 'using Pkg; pkg"dev ~/CMBLensing; instantiate"' \
9392
&& rm -rf $HOME/.julia/conda/3/pkgs
9493
COPY --chown=1000 src $HOME/CMBLensing/src
9594
RUN (test $PRECOMPILE = 0 || julia -e 'using Pkg; pkg"precompile"')

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ You can also clone the repostiory and open the notebooks in [docs/src](https://g
4141
* _(recommended)_ FFTW.jl built with [`JULIA_FFTW_PROVIDER=MKL`](https://juliamath.github.io/FFTW.jl/stable/#Installation-1) for faster CPU FFTs
4242
* _(recommended)_ Python 3 + matplotlib (used for plotting)
4343
* _(recommended)_ [pycamb](https://github.com/cmbant/CAMB) to generate $C_\ell$'s
44+
* _(recommended)_ [JuliaMono](https://github.com/cormullion/juliamono/releases) font to ensure characters like `f̃, ϕ, ∇, ℓ`, etc... are rendered correctly
4445
* _(optional)_ [healpy](https://github.com/healpy/healpy) for experimental curved sky support
4546

4647
### Native installation

docker-compose.yml

+5
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,8 @@ services:
1010
hostname: localhost
1111
environment:
1212
- PORT=${PORT:-8888}
13+
# uncomment to mount local files into container for easier development:
14+
# volumes:
15+
# - "./src:/home/cosmo/CMBLensing/src"
16+
# - "./docs/src:/home/cosmo/CMBLensing/docs/src"
17+
# - "/home/cosmo/.julia"

docs/make.jl

+6-4
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ for file in readdir("src")
3030
if endswith(file, "ipynb")
3131
file |> convert_to_markdown |> convert_equations
3232
elseif !startswith(file, ".")
33-
cp("src/$file", "src-staging/$file")
33+
cp("src/$file", "src-staging/$file", force=true)
3434
end
3535
end
36+
rm("src-staging/index.md",force=true)
3637
symlink("../../README.md","src-staging/index.md")
3738

3839

@@ -152,11 +153,12 @@ makedocs(
152153
],
153154
)
154155

155-
open("build/Dockerfile","w") do io
156-
write(io,"FROM $(ENV["IMAGE_NAME"])")
156+
if haskey(ENV, "IMAGE_NAME")
157+
open("build/Dockerfile","w") do io
158+
write(io,"FROM $(ENV["IMAGE_NAME"])")
159+
end
157160
end
158161

159-
160162
deploydocs(
161163
repo = "github.com/marius311/CMBLensing.jl.git",
162164
push_preview = true,

docs/src-staging/api.md

+82
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,88 @@
11
# API
22

3+
```@contents
4+
Pages = ["api.md"]
5+
```
6+
7+
## Simulation
8+
```@docs
9+
load_sim
10+
resimulate
11+
resimulate!
12+
```
13+
14+
## Lensing estimation
15+
16+
```@docs
17+
MAP_joint
18+
MAP_marg
19+
sample_joint
20+
argmaxf_lnP
21+
quadratic_estimate
22+
```
23+
24+
## Field constructors
25+
26+
```@docs
27+
FlatMap
28+
FlatFourier
29+
FlatQUMap
30+
FlatQUFourier
31+
FlatEBMap
32+
FlatEBFourier
33+
FlatIQUMap
34+
FlatIQUFourier
35+
FlatIEBMap
36+
FlatIEBFourier
37+
```
38+
39+
## Lensing operators
40+
41+
```@docs
42+
LenseFlow
43+
BilinearLens
44+
Taylens
45+
PowerLens
46+
CMBLensing.antilensing
47+
```
48+
49+
## Configuration options
50+
51+
```@docs
52+
CMBLensing.FFTW_NUM_THREADS
53+
CMBLensing.FFTW_TIMELIMIT
54+
```
55+
56+
## Other
57+
358
```@autodocs
459
Modules = [CMBLensing]
560
Order = [:function, :type, :macro, :constant]
61+
Filter = x -> !(x in [
62+
load_sim,
63+
resimulate,
64+
resimulate!,
65+
MAP_joint,
66+
MAP_marg,
67+
sample_joint,
68+
argmaxf_lnP,
69+
quadratic_estimate,
70+
FlatMap,
71+
FlatFourier,
72+
FlatQUMap,
73+
FlatQUFourier,
74+
FlatEBMap,
75+
FlatEBFourier,
76+
FlatIQUMap,
77+
FlatIQUFourier,
78+
FlatIEBMap,
79+
FlatIEBFourier,
80+
LenseFlow,
81+
BilinearLens,
82+
Taylens,
83+
PowerLens,
84+
CMBLensing.antilensing,
85+
CMBLensing.FFTW_NUM_THREADS,
86+
CMBLensing.FFTW_TIMELIMIT,
87+
])
688
```
-333 KB
Binary file not shown.
2.34 MB
Binary file not shown.

docs/src-staging/assets/cmblensing.css

+4-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ pre.language-output {
33
}
44

55
@font-face {
6-
font-family: 'DejaVuSansMono';
7-
src: url("DejaVuSansMono.ttf");
6+
font-family: 'JuliaMono-Regular';
7+
src: url("JuliaMono-Regular.ttf");
88
}
99

10-
pre, code, kbd {
11-
font-family: 'DejaVuSansMono', Monaco, courier, monospace;
12-
font-size: 0.90em;
10+
code, pre {
11+
font-family: 'JuliaMono-Regular', Monaco, courier, monospace !important;
1312
}

docs/src/01_lense_a_map.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jupyter:
88
format_version: '1.2'
99
jupytext_version: 1.4.1
1010
kernelspec:
11-
display_name: Julia 1.5.1
11+
display_name: Julia 1.5.3
1212
language: julia
1313
name: julia-1.5
1414
---
@@ -113,8 +113,10 @@ using BenchmarkTools
113113
@benchmark cache(LenseFlow(ϕ),f)
114114
```
115115

116-
Once cached, it's very fast and memory non-intensive to repeatedly apply the operator:
116+
Once cached, it's faster and less memory intensive to repeatedly apply the operator:
117117

118118
```julia
119119
@benchmark* f setup=(Lϕ=cache(LenseFlow(ϕ),f))
120120
```
121+
122+
Note that this documentation is generated on limited-performance cloud servers. Actual benchmarks are likely much faster locally or on a cluster, and yet (much) faster on [GPU](../06_gpu/).

docs/src/02_posterior.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jupyter:
88
format_version: '1.2'
99
jupytext_version: 1.4.1
1010
kernelspec:
11-
display_name: Julia 1.5.1
11+
display_name: Julia 1.5.3
1212
language: julia
1313
name: julia-1.5
1414
---
@@ -40,14 +40,13 @@ $$ d = \mathbb{A} \, \mathbb{L}(\phi) \, f + n, $$
4040

4141
where
4242

43-
$$ \mathbb{A} = \mathbb{P} \, \mathbb{M} \, \mathbb{B} $$
43+
$$ \mathbb{A} = \mathbb{M} \, \mathbb{B} $$
4444

4545
and
4646

4747
* $\mathbb{L}(\phi)$ is the lensing operation
4848
* $\mathbb{B}$ is an instrumental transfer function or "beam"
4949
* $\mathbb{M}$ is a user-chosen mask
50-
* $\mathbb{P}$ is a pixelization operation which allows one to estimate $f$ on a higher resolution than the data
5150
* $n$ is the instrumental noise.
5251

5352

@@ -93,7 +92,7 @@ To evaluate this posterior, we need the arguments of the probability distributio
9392
First lets load up some simulated data. The function `load_sim` handles constructing a `DataSet` and is the recommended way to create the various fields and covariances needed. In this case, let's use 1$\mu$K-arcmin noise and a border mask:
9493

9594
```julia
96-
@unpack f, f̃, ϕ, ds, L = load_sim(
95+
@unpack f, f̃, ϕ, ds = load_sim(
9796
θpix = 2,
9897
Nside = 256,
9998
T = Float64,
@@ -142,7 +141,7 @@ For the unlensed and lensed parametrizations, pass `0` and `1` as the first argu
142141
For example, the following is the same point in parameter space that we evaluated above, just in a different parametrization (any differences to the above value are numerical):
143142

144143
```julia
145-
-2*lnP(1, L(ϕ)*f, ϕ, ds)
144+
-2*lnP(1, ds.L(ϕ)*f, ϕ, ds)
146145
```
147146

148147
We expect minus twice the posterior evaluated at the truth to be distributed like a $\chi^2$ distribution where the degrees of freedom equals the number of pixels in $d$, $f$, and $\phi$ (i.e. in each of the three Gaussian terms in the posterior). Since these maps are 256x256 and $d$ and $f$ have both Q and U maps, this is:

docs/src/03_joint_MAP_example.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jupyter:
77
format_version: '1.2'
88
jupytext_version: 1.4.1
99
kernelspec:
10-
display_name: Julia 1.5.1
10+
display_name: Julia 1.5.3
1111
language: julia
1212
name: julia-1.5
1313
---
@@ -111,7 +111,7 @@ plot(ds.d, title = "data " .* ["E" "B"]);
111111
Now we compute the maximum of the joint posterior, $\mathcal{P}\big(f, \phi \,\big|\,d\big)$
112112

113113
```julia
114-
fbf, ϕbf, history = MAP_joint(ds, nsteps=30, progress=true);
114+
fJ, ϕJ, history = MAP_joint(ds, nsteps=30, progress=true);
115115
```
116116

117117
# Examine results
@@ -136,16 +136,16 @@ Here's how far away our final $\chi^2$ is from this expectation, in units of $\s
136136
Here's the best-fit $\phi$ relative to the truth,
137137

138138
```julia
139-
plot(10^6*ϕbf], title=["true" "best-fit"] .* raw" $\phi$", vlim=17);
139+
plot(10^6*ϕJ], title=["true" "best-fit"] .* raw" $\phi$", vlim=17);
140140
```
141141

142142
Here is the difference in terms of the power spectra. Note the best-fit has high-$\ell$ power suppressed, like a Wiener filter solution (in fact what we're doing here is akin to a non-linear Wiener filter). In the high S/N region ($\ell\lesssim1000$), the difference is approixmately equal to the noise, which you can see is almost two orders of magnitude below the signal.
143143

144144
```julia
145145
loglog(ℓ⁴ * Cℓ.total.ϕϕ, "k")
146146
loglog(get_ℓ⁴Cℓ(ϕ))
147-
loglog(get_ℓ⁴Cℓ(ϕbf))
148-
loglog(get_ℓ⁴Cℓ(ϕbf-ϕ))
147+
loglog(get_ℓ⁴Cℓ(ϕJ))
148+
loglog(get_ℓ⁴Cℓ(ϕJ-ϕ))
149149
xlim(80,3000)
150150
ylim(5e-9,2e-6)
151151
legend(["theory",raw"true $\phi$", raw"best-fit $\phi$", "difference"])
@@ -156,11 +156,11 @@ ylabel(raw"$\ell^4 C_\ell$");
156156
The best-fit unlensed fields relative to truth,
157157

158158
```julia
159-
plot([f,fbf], title = ["true", "best-fit"] .* " unlensed " .* ["E" "B"]);
159+
plot([f,fJ], title = ["true", "best-fit"] .* " unlensed " .* ["E" "B"]);
160160
```
161161

162162
The best-fit lensed field (bottom row) relative to truth (top row),
163163

164164
```julia
165-
plot([f̃, LenseFlow(ϕbf)*fbf], title = ["true", "best-fit"] .* " lensed " .* ["E" "B"]);
165+
plot([f̃, LenseFlow(ϕJ)*fJ], title = ["true", "best-fit"] .* " lensed " .* ["E" "B"]);
166166
```

docs/src/04_from_python.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jupyter:
55
extension: .md
66
format_name: markdown
77
format_version: '1.2'
8-
jupytext_version: 1.4.1
8+
jupytext_version: 1.9.1
99
kernelspec:
1010
display_name: Python 3
1111
language: python

docs/src/05_field_basics.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jupyter:
77
format_version: '1.2'
88
jupytext_version: 1.4.1
99
kernelspec:
10-
display_name: Julia 1.5.1
10+
display_name: Julia 1.5.3
1111
language: julia
1212
name: julia-1.5
1313
---

0 commit comments

Comments
 (0)