Ejemplo n.º 1
0
lspectra = [
    X[0],
]
llabels = [
    "Initial",
]
for i, length in enumerate([5, 11, 27, 51, 101, 201, 501]):
    s = X[0].smooth(window_length=length)  # smooth
    s += 0.1 * (
        1 + i
    )  # shift the absorbance by +0.1 a.u. with respect to previous iteration
    lspectra.append(s)
    llabels.append(f"length: {length}")

ax = scp.plot_multiple(
    figsize=(7, 6), method="pen", datasets=lspectra, labels=llabels, legend="upper left"
)

# %% The above spectra clearly show that as that the width of the window increases, the peaks belonging to [markdown]
# The spectrum is flattened out and distorted. When determining the optimum window length, one should thus consider
# the balance between noise removal and signal integrity: the larger the window length, the stronger the smoothing,
# but also the greater the chance to distort the spectrum.
#
# ### Window function
#
# Besides the window `length` (default=11 points), the user can also choose the type of
# window (`window`) from `flat`, `hanning` (i.e. Hann window), `hamming`, `bartlett` or `blackman`.  The `flat`
# window - which is the default shown above - should be fine for the vast majority of cases.
#
# The code below compares the effect of the type of window:
Ejemplo n.º 2
0
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

# %%
scp.plot_multiple(method='scatter',
                  ms=5,
                  datasets=[inttrapz, intsimps],
                  labels=['trapzoidal rule', 'simpson\' rule'],
                  legend='best')

# %% [markdown]
# The difference between the trapezoidal and simpson integration methods is visualized below. In this case they are
# extremly close.

# %%
diff = ((inttrapz - intsimps) * 100. / intsimps)
diff.title = 'difference'
diff.units = 'percent'
diff.plot(scatter=True, ms=5)
Ejemplo n.º 3
0
_ = ds2.plot_stack(ax=ax1, clear=False, zlim=(-2.5, 4))

# %% [markdown]
# For 1D datasets only, you can also use the `plot_multiple`method:

# %%
datasets = [dataset[0], dataset[10], dataset[20], dataset[50], dataset[53]]
labels = [
    "sample {}".format(label) for label in ["S1", "S10", "S20", "S50", "S53"]
]
prefs.reset()
prefs.axes.facecolor = ".99"
prefs.axes.grid = True
_ = scp.plot_multiple(method="scatter",
                      me=10,
                      datasets=datasets,
                      labels=labels,
                      legend="best")

# %% [markdown]
# ## Overview of the main configuration parameters

# %% [markdown]
# To display a dictionary of the current settings (**compared to those set by default**
# at API startup), you can simply type :

# %%
prefs

# %% [markdown]
# **Warning**: Note that with respect to matplotlib,the parameters in the `dataset.preferences` dictionary
Ejemplo n.º 4
0
########################################################################################################################
# check that style reinit to default
# should be identical to the first
ax = dataset[0].plot()

########################################################################################################################
# Multiple plots
dataset = dataset[:, ::100]

datasets = [dataset[0], dataset[10], dataset[20], dataset[50], dataset[53]]
labels = [
    "sample {}".format(label) for label in ["S1", "S10", "S20", "S50", "S53"]
]

scp.plot_multiple(method="scatter",
                  datasets=datasets,
                  labels=labels,
                  legend="best")

########################################################################################################################
# plot multiple with style
scp.plot_multiple(method="scatter",
                  style="sans",
                  datasets=datasets,
                  labels=labels,
                  legend="best")

########################################################################################################################
# check that style reinit to default
scp.plot_multiple(method="scatter",
                  datasets=datasets,
                  labels=labels,
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

# %%
scp.plot_multiple(
    method="scatter",
    ms=5,
    datasets=[inttrapz, intsimps],
    labels=["trapzoidal rule", "simpson' rule"],
    legend="best",
)

# %% [markdown]
# The difference between the trapezoidal and simpson integration methods is visualized below. In this case they are
# extremely close.

# %%
diff = (inttrapz - intsimps) * 100.0 / intsimps
diff.title = "difference"
diff.units = "percent"
diff.plot(scatter=True, ms=5)
Ejemplo n.º 6
0
########################################################################################################################
# check that style reinit to default
# should be identical to the first
ax = dataset[0].plot()

########################################################################################################################
# Multiple plots
dataset = dataset[:, ::100]

datasets = [dataset[0], dataset[10], dataset[20], dataset[50], dataset[53]]
labels = [
    'sample {}'.format(label) for label in ["S1", "S10", "S20", "S50", "S53"]
]

scp.plot_multiple(method='scatter',
                  datasets=datasets,
                  labels=labels,
                  legend='best')

########################################################################################################################
# plot mupltiple with style
scp.plot_multiple(method='scatter',
                  style='sans',
                  datasets=datasets,
                  labels=labels,
                  legend='best')

########################################################################################################################
# check that style reinit to default
scp.plot_multiple(method='scatter',
                  datasets=datasets,
                  labels=labels,