Example #1
0
def test_MAF_lineshape_kernel():
    for dim in anisotropic_dims:
        ns_obj = ShieldingPALineshape(
            anisotropic_dimension=dim,
            inverse_dimension=inverse_dimension,
            channel="29Si",
            magnetic_flux_density="9.4 T",
            rotor_angle="90 deg",
            rotor_frequency="14 kHz",
            number_of_sidebands=1,
        )
        zeta, eta = ns_obj._get_zeta_eta(supersampling=1)
        K = ns_obj.kernel(supersampling=1)
        sim_lineshape = generate_shielding_kernel(zeta, eta, np.pi / 2, 14000,
                                                  1).T
        assert np.allclose(K, sim_lineshape, rtol=1.0e-3, atol=1e-3)

        ns_obj = MAF(
            anisotropic_dimension=dim,
            inverse_dimension=inverse_dimension,
            channel="29Si",
            magnetic_flux_density="9.4 T",
        )
        zeta, eta = ns_obj._get_zeta_eta(supersampling=1)
        K = ns_obj.kernel(supersampling=1)
        sim_lineshape = generate_shielding_kernel(zeta, eta, np.pi / 2, 14000,
                                                  1).T

        assert np.allclose(K, sim_lineshape, rtol=1.0e-3, atol=1e-3)

        _ = TSVDCompression(K, s=np.arange(96))
        assert _.truncation_index == 15
Example #2
0
def test_spinning_sidebands_kernel():
    # 1
    for dim in anisotropic_dims:
        ns_obj = ShieldingPALineshape(
            anisotropic_dimension=dim,
            inverse_dimension=inverse_dimension,
            channel="29Si",
            magnetic_flux_density="9.4 T",
            rotor_angle="54.735 deg",
            rotor_frequency="100 Hz",
            number_of_sidebands=96,
        )
        zeta, eta = ns_obj._get_zeta_eta(supersampling=1)
        K = ns_obj.kernel(supersampling=1)
        sim_lineshape = generate_shielding_kernel(zeta, eta,
                                                  0.9553059660790962, 100,
                                                  96).T

        assert np.allclose(K, sim_lineshape, rtol=1.0e-3, atol=1e-3)

        # 2
        ns_obj = ShieldingPALineshape(
            anisotropic_dimension=dim,
            inverse_dimension=inverse_dimension_ppm,
            channel="29Si",
            magnetic_flux_density="9.4 T",
            rotor_angle="54.735 deg",
            rotor_frequency="100 Hz",
            number_of_sidebands=96,
        )
        zeta, eta = ns_obj._get_zeta_eta(supersampling=1)
        K = ns_obj.kernel(supersampling=1)
        sim_lineshape = generate_shielding_kernel(zeta,
                                                  eta,
                                                  0.9553059660790962,
                                                  100,
                                                  96,
                                                  to_ppm=False).T

        assert np.allclose(K, sim_lineshape, rtol=1.0e-3, atol=1e-3)

        # 3
        ns_obj = SpinningSidebands(
            anisotropic_dimension=dim,
            inverse_dimension=inverse_dimension,
            channel="29Si",
            magnetic_flux_density="9.4 T",
        )
        zeta, eta = ns_obj._get_zeta_eta(supersampling=1)
        K = ns_obj.kernel(supersampling=1)
        sim_lineshape = generate_shielding_kernel(zeta, eta,
                                                  0.9553059660790962, 208.33,
                                                  96).T

        assert np.allclose(K, sim_lineshape, rtol=1.0e-3, atol=1e-3)

        _ = TSVDCompression(K, s=np.arange(96))
        assert _.truncation_index == 15
Example #3
0
def test_zeta_eta_from_x_y():
    for dim in anisotropic_dims:
        ns_obj = ShieldingPALineshape(
            anisotropic_dimension=dim,
            inverse_dimension=inverse_dimension,
            channel="29Si",
            magnetic_flux_density="9.4 T",
            rotor_angle="90 deg",
            rotor_frequency="14 kHz",
            number_of_sidebands=1,
        )

        x = np.arange(4) * 3000
        y = np.arange(4) * 3000
        factor_ = 4 / np.pi
        zeta_ = []
        eta_ = []
        for y_ in y:
            for x_ in x:
                z = np.sqrt(x_**2 + y_**2)
                if x_ < y_:
                    eta_.append(factor_ * np.arctan(x_ / y_))
                    zeta_.append(z)
                elif x_ > y_:
                    eta_.append(factor_ * np.arctan(y_ / x_))
                    zeta_.append(-z)
                else:
                    zeta_.append(z)
                    eta_.append(1.0)
        zeta, eta = ns_obj._get_zeta_eta(supersampling=1)

        assert np.allclose(zeta, np.asarray(zeta_))
        assert np.allclose(eta, np.asarray(eta_))