From f44c7596dfef083351cd1dc9284869d4b4ef78a1 Mon Sep 17 00:00:00 2001 From: David Wallace Date: Sun, 10 Dec 2023 18:31:09 +0100 Subject: [PATCH] chore: fix bugs --- pyproject.toml | 2 +- .../deconvolution_models/prepare_parameters.py | 14 +++++++++----- .../processing/baseline_subtraction.py | 3 +-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 2820128..09cdae1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,7 +58,7 @@ repository = "https://github.com/MyPyDavid/raman-fitting.git" # documentation = "https://raman-fitting.readthedocs.io/en/latest/" [project.scripts] -raman_fitting = "raman_fitting.interfaces:main" +raman_fitting = "raman_fitting.interfaces.cli:main" [tool.hatch.version] diff --git a/src/raman_fitting/deconvolution_models/prepare_parameters.py b/src/raman_fitting/deconvolution_models/prepare_parameters.py index 282df26..22d2d5f 100644 --- a/src/raman_fitting/deconvolution_models/prepare_parameters.py +++ b/src/raman_fitting/deconvolution_models/prepare_parameters.py @@ -37,22 +37,26 @@ def add_D4_ratio(a: str, t: str, peaks, result): def add_ratio_combined_params( - windowname: str, a: str, t: str, result={}, extra_fit_results=None + windowname, a: str, t: str, result={}, extra_fit_results=None ): windowname_2nd = "2nd_4peaks" + if windowname is None: + return {} + if windowname.startswith("1st") and windowname_2nd in extra_fit_results.keys(): _D1D1 = extra_fit_results[windowname_2nd].FitParameters.loc[ f"Model_{windowname_2nd}", "D1D1" + t ] result.update({"D1D1" + t: _D1D1}) return {f"Leq_{a}": 8.8 * _D1D1 / result["D" + t]} - else: - return {} + return {} -def add_D1D1_GD1_ratio(a: str, t: str, peaks, result, extra_fit_results): +def add_D1D1_GD1_ratio( + a: str, t: str, peaks, result, extra_fit_results, window_name=None +): RatioParams = {} if {"D1D1_", "GD1_"}.issubset(peaks): RatioParams.update({f"{a}D1D1/{a}GD1": result["D1D1" + t] / result["GD1" + t]}) if extra_fit_results: - RatioParams.update(add_ratio_combined_params(a, t)) + RatioParams.update(add_ratio_combined_params(window_name, a, t)) diff --git a/src/raman_fitting/processing/baseline_subtraction.py b/src/raman_fitting/processing/baseline_subtraction.py index 926bcf3..e2e87a1 100644 --- a/src/raman_fitting/processing/baseline_subtraction.py +++ b/src/raman_fitting/processing/baseline_subtraction.py @@ -76,9 +76,8 @@ def subtract_loop(windows_data: dict, window_limits: dict, label=None): blcorr_int, blcorr_lin = subtract_baseline_per_window( spec, window_name, windows_data, window_limits ) - label = f"blcorr_{window_name}" if label: - label = f"{label}_{label}" + label = f"blcorr_{label}" _data = SpectrumData(spec.ramanshift, blcorr_int, label, window_name) _blcorr.update(**{window_name: _data}) _info.update(**{window_name: blcorr_lin})