示例#1
0
    def test_whole(self):
        data = Orange.data.Table([[1, 5, 1]])
        i = LinearBaseline()(data)
        np.testing.assert_equal(i.X, [[0, 4, 0]])

        data = Orange.data.Table([[4, 1, 2, 4]])
        i = LinearBaseline(peak_dir=LinearBaseline.PeakNegative)(data)
        np.testing.assert_equal(i.X, [[0, -3, -2, 0]])
    def test_whole(self):
        data = Table.from_numpy(None, [[1, 5, 1]])
        i = LinearBaseline()(data)
        np.testing.assert_equal(i.X, [[0, 4, 0]])

        data = Table.from_numpy(None, [[4, 1, 2, 4]])
        i = LinearBaseline(peak_dir=LinearBaseline.PeakNegative)(data)
        np.testing.assert_equal(i.X, [[0, -3, -2, 0]])
示例#3
0
    def createinstance(params):
        baseline_type = params.get("baseline_type", 0)
        peak_dir = params.get("peak_dir", 0)
        sub = params.get("sub", 0)
        zero_points = params.get("zero_points", None)

        if baseline_type == 0:
            return LinearBaseline(peak_dir=peak_dir,
                                  sub=sub,
                                  zero_points=zero_points)
        elif baseline_type == 1:
            return RubberbandBaseline(peak_dir=peak_dir, sub=sub)
        else:
            raise Exception("unknown baseline type")
 def test_edgepoints_out_of_data(self):
     data = Table.from_numpy(None, [[1, 5, 1]])
     i = LinearBaseline(zero_points=[0, 2.000000001])(data)
     np.testing.assert_almost_equal(i.X, [[0, 4, 0]])
 def test_3points(self):
     data = Table.from_numpy(None, [[1, 5, 1, 5]])
     i = LinearBaseline(zero_points=[0, 1, 3])(data)
     np.testing.assert_equal(i.X, [[0, 0, -4, 0]])
 def test_edgepoints_extrapolate(self):
     data = Table.from_numpy(None, [[1, 5, 1]])
     i = LinearBaseline(zero_points=[0, 1])(data)
     np.testing.assert_equal(i.X, [[0, 0, -8]])
    Interpolate(np.linspace(1000, 1700, 100)),
    SavitzkyGolayFiltering(window=9, polyorder=2, deriv=2),
    Cut(lowlim=1000, highlim=1800),
    GaussianSmoothing(sd=3.),
    Absorbance(),
    Transmittance(),
    Integrate(limits=[[900, 100], [1100, 1200], [1200, 1300]]),
    Integrate(methods=Integrate.Simple, limits=[[1100, 1200]]),
    Integrate(methods=Integrate.Baseline, limits=[[1100, 1200]]),
    Integrate(methods=Integrate.PeakMax, limits=[[1100, 1200]]),
    Integrate(methods=Integrate.PeakBaseline, limits=[[1100, 1200]]),
    Integrate(methods=Integrate.PeakAt, limits=[[1100]]),
    Integrate(methods=Integrate.PeakX, limits=[[1100, 1200]]),
    Integrate(methods=Integrate.PeakXBaseline, limits=[[1100, 1200]]),
    RubberbandBaseline(),
    LinearBaseline(),
    Normalize(method=Normalize.Vector),
    Normalize(method=Normalize.Area,
              int_method=Integrate.PeakMax,
              lower=0,
              upper=10000),
    Normalize(method=Normalize.MinMax),
    CurveShift(1),
    Despike(threshold=5, cutoff=60, dis=5),
]

xas_norm_collagen = XASnormalization(edge=1630,
                                     preedge_dict={
                                         'from': 1000,
                                         'to': 1300,
                                         'deg': 1
示例#8
0
 def test_edgepoints_out_of_data(self):
     data = Orange.data.Table([[1, 5, 1]])
     i = LinearBaseline(zero_points=[0, 2.000000001])(data)
     np.testing.assert_almost_equal(i.X, [[0, 4, 0]])
示例#9
0
 def test_3points(self):
     data = Orange.data.Table([[1, 5, 1, 5]])
     i = LinearBaseline(zero_points=[0, 1, 3])(data)
     np.testing.assert_equal(i.X, [[0, 0, -4, 0]])
示例#10
0
 def test_edgepoints_extrapolate(self):
     data = Orange.data.Table([[1, 5, 1]])
     i = LinearBaseline(zero_points=[0, 1])(data)
     np.testing.assert_equal(i.X, [[0, 0, -8]])
import numpy as np
from Orange.widgets.data.utils.preprocess import DescriptionRole
from Orange.widgets.tests.base import WidgetTest
from orangewidget.tests.base import GuiTest

from orangecontrib.spectroscopy.data import getx
from orangecontrib.spectroscopy.preprocess import Cut, LinearBaseline
from orangecontrib.spectroscopy.tests.spectral_preprocess import wait_for_preview
from orangecontrib.spectroscopy.widgets.gui import MovableVline
from orangecontrib.spectroscopy.widgets.owpeakfit import OWPeakFit, fit_peaks, PREPROCESSORS, \
    create_model, prepare_params, unique_prefix, create_composite_model, pack_model_editor
from orangecontrib.spectroscopy.widgets.peak_editors import ParamHintBox, VoigtModelEditor, \
    PseudoVoigtModelEditor, ExponentialGaussianModelEditor, PolynomialModelEditor

COLLAGEN = Orange.data.Table("collagen")[0:3]
COLLAGEN_2 = LinearBaseline()(Cut(lowlim=1500, highlim=1700)(COLLAGEN))
COLLAGEN_1 = LinearBaseline()(Cut(lowlim=1600, highlim=1700)(COLLAGEN_2))


class TestOWPeakFit(WidgetTest):
    def setUp(self):
        self.widget = self.create_widget(OWPeakFit)
        self.data = COLLAGEN_1

    def test_load_unload(self):
        self.send_signal("Data", Orange.data.Table("iris.tab"))
        self.send_signal("Data", None)

    def test_allint_indv(self):
        for p in PREPROCESSORS:
            with self.subTest(msg=f"Testing model {p.name}"):
                    self.info_preproc.setText(
                        self._format_preproc_str(
                            self.preprocessor).lstrip("\n"))
            else:
                # only allow readers with tile-by-tile support to run.
                reader = None
            return reader
        elif self.source == self.URL:
            url = self.url_combo.currentText().strip()
            if url:
                return UrlReader(url)


if __name__ == "__main__":
    import sys
    from orangecontrib.spectroscopy.preprocess import Cut, LinearBaseline
    from Orange.preprocess.preprocess import PreprocessorList
    import orangecontrib.protospec  #load readers
    a = QApplication(sys.argv)
    # preproc = PreprocessorList([Cut(lowlim=2000, highlim=2006), LinearBaseline()])
    preproc = PreprocessorList(
        [LinearBaseline(), Cut(lowlim=2000, highlim=2006)])
    # preproc = PreprocessorList([Cut(lowlim=2000, highlim=2006), Cut(lowlim=2002, highlim=2006)])
    # Test 2nd Deriv superwide
    # from orangecontrib.spectroscopy.preprocess import Normalize, Integrate, integrate, SavitzkyGolayFiltering
    # preproc = PreprocessorList([Normalize(lower=1591.0484214631633, upper=1719.720747038586, int_method=integrate.IntegrateFeatureSimple), SavitzkyGolayFiltering(window=13, deriv=2), Integrate(methods=integrate.IntegrateFeatureAtPeak, limits=[[1625.0, 1.0], [1152.0, 1.0], [1575.0, 1.0], [1127.0, 1.0]])])
    ow = OWTilefile()
    ow.update_preprocessor(preproc)
    ow.show()
    a.exec_()
    ow.saveSettings()