Esempio n. 1
0
def test_methods():
    das = Method2D(
        channels=["87Rb"],
        magnetic_flux_density=4.2,  # in T
        rotor_angle=54.735 * 3.14159 / 180,  # in rads
        spectral_dimensions=[
            {
                "count":
                256,
                "spectral_width":
                2e4,  # in Hz
                "reference_offset":
                -5e3,  # in Hz
                "label":
                "70.12 dimension",
                "events": [
                    {
                        "fraction": 0.5,
                        "rotor_angle": 70.12 * 3.14159 / 180,  # in rads
                        "transition_query": [{
                            "ch1": {
                                "P": [-1],
                                "D": [0]
                            }
                        }],
                    },
                    {
                        "fraction": 0.5,
                        "rotor_angle": 30.12 * 3.14159 / 180,  # in rads
                        "transition_query": [{
                            "ch1": {
                                "P": [-1],
                                "D": [0]
                            }
                        }],
                    },
                ],
            },
            # The last spectral dimension block is the direct-dimension
            {
                "count": 256,
                "spectral_width": 3e4,  # in Hz
                "reference_offset": -7e3,  # in Hz
                "label": "MAS dimension",
                "events": [{
                    "transition_query": [{
                        "ch1": {
                            "P": [-1],
                            "D": [0]
                        }
                    }]
                }],
            },
        ],
    )

    assert das.affine_matrix is None
    assert das.json() == TESTDATA["DAS"]
    assert Method.parse_dict_with_units(das.json()) == das
    assert Method2D.parse_dict_with_units(das.json()) == das
Esempio n. 2
0
def test_04():
    """SAS method declaration"""
    mth = Method2D(
        channels=["87Rb"],
        magnetic_flux_density=9.4,  # in T
        rotor_angle=70.12 * np.pi / 180,
        spectral_dimensions=[
            {
                "count": 512,
                "spectral_width": 5e4,  # in Hz
                "events": [
                    {
                        "transition_query": {
                            "P": [-1],
                            "D": [0]
                        }
                    },
                ],
            },
            MAS_DIM.copy(),
        ],
    )

    assert mth.json() == TESTDATA["SAS"]
    assert Method.parse_dict_with_units(mth.json()) == mth
    assert Method2D.parse_dict_with_units(mth.json()) == mth
Esempio n. 3
0
def test_05():
    """Satellite to central correlation method declaration"""
    sp0 = dict(
        count=512,
        spectral_width=5e6,
        events=[{
            "rotor_angle":
            0 * np.pi / 180,
            "transition_query": [{
                "P": [-1],
                "D": [2]
            }, {
                "P": [-1],
                "D": [-2]
            }],
        }],
    )
    mth = Method2D(
        channels=["87Rb"],
        magnetic_flux_density=9.4,  # in T
        spectral_dimensions=[sp0, MAS_DIM.copy()],
    )

    assert mth.json() == TESTDATA["STMAS"]
    assert Method.parse_dict_with_units(TESTDATA["STMAS"]) == mth
    assert Method2D.parse_dict_with_units(TESTDATA["STMAS"]) == mth
Esempio n. 4
0
def test_method_2D():

    error = "The first element of the affine matrix cannot be zero."
    with pytest.raises(ValueError, match=f".*{error}.*"):
        Method2D(spectral_dimensions=[{}, {}], affine_matrix=[0, 1, 2, 3])

    # parse dict with units test
    dict_1d = {
        "channels": ["87Rb"],
        "magnetic_flux_density":
        "7 T",  # in T
        "rotor_angle":
        "54.735 deg",
        "spectral_dimensions": [
            {
                "spectral_width": "10 kHz",
                **sample_test_output
            },
            {
                "spectral_width": "10 kHz",
                **sample_test_output
            },
        ],
    }
    method1a = Method2D.parse_dict_with_units(dict_1d)
    assert Method.parse_dict_with_units(method1a.json()) == method1a

    method1b = Method2D(
        channels=["87Rb"],
        magnetic_flux_density=7,  # in T
        rotor_angle=54.735 * np.pi / 180,
        spectral_dimensions=[
            {
                "spectral_width": 1e4,
                **sample_test_output
            },
            {
                "spectral_width": 1e4,
                **sample_test_output
            },
        ],
    )

    assert method1a == method1b