Пример #1
0
def test_issue_227():
    # IR spectrum, we want to make a baseline correction on the absorbance vs. time axis:
    ir = scp.read("irdata/nh4y-activation.spg")

    # baseline correction along x
    blc = scp.BaselineCorrection(ir)
    s1 = blc([5999.0, 3500.0], [1800.0, 1500.0],
             method="multivariate",
             interpolation="pchip")

    # baseline correction the transposed data along x (now on axis 0) -> should produce the same results
    # baseline correction along axis -1 previuosly
    blc = scp.BaselineCorrection(ir.T)
    s2 = blc(
        [5999.0, 3500.0],
        [1800.0, 1500.0],
        dim="x",
        method="multivariate",
        interpolation="pchip",
    )

    # compare
    assert_dataset_equal(s1, s2.T)

    ir.y = ir.y - ir[0].y
    irs = ir[:, 2000.0:2020.0]
    blc = scp.BaselineCorrection(irs)
    blc.compute(*[[0.0, 2.0e3], [3.0e4, 3.3e4]],
                dim="y",
                interpolation="polynomial",
                order=1,
                method="sequential")
    blc.corrected.plot()

    # MS profiles, we want to make a baseline correction on the ion current vs. time axis:
    ms = scp.read("msdata/ion_currents.asc", timestamp=False)
    blc = scp.BaselineCorrection(ms[10.0:20.0, :])
    blc.compute(*[[10.0, 11.0], [19.0, 20.0]],
                dim="y",
                interpolation="polynomial",
                order=1,
                method="sequential")
    blc.corrected.T.plot()

    show()
Пример #2
0
# We just give here few examples

# %% [markdown] slideshow={"slide_type": "subslide"}
# #### Smoothing

# %% slideshow={"slide_type": "fragment"}
smoothed = region.smooth(window_length=51, window='hanning')
_ = smoothed.plot(colormap='magma')

# %% [markdown] slideshow={"slide_type": "subslide"}
# #### Baseline correction

# %% slideshow={"slide_type": "fragment"}
region = ds[:, 4000.0:2000.0]
smoothed = region.smooth(window_length=51, window='hanning')
blc = scp.BaselineCorrection(smoothed)
basc = blc.compute([2000., 2300.], [3800., 3900.], method='multivariate', interpolation='pchip', npc=5)
_ = basc.plot()

# %% [markdown] slideshow={"slide_type": "subslide"}
# ## IRIS processing

# %% slideshow={"slide_type": "subslide"}
ds = scp.read('irdata/CO@Mo_Al2O3.SPG')[:, 2250.:1950.]
pressure = [0.00300, 0.00400, 0.00900, 0.01400, 0.02100, 0.02600, 0.03600,
            0.05100, 0.09300, 0.15000, 0.20300, 0.30000, 0.40400, 0.50300,
            0.60200, 0.70200, 0.80100, 0.90500, 1.00400]
ds.y = scp.Coord(pressure, title='Pressure', units='torr')
_ = ds.plot(colormap='magma')

# %% slideshow={"slide_type": "subslide"}
Пример #3
0
# %% [markdown]
# We set some plotting preferences and then plot the raw data

# %%
prefs = X.preferences
prefs.figure.figsize = (6, 3)
prefs.colormap = 'Dark2'
prefs.colorbar = True
X.plot()

# %% [markdown]
# Now we can perform some baseline correction

# %%
blc = scp.BaselineCorrection(X)
regions = ([1740., 1800.0], [1550., 1570.], [1250., 1300.]
           )  # define 3 regions where we want the baseline to reach zero.
Xcorr = blc.compute(*regions)  # compute the corrected NDDataset

Xcorr.plot()

# %% [markdown]
# To integrate each row on the full range, we can use the sum or trapz method of a NDDataset.

# %%
inttrapz = Xcorr.trapz(dim='x')
intsimps = Xcorr.simps(dim='x')

# %% [markdown]
# As you can see both method give almost the same results in this case
###############################################################################
# Load data:

nd = scp.NDDataset.read_omnic('irdata/nh4y-activation.spg')

###############################################################################
# Do some slicing to keep only the interesting region:

ndp = (nd - nd[-1])[:, 1291.0:5999.0]
# Important:  notice that we use floating point number
# integer would mean points, not wavenumbers!

###############################################################################
# Define the BaselineCorrection object:

ibc = scp.BaselineCorrection(ndp)

###############################################################################
# Launch the interactive view, using the `BaselineCorrection.run` method:

ranges = [[1556.30, 1568.26], [1795.00, 1956.75], [3766.03, 3915.81],
          [4574.26, 4616.04], [4980.10, 4998.01],
          [5437.52, 5994.70]]  # predefined ranges
span = ibc.run(*ranges,
               method='multivariate',
               interpolation='pchip',
               npc=5,
               zoompreview=3)

###############################################################################
# Print the corrected dataset: