def test_summary(): all_defined_no_constant_spec_dims = [ { "events": [ { "label": "Mix0", "query": { "ch1": { "angle": np.pi / 4, "phase": np.pi / 2 } }, }, { "label": "Dur0", "duration": 1, "magnetic_flux_density": 1, "rotor_frequency": 0, # in kHz "rotor_angle": 0.1, "transition_queries": [{ "ch1": { "P": [0], "D": [0] } }], }, { "label": "Spec0", "fraction": 1, "magnetic_flux_density": 2, "rotor_frequency": 20000, "rotor_angle": 0.2, "transition_queries": [{ "ch1": { "P": [1], "D": [-2] } }], }, ] }, { "events": [ { "label": "Mix1", "query": { "ch1": { "angle": np.pi / 2, "phase": np.pi } }, }, { "label": "Dur1", "duration": 2, "magnetic_flux_density": 3, "rotor_frequency": 0, "rotor_angle": 0.3, "transition_queries": [{ "ch1": { "P": [3], "D": [-4] } }], }, { "label": "Spec1", "fraction": 1, "magnetic_flux_density": 4, "rotor_frequency": 0, "rotor_angle": 0.4, "transition_queries": [{ "ch1": { "P": [4], "D": [-6] } }], }, ] }, ] const_mfd_rotor_ang_spec_dims = [ { "events": [ { "label": "Mix0", "query": { "ch1": { "angle": np.pi / 2, "phase": np.pi } }, }, { "label": "Dur0", "duration": 1, "rotor_frequency": 0, "rotor_angle": 0.5, "transition_queries": [{ "ch1": { "P": [0], "D": [0] } }], }, { "label": "Spec0", "fraction": 1, "rotor_frequency": 20000, "rotor_angle": 0.5, "transition_queries": [{ "ch1": { "P": [1], "D": [0] } }], }, ] }, { "events": [ { "label": "Mix1", "query": { "ch1": { "angle": np.pi / 2, "phase": np.pi } }, }, { "label": "Dur1", "duration": 2, "rotor_frequency": 0, "rotor_angle": 0.5, "transition_queries": [{ "ch1": { "P": [3], "D": [0] } }], }, { "label": "Spec1", "fraction": 1, "rotor_frequency": 0, "rotor_angle": 0.5, "transition_queries": [{ "ch1": { "P": [4], "D": [0] } }], }, ] }, ] method1 = Method( name="test-method-1", channels=["1H", "13C"], spectral_dimensions=all_defined_no_constant_spec_dims, ) # Constant 'magnetic_flux_density' and 'rotor_frequency' method2 = Method( name="test-method-2", channels=["1H", "13C"], spectral_dimensions=const_mfd_rotor_ang_spec_dims, ) assert method1.name == "test-method-1" assert len(method1.spectral_dimensions) == 2 basic_summary_tests(method1) assert method2.name == "test-method-2" assert len(method2.spectral_dimensions) == 2 args_summary_tests(method2) assert isinstance(method2.plot(), Figure)
SpectralEvent(transition_queries=[ { "ch1": { "P": [-1], "D": [2] } }, # inner satellite ]) ], ) ], ) # A graphical representation of the method object. plt.figure(figsize=(4, 2.5)) method.plot() plt.show() # %% # Create the Simulator object and add the method and the spin system object. sim = Simulator(spin_systems=[spin_system], methods=[method]) sim.run() # The plot of the simulation before signal processing. plt.figure(figsize=(4.25, 3.0)) ax = plt.subplot(projection="csdm") ax.plot(sim.methods[0].simulation.real, color="black", linewidth=1) ax.invert_xaxis() plt.tight_layout() plt.show()
reference_offset=-1.05e4, # in Hz label="Isotropic dimension", events=[ SpectralEvent( rotor_angle=54.735 * np.pi / 180, # in rads transition_queries=[{"ch1": {"P": [-1], "D": [0]}}], ) ], ), ], affine_matrix=[[1, -1], [0, 1]], ) # A graphical representation of the method object. plt.figure(figsize=(5, 2.5)) maf.plot() plt.show() # %% # Create the Simulator object, add the method and spin system objects, and run the # simulation. sim = Simulator(spin_systems=spin_systems, methods=[maf]) sim.run() # %% # Add post-simulation signal processing. csdm_dataset = sim.methods[0].simulation processor = sp.SignalProcessor( operations=[ sp.IFFT(dim_index=(0, 1)), sp.apodization.Gaussian(FWHM="50 Hz", dim_index=0),
# :math:`p=0`. A similar argument holds for ``[-1]`` query. By implementing query # objects, we decouple the method from the spin system, i.e., once a method is defined, # it can be used to simulate spectra from any given spin system. We will demonstrate # this momentarily by simulating a Hahn echo spectrum from single and two-site spin # systems. # # Besides the SpectralEvent, you may also notice a MixingEvent sandwiched in-between # the two SpectralEvent. A MixingEvent does not directly contribute to the frequencies. # As the name suggests, a mixing event is used for the mixing of transitions in a # multi-event method such as HahnEcho. In the above code, we define a mixing query # on channel-1 by setting the attributes ``angle`` and ``phase`` to :math:`\pi` and # 0, respectively. There two parameters are analogous to the pulse angle and phase. # %% plt.figure(figsize=(4, 2)) hahn_echo.plot() plt.show() # %% # As mentioned before, a method object is decoupled from the spin system object. Notice, # when we get the transition pathways from this method for a single-site spin system, we # get a single transition pathway. pprint(hahn_echo.get_transition_pathways(spin_system_1)) # %% # In the case of a homonuclear two-site spin 1/2 spin system, the same method returns # four transition pathways. pprint(hahn_echo.get_transition_pathways(spin_system_2)) # %% # Create the Simulator object, add the method and spin system objects, and run the
events=[ SpectralEvent(transition_queries=[{ "ch1": { "P": [-1], "D": [0] } }]) ], ), ], affine_matrix=[[1, 0], [1 / 4, 3 / 4]], ) # A graphical representation of the method object. plt.figure(figsize=(5, 2.75)) coaster.plot() plt.show() # %% # Create the Simulator object, add the method and spin system objects, and # run the simulation. sim = Simulator(spin_systems=[spin_system], methods=[coaster]) # configure the simulator object. For non-coincidental tensors, set the value of the # `integration_volume` attribute to `hemisphere`. sim.config.integration_volume = "hemisphere" sim.run() # %% # The plot of the simulation. dataset = sim.methods[0].simulation
rotor_angle=54.74 * np.pi / 180, # in radians transition_queries=[{ "ch1": { "P": [-1], "D": [0] } }], ) ], ), ], ) # A graphical representation of the method object. plt.figure(figsize=(5, 2.5)) sas.plot() plt.show() # %% # Create the Simulator object, add the method and spin system objects, and # run the simulation. sim = Simulator(spin_systems=spin_systems, methods=[sas]) sim.run() # %% # The plot of the simulation. dataset = sim.methods[0].simulation plt.figure(figsize=(4.25, 3.0)) ax = plt.subplot(projection="csdm") cb = ax.imshow(dataset.real / dataset.real.max(),
reference_offset=0, # in Hz label="MAS dimension", events=[ SpectralEvent( rotor_angle=54.735 * np.pi / 180, # in rads transition_queries=[{"ch1": {"P": [-1], "D": [0]}}], ) ], ), ], ) sim.methods = [das] # add the method # A graphical representation of the method object. plt.figure(figsize=(5, 2.5)) das.plot() plt.show() # %% # Run the simulation sim.run() # %% # The plot of the simulation. dataset = sim.methods[0].simulation plt.figure(figsize=(4.25, 3.0)) ax = plt.subplot(projection="csdm") cb = ax.imshow(dataset.real / dataset.real.max(), aspect="auto", cmap="gist_ncar_r") plt.colorbar(cb) ax.invert_xaxis()
spectral_width=2e5, # in Hz reference_offset=2e4, # in Hz label="Paramagnetic shift", events=[ SpectralEvent( transition_queries=[{"ch1": {"P": [-1]}}], freq_contrib=["Shielding1_0", "Shielding1_2"], ) ], ), ], ) # A graphical representation of the method object. plt.figure(figsize=(4, 1.5)) shifting_d.plot() plt.show() # %% # Create the Simulator object, add the method and spin system objects, and # run the simulation. sim = Simulator(spin_systems=spin_systems, methods=[shifting_d]) # Configure the simulator object. For non-coincidental tensors, set the value of the # `integration_volume` attribute to `hemisphere`. sim.config.integration_volume = "hemisphere" sim.config.decompose_spectrum = "spin_system" # simulate spectra per spin system sim.run() # %% # Add post-simulation signal processing. dataset = sim.methods[0].simulation