Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev 081 #28

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ dependencies = [
"loguru>=0.7",
"typer[all]",
"mpire[dill]~=2.10.0",
"tomli-w>=1.0.0"
]

[project.optional-dependencies]
Expand Down Expand Up @@ -89,7 +90,13 @@ addopts = [
"-ra -q",
"--cov",
"--cov-report term-missing html xml annotate",
"--strict-markers"
]
markers = [
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
"serial",
]

testpaths = [
"tests",
]
Expand Down
2 changes: 1 addition & 1 deletion src/raman_fitting/config/base_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from raman_fitting.models.deconvolution.spectrum_regions import (
get_default_regions_from_toml_files,
)
from .default_models import load_config_from_toml_files
from .load_config_from_toml import load_config_from_toml_files
from .path_settings import create_default_package_dir_or_ask, InternalPathSettings
from types import MappingProxyType

Expand Down
14 changes: 0 additions & 14 deletions src/raman_fitting/config/default_models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +0,0 @@
from pathlib import Path
from types import MappingProxyType
import tomllib


def load_config_from_toml_files() -> MappingProxyType:
current_parent_dir = Path(__file__).resolve().parent
default_peak_settings = {}
for i in current_parent_dir.glob("*.toml"):
default_peak_settings.update(tomllib.loads(i.read_bytes().decode()))
if not default_peak_settings:
raise ValueError("default models should not be empty.")

return MappingProxyType(default_peak_settings)
40 changes: 23 additions & 17 deletions src/raman_fitting/config/default_models/first_order.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
[first_order]
[spectrum]

[first_order.models]
[spectrum.regions.first_order]

[spectrum.regions.first_order.limits]
min = 900
max = 2000

[spectrum.regions.first_order.models]
1peak = "G"
2peaks = "G+D"
3peaks = "G+D+D3"
4peaks = "G+D+D3+D4"
5peaks = "G+D+D2+D3+D4"
6peaks = "G+D+D2+D3+D4+D5"

[first_order.peaks]
[spectrum.regions.first_order.peaks]

[first_order.peaks.G]
[spectrum.regions.first_order.peaks.G]
docstring = """
Graphite belongs to the P63/mmc (D46h) space group. If considering only a graphene plane, at
the à point of the Brillouin zone, there are six normal modes that possess only one mode (doubly
Expand All @@ -23,13 +29,13 @@ Für G: 1580-1590 D5 und D2 weiß ich nicht
"""
peak_name = "G"
peak_type = "Lorentzian"
[first_order.peaks.G.param_hints]
[spectrum.regions.first_order.peaks.G.param_hints]
center = {value = 1571, min = 1545, max = 1595}
sigma = {value = 30, min = 5, max = 150}
amplitude = {value = 100, min = 1e-05, max = 500}


[first_order.peaks.D]
[spectrum.regions.first_order.peaks.D]
docstring = """
D or D1 ; Disordered graphitic lattice (graphene layer edges,A1gsymmetry)
A defective graphite presents other bands that can be as intense as the G band at D=1350 and D'=1615 cm-1
Expand All @@ -38,39 +44,39 @@ Für D1: 1340-1350
"""
peak_name = "D"
peak_type = "Lorentzian"
[first_order.peaks.D.param_hints]
[spectrum.regions.first_order.peaks.D.param_hints]
center = {value = 1350, min = 1330, max = 1380}
sigma = {value = 35, min = 1, max = 150}
amplitude = {value = 120, min = 1e-05, max = 500}

[first_order.peaks.D2]
[spectrum.regions.first_order.peaks.D2]
docstring = """
D2 or D' ; Right next to the G peak, sometimes not obvious as G peak split.
Disordered graphitic lattice (surface graphene layers,E2g-symmetry)
j.molstruc.2010.12.065
"""
peak_name = "D2"
peak_type = "Lorentzian"
[first_order.peaks.D2.param_hints]
[spectrum.regions.first_order.peaks.D2.param_hints]
center = {value = 1606, min = 1592, max = 1635}
sigma = {value = 30, min = 5, max = 150}
amplitude = {value = 35, min = 5, max = 500}


[first_order.peaks.D3]
[spectrum.regions.first_order.peaks.D3]
docstring = """
D3 or D'' or A or Am ; Between the D and G peak, sometimes too broad.
For amorphous carbon (Gaussian[26]or Lorentzian[3,18,27]line shape).
Für D3: 1495-1515
"""
peak_name = "D3"
peak_type = "Lorentzian"
[first_order.peaks.D3.param_hints]
[spectrum.regions.first_order.peaks.D3.param_hints]
center = {value = 1480, min = 1450, max = 1525}
sigma = {value = 25, min = 1, max = 150}
amplitude = {value = 25, min = 1e-02, max = 500}

[first_order.peaks.D4]
[spectrum.regions.first_order.peaks.D4]
docstring = """
D4 or I ; Below D band, a shoulder sometimes split with D5 band.
Disordered graphitic lattice (A1gsymmetry)[10],polyenes[3,27], ionic impurities
Expand All @@ -80,24 +86,24 @@ Für D4: 1185-1210, but depends on if there is D5 or not.
"""
peak_name = "D4"
peak_type = "Lorentzian"
[first_order.peaks.D4.param_hints]
[spectrum.regions.first_order.peaks.D4.param_hints]
center = {value = 1230, min = 1180, max = 1310}
sigma = {value = 40, min = 1, max = 150}
amplitude = {value = 20, min = 1e-02, max = 200}

[first_order.peaks.D5]
[spectrum.regions.first_order.peaks.D5]
docstring = """
D5 peak at 1110 cm−1. At lowest should of D peak, below D4.
Ref: Jurkiewicz, K., Pawlyta, M., Zygadło, D. et al. J Mater Sci (2018) 53: 3509. https://doi.org/10.1007/s10853-017-1753-7
"""
peak_name = "D5"
peak_type = "Lorentzian"
[first_order.peaks.D5.param_hints]
[spectrum.regions.first_order.peaks.D5.param_hints]
center = {value = 1110, min = 1080, max = 1150}
sigma = {value = 40, min = 1, max = 150}
amplitude = {value = 20, min = 1e-02, max = 200}

[first_order.peaks.Si1]
[spectrum.regions.first_order.peaks.Si1]
docstring = """
===== Extra peak at ca. 960 cm-1 presumably from Si substrate 2nd order === not from Nafion...
=> Either cut the Spectra 1000-2000
Expand All @@ -106,7 +112,7 @@ docstring = """
peak_name = "Si1"
peak_type = "Gaussian"
is_substrate = true
[first_order.peaks.Si1.param_hints]
[spectrum.regions.first_order.peaks.Si1.param_hints]
center = {value = 960, min = 900, max = 980}
sigma = {value = 10, min = 0, max = 150}
amplitude = {value = 10, min = 0, max = 200}
87 changes: 87 additions & 0 deletions src/raman_fitting/config/default_models/low_first_order.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
[spectrum]

[spectrum.regions.low_first_order]

[spectrum.regions.low_first_order.limits]
min = 220
max = 500
extra_margin = 10

[spectrum.regions.low_first_order.models]
low1peak = "A"
low2peaks = "B+C"
low3peaks = "A+B+C"
low4peaks = "A+B+C+C2"
low5peaks = "A+B+C+C2+F"

[spectrum.regions.low_first_order.peaks]

[spectrum.regions.low_first_order.peaks.A]
docstring = """
A, around 290
"""
peak_name = "A"
peak_type = "Lorentzian"
[spectrum.regions.low_first_order.peaks.A.param_hints]
center = {value = 290, min = 220, max = 300}
sigma = {value = 30, min = 2, max = 70}
amplitude = {value = 50, min = 1e-05, max = 500}


[spectrum.regions.low_first_order.peaks.B]
docstring = """
around 320
"""
peak_name = "B"
peak_type = "Lorentzian"
[spectrum.regions.low_first_order.peaks.B.param_hints]
center = {value = 315, min = 300, max = 340}
sigma = {value = 35, min = 1, max = 150}
amplitude = {value = 120, min = 1e-05, max = 500}

[spectrum.regions.low_first_order.peaks.C]
docstring = """
around 340
"""
peak_name = "C"
peak_type = "Lorentzian"
[spectrum.regions.low_first_order.peaks.C.param_hints]
center = {value = 340, min = 325, max = 355}
sigma = {value = 30, min = 5, max = 150}
amplitude = {value = 70, min = 5, max = 500}


[spectrum.regions.low_first_order.peaks.C2]
docstring = """
should of c, around 370
"""
peak_name = "C2"
peak_type = "Lorentzian"
[spectrum.regions.low_first_order.peaks.C2.param_hints]
center = {value = 360, min = 355, max = 375}
sigma = {value = 25, min = 5, max = 150}
amplitude = {value = 25, min = 1e-02, max = 500}

[spectrum.regions.low_first_order.peaks.F]
docstring = """
F, around 475
"""
peak_name = "F"
peak_type = "Lorentzian"
[spectrum.regions.low_first_order.peaks.F.param_hints]
center = {value = 475, min = 450, max = 500}
sigma = {value = 40, min = 1, max = 150}
amplitude = {value = 20, min = 1e-02, max = 200}


[spectrum.regions.low_first_order.peaks.Si2]
docstring = """
Extra band at 670
"""
peak_name = "Si2"
peak_type = "Gaussian"
is_substrate = true
[spectrum.regions.low_first_order.peaks.Si2.param_hints]
center = {value = 670, min = 600, max = 710}
sigma = {value = 40, min = 0, max = 150}
amplitude = {value = 10, min = 0, max = 200}
19 changes: 12 additions & 7 deletions src/raman_fitting/config/default_models/normalization.toml
Original file line number Diff line number Diff line change
@@ -1,30 +1,35 @@
[normalization]
[spectrum]

[normalization.models]
[spectrum.regions.normalization.limits]
min = 1500
max = 1675
extra_margin = 10

[spectrum.regions.normalization.models]
norm = "norm_G+norm_D"

[normalization.peaks]
[spectrum.regions.normalization.peaks]

[normalization.peaks.norm_G]
[spectrum.regions.normalization.peaks.norm_G]
docstring = """
G_peak used for normalization
"""
peak_name = "norm_G"
peak_type = "Lorentzian"
is_for_normalization = true
[normalization.peaks.norm_G.param_hints]
[spectrum.regions.normalization.peaks.norm_G.param_hints]
center = {"value" = 1581, "min" = 1500, "max" = 1600}
sigma = {"value" = 40, "min" = 1e-05, "max" = 1e3}
amplitude = {"value" = 8e4, "min" = 1e2}

[normalization.peaks.norm_D]
[spectrum.regions.normalization.peaks.norm_D]
docstring = """
D_peak for normalization
"""
peak_name = "norm_D"
peak_type = "Lorentzian"
is_for_normalization = true
[normalization.peaks.norm_D.param_hints]
[spectrum.regions.normalization.peaks.norm_D.param_hints]
center = {"value" = 1350, "min" = 1300, "max" = 1400}
sigma = {"value" = 90, "min" = 1e-05}
amplitude = {"value" = 10e5, "min" = 1e2}
28 changes: 17 additions & 11 deletions src/raman_fitting/config/default_models/second_order.toml
Original file line number Diff line number Diff line change
@@ -1,38 +1,44 @@
[second_order]
[spectrum]

[second_order.models]
[spectrum.regions.second_order]

[spectrum.regions.second_order.limits]
min = 2150
max = 3380

[spectrum.regions.second_order.models]
2nd_4peaks = "D4D4+D1D1+GD1+D2D2"

[second_order.peaks]
[spectrum.regions.second_order.peaks]

[second_order.peaks.D4D4]
[spectrum.regions.second_order.peaks.D4D4]
peak_name = "D4D4"
peak_type = "Lorentzian"
[second_order.peaks.D4D4.param_hints]
[spectrum.regions.second_order.peaks.D4D4.param_hints]
center = {value = 2435, min = 2400, max = 2550}
sigma = {value = 30, min = 1, max = 200}
amplitude = {value = 2, min = 1e-03, max = 100}

[second_order.peaks.D1D1]
[spectrum.regions.second_order.peaks.D1D1]
peak_name = "D1D1"
peak_type = "Lorentzian"
[second_order.peaks.D1D1.param_hints]
[spectrum.regions.second_order.peaks.D1D1.param_hints]
center = {value = 2650, min = 2600, max = 2750}
sigma = {value = 60, min = 1, max = 200}
amplitude = {value = 14, min = 1e-03, max = 100}

[second_order.peaks.GD1]
[spectrum.regions.second_order.peaks.GD1]
peak_name = "GD1"
peak_type = "Lorentzian"
[second_order.peaks.GD1.param_hints]
[spectrum.regions.second_order.peaks.GD1.param_hints]
center = {value = 2900, min = 2800, max = 2950}
sigma = {value = 50, min = 1, max = 200}
amplitude = {value = 10, min = 1e-03, max = 100}

[second_order.peaks.D2D2]
[spectrum.regions.second_order.peaks.D2D2]
peak_type = "Lorentzian"
peak_name = "D2D2"
[second_order.peaks.D2D2.param_hints]
[spectrum.regions.second_order.peaks.D2D2.param_hints]
center = {value = 3250, min = 3000, max = 3400}
sigma = {value = 60, min = 20, max = 200}
amplitude = {value = 1, min = 1e-03, max = 100}
19 changes: 12 additions & 7 deletions src/raman_fitting/config/default_models/spectrum_regions.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
[spectrum]

[spectrum.regions]
full = {"min" = 200, "max" = 3600}
full_first_and_second = {"min" = 800, "max" = 3500}
low = {"min" = 150, "max" = 850, "extra_margin" = 10}
first_order = {"min" = 900, "max" = 2000}
mid = {"min" = 1850, "max" = 2150, "extra_margin" = 10}
normalization = {"min" = 1500, "max" = 1675, "extra_margin" = 10}
second_order = {"min" = 2150, "max" = 3380}

[spectrum.regions.full]
limits = {"min" = 200, "max" = 3600}

[spectrum.regions.full_first_and_second]
limits = {"min" = 800, "max" = 3500}

[spectrum.regions.low]
limits = {"min" = 150, "max" = 850, "extra_margin" = 10}

[spectrum.regions.mid]
limits = {"min" = 1850, "max" = 2150, "extra_margin" = 10}
Loading
Loading