Skip to content

baseline

Full documentation pages are generated for docstring reference only and may contain symbols imported from other modules. Imported symbols are not distinguished from locally defined symbols and will appear in any module that they are imported into. For better information on where symbols should be imported from, review the sourcecode on the github.

FoSpy.plotting.diffraction.ui.baseline

X_LABEL module-attribute

X_LABEL = full_cfg.diffraction.x_label

full_cfg module-attribute

full_cfg = None

BaselineFinderAbstract

Source code in FoSpy/plotting/diffraction/ui/baseline.py
class BaselineFinderAbstract:
    def __init__(self, exp_int, exp_2th, cfg={}, **kwargs):
        self.exp_int = exp_int
        self.exp_2th = exp_2th
        self.offset = max(exp_int)

        specs = get_baseline_sliders(baseline_cfg=cfg)
        super().__init__(specs=specs, cfg=cfg, x_label=X_LABEL, y_ticks=False, y_label="Intensity", **kwargs)

        self.plotcolors = {
            "static": self.color1,
            "baseline": self.color2,
            "corrected": self.color3
        }

        self.plotXY(self.exp_2th, self.exp_int+self.offset, plotset="static")

        self.fitter = Baseline()

    def update_baseline(self):
        self.update_cfg()

        args = convert_baseline_cfg(self.cfg)

        baseline, _ = self.fitter.arpls(self.exp_int,**args)

        self.baseline = baseline
        self.corrected = self.exp_int - baseline

        self.reset_plotsets("baseline", "corrected")
        self.plotXY(self.exp_2th, self.baseline+self.offset, plotset="baseline")
        self.plotXY(self.exp_2th, self.corrected, plotset="corrected")

    def update_plot(self, val=None):
        super().update_plot(val)
        self.update_baseline()

    def main_loop(self):
        super().main_loop()
        return self.baseline, self.corrected

exp_2th instance-attribute

exp_2th = exp_2th

exp_int instance-attribute

exp_int = exp_int

fitter instance-attribute

fitter = Baseline()

offset instance-attribute

offset = max(exp_int)

plotcolors instance-attribute

plotcolors = {
    "static": self.color1,
    "baseline": self.color2,
    "corrected": self.color3,
}

__init__

__init__(exp_int, exp_2th, cfg={}, **kwargs)
Source code in FoSpy/plotting/diffraction/ui/baseline.py
def __init__(self, exp_int, exp_2th, cfg={}, **kwargs):
    self.exp_int = exp_int
    self.exp_2th = exp_2th
    self.offset = max(exp_int)

    specs = get_baseline_sliders(baseline_cfg=cfg)
    super().__init__(specs=specs, cfg=cfg, x_label=X_LABEL, y_ticks=False, y_label="Intensity", **kwargs)

    self.plotcolors = {
        "static": self.color1,
        "baseline": self.color2,
        "corrected": self.color3
    }

    self.plotXY(self.exp_2th, self.exp_int+self.offset, plotset="static")

    self.fitter = Baseline()

main_loop

main_loop()
Source code in FoSpy/plotting/diffraction/ui/baseline.py
def main_loop(self):
    super().main_loop()
    return self.baseline, self.corrected

update_baseline

update_baseline()
Source code in FoSpy/plotting/diffraction/ui/baseline.py
def update_baseline(self):
    self.update_cfg()

    args = convert_baseline_cfg(self.cfg)

    baseline, _ = self.fitter.arpls(self.exp_int,**args)

    self.baseline = baseline
    self.corrected = self.exp_int - baseline

    self.reset_plotsets("baseline", "corrected")
    self.plotXY(self.exp_2th, self.baseline+self.offset, plotset="baseline")
    self.plotXY(self.exp_2th, self.corrected, plotset="corrected")

update_plot

update_plot(val=None)
Source code in FoSpy/plotting/diffraction/ui/baseline.py
def update_plot(self, val=None):
    super().update_plot(val)
    self.update_baseline()

AssembleSlider

AssembleSlider(subcls, ui=None)
Source code in FoSpy/ui/sliders/abstract.py
def AssembleSlider(subcls, ui=None):
    from ..available import get_valid_ui, discover_ui_options

    # look for existing slider bindings
    ui_opts = discover_ui_options(__package__)

    # validate ui and route to correct module
    ui = get_valid_ui(ui, options=ui_opts.keys())
    plot_module = ui_opts[ui]

    # construct hybrid class with slider routines and ui bindings
    class SliderPlot(subcls, plot_module.SliderPlot):
        pass

    return SliderPlot

BaselineFinder

BaselineFinder(exp_int, exp_2th, ui=None, cfg={}, **kwargs)
Source code in FoSpy/plotting/diffraction/ui/baseline.py
def BaselineFinder(exp_int, exp_2th, ui=None, cfg={}, **kwargs):
    BaselineFinder = AssembleSlider(BaselineFinderAbstract, ui=ui)

    return BaselineFinder(exp_int, exp_2th, cfg=cfg, **kwargs)

convert_baseline_cfg

convert_baseline_cfg(baseline_cfg)
Source code in FoSpy/plotting/diffraction/phase_match/_utils.py
def convert_baseline_cfg(baseline_cfg):
    out = baseline_cfg.copy()

    out['lam'] = 10**out['lam']

    for int_cfg in ("max_iter", "diff_order"):
        out[int_cfg] = int(out[int_cfg])

    return out

get_baseline_sliders

get_baseline_sliders(baseline_cfg)
Source code in FoSpy/plotting/diffraction/ui/_specs.py
def get_baseline_sliders(baseline_cfg):
    sliders = {
        "lam": {
            "type": "scalar",
            "label": "Baseline Smoothing",
            "min": 0,
            "max": 10
        },
        "diff_order": {
            "type": "scalar",
            "label": "Differential Order",
            "min": 1,
            "max": 3,
            "int": True
        },
        "max_iter": {
            "type": "scalar",
            "label": "Maximum Iterations",
            "min": 1,
            "max": 100,
            "int": True
        },
        "tol": {
            "type": "scalar",
            "label": "Tolerance",
            "min": 0,
            "max": 1
        }
    }

    sliders = assemble_sliders(sliders, "baseline", baseline_cfg)
    return sliders