Exemplo n.º 1
0
def assertion(csdm, res, test_ref=""):
    assert get_spectral_dimensions(csdm)[0] == res, f"failed ref {test_ref}"

    csdm_coordinates = csdm.x[0].coordinates.to("Hz").value
    if csdm.x[0].increment < 0:
        csdm_coordinates = csdm_coordinates[::-1]
    spectral_dimension = SpectralDimension(**res)
    mrsim_coordinates = spectral_dimension.coordinates_Hz()
    assert np.allclose(csdm_coordinates,
                       mrsim_coordinates), f"failed ref {test_ref}"
Exemplo n.º 2
0
def test_get_spectral_dimensions():
    # 1
    csdm = cp.as_csdm(np.arange(10))
    csdm.dimensions[0] = cp.LinearDimension(count=10,
                                            increment="1 Hz",
                                            complex_fft=True)

    res = {"count": 10, "spectral_width": 10, "reference_offset": 0}
    assert get_spectral_dimensions(csdm)[0] == res

    # 2
    csdm.dimensions[0] = cp.LinearDimension(count=10,
                                            increment="1 Hz",
                                            coordinates_offset="-0.05 kHz",
                                            complex_fft=True)

    res = {"count": 10, "spectral_width": 10, "reference_offset": -50}
    assert get_spectral_dimensions(csdm)[0] == res

    # 3
    csdm.dimensions[0] = cp.LinearDimension(count=10, increment="1 Hz")

    res = {"count": 10, "spectral_width": 10, "reference_offset": 5}
    assert get_spectral_dimensions(csdm)[0] == res

    # 4
    csdm.dimensions[0] = cp.LinearDimension(count=10,
                                            increment="1 Hz",
                                            label="1H")

    res = {
        "count": 10,
        "spectral_width": 10,
        "reference_offset": 5,
        "label": "1H"
    }
    assert get_spectral_dimensions(csdm)[0] == res
Exemplo n.º 3
0
# %%
# Create a fitting model
# ----------------------
# **Spin System**
B11 = Site(
    isotope="11B",
    isotropic_chemical_shift=20.0,  # in ppm
    quadrupolar=SymmetricTensor(Cq=2.3e6, eta=0.03),  # Cq in Hz
)
spin_systems = [SpinSystem(sites=[B11])]

# %%
# **Method**

# Get the spectral dimension parameters from the experiment.
spectral_dims = get_spectral_dimensions(experiment)

MAS_CT = BlochDecayCTSpectrum(
    channels=["11B"],
    magnetic_flux_density=14.1,  # in T
    rotor_frequency=12500,  # in Hz
    spectral_dimensions=spectral_dims,
    experiment=experiment,  # add the measurement to the method.
)

# Optimize the script by pre-setting the transition pathways for each spin system from
# the method.
for sys in spin_systems:
    sys.transition_pathways = MAS_CT.get_transition_pathways(sys)

# %%
    isotope="13C",
    isotropic_chemical_shift=0,  #
    shielding_symmetric={
        "zeta": -70,
        "eta": 0.8
    },
)
spin_systems = [SpinSystem(sites=[site])]

# %%
# **Method**
#
# For the sideband-only cross-section, use the BlochDecaySpectrum method.

# Get the dimension information from the experiment.
spectral_dims = get_spectral_dimensions(pass_cross_section)

PASS = BlochDecaySpectrum(
    channels=["13C"],
    magnetic_flux_density=9.395,  # in T
    rotor_frequency=1500,  # in Hz
    spectral_dimensions=spectral_dims,
    experiment=pass_cross_section,  # also add the measurement to the method.
)

# Optimize the script by pre-setting the transition pathways for each spin system from
# the method.
for sys in spin_systems:
    sys.transition_pathways = PASS.get_transition_pathways(sys)

# %%
Exemplo n.º 5
0
eta = [0.8, 0.4, 0.9, 0.3, 0.0, 0.0]

spin_systems = single_site_system_generator(
    isotope="13C",
    isotropic_chemical_shift=shifts,
    shielding_symmetric={"zeta": zeta, "eta": eta},
    abundance=100 / 6,
)

# %%
# **Method**
#
# Create the SSB2D method.

# Get the spectral dimension parameters from the experiment.
spectral_dims = get_spectral_dimensions(mat_dataset)

PASS = SSB2D(
    channels=["13C"],
    magnetic_flux_density=9.395,  # in T
    rotor_frequency=1500,  # in Hz
    spectral_dimensions=spectral_dims,
    experiment=mat_dataset,  # add the measurement to the method.
)

# Optimize the script by pre-setting the transition pathways for each spin system from
# the method.
for sys in spin_systems:
    sys.transition_pathways = PASS.get_transition_pathways(sys)

# %%
    shielding_symmetric=SymmetricTensor(zeta=30, eta=0.5),  # zeta in Hz
)

spin_systems = [
    SpinSystem(sites=[C1], name="C1"),
    SpinSystem(sites=[C2], name="C2")
]

# %%
# **Method**: Create the three MAS method objects with respective MAS spinning speeds.

# Get the spectral dimension parameters from the respective experiment and setup the
# corresponding method.

# Method for dataset 1
spectral_dims1 = get_spectral_dimensions(experiment1)
MAS1 = BlochDecaySpectrum(
    channels=["13C"],
    magnetic_flux_density=7.05,  # in T
    rotor_frequency=5000,  # in Hz
    spectral_dimensions=spectral_dims1,
    experiment=experiment1,  # add experimental dataset 1
)

# Method for dataset 2
spectral_dims2 = get_spectral_dimensions(experiment2)
MAS2 = BlochDecaySpectrum(
    channels=["13C"],
    magnetic_flux_density=7.05,  # in T
    rotor_frequency=1940,  # in Hz
    spectral_dimensions=spectral_dims2,
Exemplo n.º 7
0
)
Rb_2 = Site(
    isotope="87Rb",
    isotropic_chemical_shift=40,  # in ppm
    quadrupolar=SymmetricTensor(Cq=2.2e6, eta=0.95),  # Cq in Hz
)

spin_systems = [SpinSystem(sites=[s]) for s in [Rb_1, Rb_2]]

# %%
# **Method**
#
# Create the SSB2D method.

# Get the spectral dimension parameters from the experiment.
spectral_dims = get_spectral_dimensions(qmat_data)

PASS = SSB2D(
    channels=["87Rb"],
    magnetic_flux_density=9.395,  # in T
    rotor_frequency=2604,  # in Hz
    spectral_dimensions=spectral_dims,
    experiment=qmat_data,  # add the measurement to the method.
)

# Optimize the script by pre-setting the transition pathways for each spin system from
# the method.
for sys in spin_systems:
    sys.transition_pathways = PASS.get_transition_pathways(sys)

# %%
Exemplo n.º 8
0
def add_measurement_to_a_method():
    """Add a measurement to the selected method."""
    existing_data = ctx.states["local-mrsim-data.data"]
    existing_data["trigger"] = {
        "simulation": False,
        "internal_processor": False,
    }

    trigger_id = ctx.triggered[0]["prop_id"].split(".")[0]
    contents = ctx.inputs[f"{trigger_id}.contents"]
    content_string = contents.split(",")[1]
    decoded = base64.b64decode(content_string)
    success, exp_data, error_message = load_csdm(decoded)

    if not success:
        return sim_utils.on_fail_message(f"FileLoadError: {error_message}")

    index = ctx.states["select-method.value"]
    method = existing_data["methods"][index]
    method["experiment"] = exp_data.to_dict()
    spectral_dim = method["spectral_dimensions"]

    mrsim_spectral_dims = get_spectral_dimensions(exp_data, units=True)

    for i, dim in enumerate(mrsim_spectral_dims):
        spectral_dim[i].update(dim)

    method_overview = method_UI.refresh(existing_data["methods"])

    post_sim_overview = no_update
    if existing_data["signal_processors"][index] in [None, {"operations": []}]:
        vector = exp_data.y[0].components[0].real
        increment = exp_data.x[0].increment.value
        amp = vector.sum()
        existing_data["signal_processors"][index]["operations"] = [
            {
                "dim_index": [0],
                "function": "IFFT"
            },
            {
                "dim_index": [0],
                "FWHM": f"{abs(3*increment)} Hz",
                "function": "apodization",
                "type": "Exponential",
            },
            {
                "dim_index": [0],
                "function": "FFT"
            },
            {
                "factor": abs(amp) / 30,
                "function": "Scale"
            },
        ]
        post_sim_overview = post_sim_UI.refresh(existing_data)

    out = {
        "alert": ["", False],
        "mrsim": [existing_data, no_update],
        "children": [no_update, method_overview, no_update],
        "mrsim_config": [no_update] * 4,
        "processor": [post_sim_overview],
    }
    return sim_utils.expand_output(out)
Exemplo n.º 9
0
        "zeta": -70,
        "eta": 0.8
    },
)
spin_systems = [SpinSystem(sites=[site])]

# %%
# **Method**
#
# For the sideband only cross-section, use the BlochDecaySpectrum method.

# Get the dimension information from the experiment. Note, the following function
# returns an array of two spectral dimensions corresponding to the 2D PASS dimensions.
# Use the spectral dimension that is along the anisotropic dimensions for the
# BlochDecaySpectrum method.
spectral_dims = get_spectral_dimensions(pass_data)
method = BlochDecaySpectrum(
    channels=["13C"],
    magnetic_flux_density=9.4,  # in T
    rotor_frequency=1500,  # in Hz
    spectral_dimensions=[spectral_dims[0]],
    experiment=data1D,  # also add the measurement to the method.
)

# Optimize the script by pre-setting the transition pathways for each spin system from
# the method.
for sys in spin_systems:
    sys.transition_pathways = method.get_transition_pathways(sys)

# %%
# **Guess Spectrum**