def test_simple(self):
     """ Just one point is not in the convex region. """
     data = Table.from_numpy(None, [[1, 2, 1, 1]])
     i = RubberbandBaseline()(data)
     np.testing.assert_equal(i.X, [[0, 1, 0, 0]])
     data = Table.from_numpy(None, [[1, 2, 1, 1]])
     i = RubberbandBaseline(peak_dir=RubberbandBaseline.PeakNegative)(data)
     np.testing.assert_equal(i.X, [[0, 0, -0.5, 0]])
 def test_whole(self):
     """ Every point belongs in the convex region. """
     data = Table.from_numpy(None, [[2, 1, 2]])
     i = RubberbandBaseline()(data)
     np.testing.assert_equal(i.X, 0)
     data = Table.from_numpy(None, [[1, 2, 1]])
     i = RubberbandBaseline(peak_dir=RubberbandBaseline.PeakNegative)(data)
     np.testing.assert_equal(i.X, 0)
Ejemplo n.º 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")
PREPROCESSORS_INDEPENDENT_SAMPLES = [
    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,