Skip to content

Commit 834a7c3

Browse files
authored
Merge pull request #37 from garrekstemo/garrekstemo
Change ## to # in example comments
2 parents 2bc6aa1 + 1c4e504 commit 834a7c3

File tree

4 files changed

+45
-44
lines changed

4 files changed

+45
-44
lines changed

docs/src/Measurements.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ We first generate a dummy signal to play with:
1717
```@example 1
1818
using Plots, Spectra, Random
1919
20-
## the x axis
20+
# the x axis
2121
x = collect(0:0.1:100)
2222
23-
## a fake signal: perfect y
23+
# a fake signal: perfect y
2424
y_perfect = gaussian(x, 1.0, 50.0, 6.0)
2525
26-
## we add noise: observed y
26+
# we add noise: observed y
2727
y = y_perfect + 0.05*randn(size(x,1))
2828
2929
plot(x, y, label="Noisy observed signal", xlabel="X", ylabel="Y")

docs/src/PeakFitting.md

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,22 @@ using Plots
3838
using Spectra
3939
using Statistics
4040
41-
## The X axis
41+
# The X axis
4242
x = collect(0:0.2:100)
43-
## The "perfect" Y signal
43+
44+
# The "perfect" Y signal
4445
y_perfect = (
4546
gaussian(x, [10.0, 35.0, 10.0]) +
4647
lorentzian(x, [15.0, 55.0, 3.0]) +
4748
pearson7(x, [20.0, 45.0, 2.0, 0.4])
4849
)
49-
## Of course, in real world we have noise, here it is Gaussian
50+
# Of course, in real world we have noise, here it is Gaussian
5051
noise = randn(length(x))*0.3
5152
52-
## This is what we observe and want to fit
53+
# This is what we observe and want to fit
5354
y_obs = y_perfect + noise
5455
55-
## Let's visualize it!
56+
# Let's visualize it!
5657
p1 = plot(x, [y_perfect, y_obs]; labels=["The true signal" "Observations"])
5758
savefig("fit_1.svg"); nothing #hide
5859
```
@@ -61,27 +62,27 @@ savefig("fit_1.svg"); nothing #hide
6162
First, you define a vector containing named vectors of peak types, ``m_{prior}``, ``\sigma_{m_{prior}}``, and lower and upper boundaries. For instance, after a visual review of the signal above, you would declare a vector of peak informations like this:
6263

6364
```@example 1
65+
# (peak_type, m_prior, sigma_m_prior, lower_bounds, upper_bounds)
6466
peaks_info = [
65-
## (peak_type, m_prior, sigma_m_prior, lower_bounds, upper_bounds)
6667
(
67-
:gaussian, ## peak_type
68-
[10.5, 30.0, 11.0], ## m_prior (intensity, position, hwhm)
69-
[5.0, 5.0, 3.0], ## sigma_m_prior
70-
[0.0, 0.0, 0.0], ## lower_bounds
71-
[Inf, Inf, 50.0]), ## upper_bounds
68+
:gaussian, # peak_type
69+
[10.5, 30.0, 11.0], # m_prior (intensity, position, hwhm)
70+
[5.0, 5.0, 3.0], # sigma_m_prior
71+
[0.0, 0.0, 0.0], # lower_bounds
72+
[Inf, Inf, 50.0]), # upper_bounds
7273
(
73-
:lorentzian, ## peak_type
74-
[17.5, 54.0, 3.1], ## m_prior (intensity, position, hwhm)
75-
[5.0, 3.0, 1.0], ## sigma_m_prior
76-
[0.0, 0.0, 0.0], ## lower_bounds
77-
[Inf, Inf, Inf], ## upper_bounds
74+
:lorentzian, # peak_type
75+
[17.5, 54.0, 3.1], # m_prior (intensity, position, hwhm)
76+
[5.0, 3.0, 1.0], # sigma_m_prior
77+
[0.0, 0.0, 0.0], # lower_bounds
78+
[Inf, Inf, Inf], # upper_bounds
7879
),
7980
(
80-
:pearson7, ## peak_type
81-
[21.5, 44.0, 3.0, 0.4], ## m_prior (intensity, position, hwhm, shape exponent)
82-
[3.0, 2.0, 5.0, 0.02], ## sigma_m_prior
83-
[0.0, 0.0, 0.0, 0.0], ## lower_bounds
84-
[100.0, 100.0, 50.0, Inf], ## upper_bounds
81+
:pearson7, # peak_type
82+
[21.5, 44.0, 3.0, 0.4], # m_prior (intensity, position, hwhm, shape exponent)
83+
[3.0, 2.0, 5.0, 0.02], # sigma_m_prior
84+
[0.0, 0.0, 0.0, 0.0], # lower_bounds
85+
[100.0, 100.0, 50.0, Inf], # upper_bounds
8586
),
8687
]
8788
```
@@ -231,34 +232,34 @@ Run it on your own computer! If you have suggestions, do not hesitate!
231232
```julia
232233
using Turing
233234

234-
## Define a Bayesian model with priors
235+
# Define a Bayesian model with priors
235236
@model function bayesian_peaks(x, y)
236-
## Define priors based on peak_types
237+
# Define priors based on peak_types
237238

238-
## PEAK 1
239+
# PEAK 1
239240
amplitude ~ truncated(Normal(10.016, 0.5), 0.0, Inf)
240241
center ~ Normal(34.92, 0.5)
241242
width ~ truncated(Normal(10.0, 0.5), 0.0, Inf)
242243

243244
μ = gaussian(x, [amplitude, center, width])
244245

245-
## PEAK 2
246+
# PEAK 2
246247
amplitude2 ~ truncated(Normal(14.9, 0.5), 0.0, Inf)
247248
center2 ~ Normal(55.0, 0.5)
248249
width2 ~ truncated(Normal(3.0, 0.5), 0.0, Inf)
249250

250251
μ2 = lorentzian(x, [amplitude2, center2, width2])
251252

252-
## PEAK 3
253+
# PEAK 3
253254
amplitude3 ~ truncated(Normal(25.5, 0.5), 0.0, Inf)
254255
center3 ~ Normal(43.0, 10.0)
255256
width3 ~ truncated(Normal(2.0, 0.5), 0.0, Inf)
256257
lr ~ truncated(Normal(0.39, 0.03), 0.0, 1.0)
257258

258-
## Calculate model prediction
259+
# Calculate model prediction
259260
μ3 = pseudovoigt(x, [amplitude3, center3, width3, lr])
260261

261-
## Likelihood
262+
# Likelihood
262263
σ ~ truncated(Normal(0.2, 0.03), 0.001, Inf)
263264
y ~ MvNormal+ μ2 + μ3, σ^2 * I)
264265
end

docs/src/PreProcessing.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,29 @@ Spectra allows you to perform several processing steps on x-y spectral data. Bel
77
As a starting point and for the sack of example, we create two synthetic signals to play with. They will be Gaussian signals randomly sampled along two different X axis, with noise and increasing backgrounds. One of them will also have a strong spike!
88

99
```@example 1
10-
## Signal creation
10+
# Signal creation
1111
using Spectra, Plots
1212
13-
## we create a fake signal with
13+
# we create a fake signal with
1414
x_1 = rand(1000)*100
1515
x_2 = rand(1000)*100
1616
17-
## create a signal that is the combination of two gaussian peaks plus a background
17+
# create a signal that is the combination of two gaussian peaks plus a background
1818
background_1 = 0.08 * x_1
1919
background_2 = 0.03 * x_2
2020
21-
## some noise
21+
# some noise
2222
noise_1 = 0.5*randn(1000)
2323
noise_2 = 0.3*randn(1000)
2424
25-
## the full toy signals
25+
# the full toy signals
2626
y_1 = gaussian(x_1, 10.0, 40., 5.) .+ background_1 .+ noise_1
2727
y_2 = gaussian(x_2, 20.0, 60., 9.) .+ background_2 .+ noise_2
2828
29-
## one of them will have a spike!
29+
# one of them will have a spike!
3030
y_1[600] = 250.0
3131
32-
## make a plot of our two spectra
32+
# make a plot of our two spectra
3333
scatter(x_1, y_1)
3434
scatter!(x_2, y_2)
3535
savefig("fp_1.svg"); nothing #hide

docs/src/examples/Raman_spectrum_fitting.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ For further references for fitting Raman spectra of glasses, please see for inst
4444
First, we import the libraries for doing various things:
4545

4646
````@example Raman_spectrum_fitting
47-
using Spectra ## our Spectra library
48-
using Statistics ## to have access to core functions like mean() or std()
49-
using DelimitedFiles ## to import the data
47+
using Spectra # our Spectra library
48+
using Statistics # to have access to core functions like mean() or std()
49+
using DelimitedFiles # to import the data
5050
5151
# Plotting libraries
52-
using Plots ## to make plots
53-
gr() ## Plots backend
54-
using LaTeXStrings ## LaTeX for superscripts/subscripts in labels, captions...
52+
using Plots # to make plots
53+
gr() # Plots backend
54+
using LaTeXStrings # LaTeX for superscripts/subscripts in labels, captions...
5555
````
5656

5757
## Importing data

0 commit comments

Comments
 (0)