Skip to content

Commit

Permalink
add test case for vms data analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaspie committed Nov 21, 2024
1 parent 26f0066 commit fcab3fe
Show file tree
Hide file tree
Showing 9 changed files with 4,808 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ cython_debug/
!examples/vms/vms_txt_export.txt
!tests/data/scienta_txt/Ag_*.txt
!tests/data/vms_txt_export/vms_txt_export.txt
!tests/data/vms_analysis/FeO_analyzed_lineshapes_cols.txt

build/
.python-version
Expand Down
10 changes: 9 additions & 1 deletion scripts/regenerate_ref_nxs_files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ function update_vms_txt_export_ref {
cd ..
}

function update_vms_analysis_ref {
cd vms_analysis/
echo "Update Vamas data anaylsis export reference"
dataconverter dataconverter FeO* eln.yaml --reader $READER --nxdl $NXDL --ignore-undocumented --output vms_analysis.nxs
cd ..
}

project_dir=$(dirname $(dirname $(realpath $0)))
cd $project_dir/tests/data

Expand All @@ -86,4 +93,5 @@ update_specs_xml_ref
update_specs_xy_ref
update_vms_irregular_ref
update_vms_regular_ref
update_vms_txt_export_ref
update_vms_txt_export_ref
update_vms_analysis_ref
14 changes: 8 additions & 6 deletions src/pynxtools_xps/models/backgrounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
class LinearBackground:
"""Linear background model for XPS spectra that connects the first and last points in the y array."""

def __init__(self):
def __init__(self, *args):
"""
Initialize the linear background model without predefined parameters.
The slope and intercept will be calculated based on the input data.
Expand Down Expand Up @@ -76,7 +76,7 @@ def formula(self) -> str:
class StepUp:
"""Step Up background model for XPS spectra, based on the complementary error function."""

def __init__(self, a0: float, a1: float, a2: float, a3: float):
def __init__(self, a0: float, a1: float, a2: float, a3: float, *args):
"""
Initialize the Step Up background model without predefined parameters.
"""
Expand Down Expand Up @@ -122,7 +122,7 @@ def formula(self) -> str:
class StepDown:
"""Step Down background model for XPS spectra, the reflection of Step Up around the edge position."""

def __init__(self, a0: float, a1: float, a2: float, a3: float):
def __init__(self, a0: float, a1: float, a2: float, a3: float, *args):
"""
Initialize the Step Up background model without predefined parameters.
"""
Expand Down Expand Up @@ -176,7 +176,7 @@ class Shirley:
tolerance and maximum iterations.
"""

def __init__(self) -> None:
def __init__(self, *args) -> None:
"""Initialize the Shirley background subtraction object."""
pass

Expand Down Expand Up @@ -288,7 +288,7 @@ class TougaardU3:
C (float): Shape parameter that determines the background curvature.
"""

def __init__(self, E0: float, A: float, C: float):
def __init__(self, E0: float, A: float, C: float, *args):
"""
Initialize the U3 Tougaard model with the required parameters.
Expand Down Expand Up @@ -343,7 +343,9 @@ def __repr__(self) -> str:
class TougaardU4:
"""U4 Tougaard background model for XPS spectra."""

def __init__(self, B: float, C: float, D: float, Eg: float, temp: float = 300.0):
def __init__(
self, B: float, C: float, D: float, Eg: float, temp: float = 300.0, *args
):
"""
Initialize the U4 Tougaard model with the required parameters.
Expand Down
8 changes: 5 additions & 3 deletions src/pynxtools_xps/vms/casa_data_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,15 +386,17 @@ def calculate_background(self, x: np.ndarray, y: np.ndarray):
"Shirley": Shirley,
"Step Up": StepUp,
"Step Down": StepDown,
"U 2 Tougaard": TougaardU3,
"U 3 Tougaard": TougaardU3,
"U 4 Tougaard": TougaardU4,
}

leading_letters, _ = split_after_letters(self.bg_type)
background_params = [float(param) for param in self.cross_section]
background_params = [
float(param) for param in self.cross_section if float(param)
]

try:
background_class = backgrounds[leading_letters]
background_class = backgrounds[self.bg_type]

try:
background = background_class(*background_params)
Expand Down
Loading

0 comments on commit fcab3fe

Please sign in to comment.