Пример #1
0
def test_Gaussian_class():
    # direct initialization
    a = apo.Gaussian(FWHM="200 km/s", dim_index=0, dv_index=0)

    assert a.FWHM == 200
    assert a.property_units == {"FWHM": "km / s"}
    assert a.dim_index == 0
    assert a.dv_index == 0

    # class to dict with units
    dict_ = a.json()

    assert dict_ == {
        "function": "apodization",
        "type": "Gaussian",
        "FWHM": "200.0 km / s",
        "dim_index": 0,
        "dv_index": 0,
    }

    # read from dictionary
    b = apo.Gaussian.parse_dict_with_units(dict_)

    assert a == b
Пример #2
0
# **Step 5:** Simulate the spectrum.
sim.run()

# The plot of the simulation before signal processing.
ax = plt.subplot(projection="csdm")
ax.plot(sim.methods[0].simulation.real, color="black", linewidth=1)
ax.invert_xaxis()
plt.tight_layout()
plt.show()

# %%
# **Step 6:** Add post-simulation signal processing.
processor = sp.SignalProcessor(operations=[
    sp.IFFT(),
    apo.Exponential(FWHM="30 Hz"),
    apo.Gaussian(FWHM="145 Hz"),
    sp.FFT(),
])
processed_data = processor.apply_operations(data=sim.methods[0].simulation)

# The plot of the simulation after signal processing.
ax = plt.subplot(projection="csdm")
ax.plot(processed_data.real, color="black", linewidth=1)
ax.invert_xaxis()
plt.tight_layout()
plt.show()

# %%
# .. [#f1] Grandinetti, P. J., Baltisberger, J. H., Farnan, I., Stebbins, J. F.,
#       Werner, U. and Pines, A.
#       Solid-State :math:`^{17}\text{O}` Magic-Angle and Dynamic-Angle Spinning NMR
Пример #3
0
)

# %%
# Create the Simulator object, add the method and spin system objects, and run the
# simulation.
sim = Simulator()
sim.spin_systems = spin_systems  # add the spin systems
sim.methods = [maf]  # add the method
sim.run()

# %%
# Add post-simulation signal processing.
csdm_data = sim.methods[0].simulation
processor = sp.SignalProcessor(operations=[
    sp.IFFT(dim_index=(0, 1)),
    apo.Gaussian(FWHM="50 Hz", dim_index=0),
    apo.Gaussian(FWHM="50 Hz", dim_index=1),
    sp.FFT(dim_index=(0, 1)),
])
processed_data = processor.apply_operations(data=csdm_data).real
processed_data /= processed_data.max()

# %%
# The plot of the simulation after signal processing.
ax = plt.subplot(projection="csdm")
cb = ax.imshow(processed_data.T, aspect="auto", cmap="gist_ncar_r")
plt.colorbar(cb)
ax.invert_xaxis()
ax.invert_yaxis()
plt.tight_layout()
plt.show()
Пример #4
0
data = sim.methods[0].simulation
ax = plt.subplot(projection="csdm")
cb = ax.imshow(data / data.max(), aspect="auto", cmap="gist_ncar_r")
plt.colorbar(cb)
ax.invert_xaxis()
ax.invert_yaxis()
plt.tight_layout()
plt.show()

# %%
# Add post-simulation signal processing.
processor = sp.SignalProcessor(
    operations=[
        # Gaussian convolution along both dimensions.
        sp.IFFT(dim_index=(0, 1)),
        apo.Gaussian(FWHM="0.3 kHz", dim_index=0),
        apo.Gaussian(FWHM="0.15 kHz", dim_index=1),
        sp.FFT(dim_index=(0, 1)),
    ]
)
processed_data = processor.apply_operations(data=data)
processed_data /= processed_data.max()

# %%
# The plot of the simulation after signal processing.
ax = plt.subplot(projection="csdm")
cb = ax.imshow(processed_data.real, cmap="gist_ncar_r", aspect="auto")
plt.colorbar(cb)
ax.invert_xaxis()
ax.invert_yaxis()
plt.tight_layout()
Пример #5
0
# The plot of the simulation.
data = sim.methods[0].simulation
ax = plt.gca(projection="csdm")
cb = ax.imshow(data / data.max(), aspect="auto", cmap="gist_ncar_r")
plt.colorbar(cb)
ax.invert_xaxis()
ax.invert_yaxis()
plt.tight_layout()
plt.show()

# %%
# Add post-simulation signal processing.
processor = sp.SignalProcessor(operations=[
    # Gaussian convolution along both dimensions.
    sp.IFFT(dim_index=(0, 1)),
    apo.Gaussian(FWHM="0.08 kHz", dim_index=0),
    apo.Gaussian(FWHM="0.22 kHz", dim_index=1),
    sp.FFT(dim_index=(0, 1)),
])
processed_data = processor.apply_operations(data=sim.methods[0].simulation)
processed_data /= processed_data.max()

# %%
# The plot of the simulation after signal processing.
ax = plt.subplot(projection="csdm")
cb = ax.imshow(processed_data.real, cmap="gist_ncar_r", aspect="auto")
plt.colorbar(cb)
ax.set_ylim(-40, -70)
ax.set_xlim(-20, -60)
plt.tight_layout()
plt.show()
Пример #6
0
        "reference_offset": 0
    }],
)

PS_0 = [sp.Scale(factor=10)]

PS_1 = [
    sp.IFFT(dim_index=0),
    apo.Exponential(FWHM="200 Hz", dim_index=0, dv_index=0),
    sp.FFT(dim_index=0),
]

sigma = 20 * 2.354820045030949
PS_2 = [
    sp.IFFT(dim_index=0),
    apo.Gaussian(FWHM=f"{sigma} Hz", dim_index=0, dv_index=[0, 1]),
    sp.FFT(dim_index=0),
]

PS_3 = [
    sp.IFFT(dim_index=0),
    apo.Gaussian(FWHM=f"{sigma} Hz", dim_index=0, dv_index=None),
    sp.FFT(dim_index=0),
]

sim.methods += [method_1]
sim.run()

freqHz = sim.methods[0].spectral_dimensions[0].coordinates_Hz()