Exemple #1
0
    def test_plot_line(self):
        self.data.calculate_strain(self.q0)
        self.data.material_parameters(E=200 * 10**9, v=0.3)
        data2 = copy.deepcopy(self.data)
        data2.d1 += 1.0001
        merged = ordered_merge([self.data, data2], [0, 1])

        # Try a few slice extract options
        phi_names = ['strain', 'stress', 'shear strain', 'shear stress']
        az_names = [
            'peaks', 'fwhm', 'strain', 'stress', 'peak err', 'fwhm err',
            'strain err'
        ]
        phi_, az_ = [-2 * np.pi], [20]
        pnt_, theta_ = [(-0.2, 0.2)], [0, -np.pi / 3]
        d_ = [self.data, merged]

        iterator = product(d_, phi_names, phi_, pnt_, theta_)
        for d1, name, phi, pnt, theta in iterator:
            d1.plot_line(name, phi=phi, pnt=pnt, theta=theta)
            plt.close()

        iterator = product(d_, az_names, phi_, pnt_, theta_)
        for d2, name, az, pnt, theta in iterator:
            d2.plot_line(name, az_idx=az, pnt=pnt, theta=theta)
            plt.close()
Exemple #2
0
    def test_plot_slice(self):
        self.data.calculate_strain(self.q0)
        self.data.material_parameters(E=200 * 10**9, v=0.3)
        data2 = copy.deepcopy(self.data)
        data2.d1 += 1.0001
        merged = ordered_merge([self.data, data2], [0, 1])

        # Try a few slice extract options

        phi_names = ['strain', 'stress', 'shear strain', 'shear stress']
        az_names = [
            'peaks', 'fwhm', 'strain', 'stress', 'peak err', 'fwhm err',
            'strain err'
        ]

        phi_ = [-2.5 * np.pi]
        az_ = [20]
        d_ = [self.data, merged]

        for d1, name, phi in product(d_, phi_names, phi_):
            d1.plot_slice(name, phi=phi)
            plt.close()
        for d2, name, az in product(d_, az_names, az_):
            d2.plot_slice(name, az_idx=az)
            plt.close()
Exemple #3
0
 def test_save_to_text(self):
     self.data.calculate_strain(self.q0)
     self.data.material_parameters(200 * 10 ** 9, 0.3)
     data2 = copy.deepcopy(self.data)
     data2.d1 += 1.00001
     merged = ordered_merge([self.data, data2], [0, 1], 0.1)
     merged.plot_slice("shear strain", phi=np.pi / 3)
     az_lst = ["fwhm", "fwhm error", "peaks", "peaks error", "strain", "strain error", "stress"]
     phi_lst = ["strain", "shear strain", "stress", "shear stress"]
     merged.save_to_txt("pyxe/data/test.csv", az_lst, az_idx=2)
     merged.save_to_txt("pyxe/data/test.csv", phi_lst, phi=-np.pi / 3)
Exemple #4
0
def test_real():
    fine = EDI12(fpath_1)
    coarse = EDI12(fpath_2)
    for data in [fine, coarse]:
        data.peak_fit(3.1, 0.25)
        data.calculate_strain(3.1)
        data.material_parameters(E=200*10**9, v=0.3)
    merged = ordered_merge([fine, coarse], [0, 1], pad=0.2)
    merged.plot_slice('stress', phi=np.pi/3)

    return fine, coarse, merged
Exemple #5
0
 def test_save_to_text(self):
     self.data.calculate_strain(self.q0)
     self.data.material_parameters(200*10**9, 0.3)
     data2 = copy.deepcopy(self.data)
     data2.d1 += 1.00001
     merged = ordered_merge([self.data, data2], [0, 1], 0.1)
     merged.plot_slice('shear strain', phi=np.pi / 3)
     az_lst = ['fwhm', 'fwhm error', 'peaks', 'peaks error',
               'strain', 'strain error', 'stress']
     phi_lst = ['strain', 'shear strain', 'stress', 'shear stress']
     merged.save_to_txt('pyxe/data/test.csv', az_lst, az_idx=2)
     merged.save_to_txt('pyxe/data/test.csv', phi_lst, phi=-np.pi/3)
Exemple #6
0
    def test_ordered_merge(self):
        self.data.calculate_strain(self.q0)
        data2 = copy.deepcopy(self.data)

        pad = 0.35
        shift = 1.00001
        data2.d1 += shift
        added = np.sum(data2.d1 > (1 + pad))

        merged = ordered_merge([self.data, data2], [0, 1], pad)
        assert np.array_equal(merged.phi, self.data.phi)
        assert merged.d1.size == added + self.data.d1.size, (
        merged.d1.size, added, self.data.d1.size)
Exemple #7
0
    def test_ordered_merge(self):
        self.data.calculate_strain(self.q0)
        data2 = copy.deepcopy(self.data)

        pad = 0.35
        shift = 1.00001
        data2.d1 += shift
        added = np.sum(data2.d1 > (1 + pad))

        merged = ordered_merge([self.data, data2], [0, 1], pad)
        assert np.array_equal(merged.phi, self.data.phi)
        err = (merged.d1.size, added, self.data.d1.size)
        assert merged.d1.size == added + self.data.d1.size, err
Exemple #8
0
 def test_save_to_text(self):
     self.data.calculate_strain(self.q0)
     self.data.material_parameters(200 * 10**9, 0.3)
     data2 = copy.deepcopy(self.data)
     data2.d1 += 1.00001
     merged = ordered_merge([self.data, data2], [0, 1], 0.1)
     merged.plot_slice('shear strain', phi=np.pi / 3)
     az_lst = [
         'fwhm', 'fwhm error', 'peaks', 'peaks error', 'strain',
         'strain error', 'stress'
     ]
     phi_lst = ['strain', 'shear strain', 'stress', 'shear stress']
     merged.save_to_txt('pyxe/data/test.csv', az_lst, az_idx=2)
     merged.save_to_txt('pyxe/data/test.csv', phi_lst, phi=-np.pi / 3)
Exemple #9
0
    def test_save_reload(self):
        self.data.calculate_strain(self.q0)

        data2 = copy.deepcopy(self.data)
        data2.d1 += 1.00001
        merged = ordered_merge([self.data, data2], [0, 1], 0.1)
        merged.plot_slice("shear strain", phi=np.pi / 3)
        plt.close()
        merged.save_to_hdf5(fpath="pyxe/data/energy_test_pyxe.h5", overwrite=True)
        merged_reload = PeakAnalysis(fpath="pyxe/data/energy_test_pyxe.h5")
        merged_reload_b = DataViz(fpath="pyxe/data/energy_test_pyxe.h5")
        merged_reload.plot_slice("shear strain", phi=np.pi / 3)
        plt.close()
        merged_reload_b.plot_slice("shear strain", phi=np.pi / 3)
        plt.close()

        assert np.array_equal(merged.peaks, merged_reload.peaks)
Exemple #10
0
    def test_save_reload(self):
        self.data.calculate_strain(self.q0)

        data2 = copy.deepcopy(self.data)
        data2.d1 += 1.00001
        merged = ordered_merge([self.data, data2], [0, 1], 0.1)
        merged.plot_slice('shear strain', phi=np.pi / 3)
        plt.close()
        merged.save_to_hdf5(fpath='pyxe/data/energy_test_pyxe.h5',
                            overwrite=True)
        merged_reload = PeakAnalysis(fpath='pyxe/data/energy_test_pyxe.h5')
        merged_reload_b = DataViz(fpath='pyxe/data/energy_test_pyxe.h5')
        merged_reload.plot_slice('shear strain', phi=np.pi / 3)
        plt.close()
        merged_reload_b.plot_slice('shear strain', phi=np.pi / 3)
        plt.close()

        assert np.array_equal(merged.peaks, merged_reload.peaks)
Exemple #11
0
    def test_plot_slice(self):
        self.data.calculate_strain(self.q0)
        self.data.material_parameters(E=200 * 10 ** 9, v=0.3)
        data2 = copy.deepcopy(self.data)
        data2.d1 += 1.0001
        merged = ordered_merge([self.data, data2], [0, 1])

        # Try a few slice extract options

        phi_names = ["strain", "stress", "shear strain", "shear stress"]
        az_names = ["peaks", "fwhm", "strain", "stress", "peak err", "fwhm err", "strain err"]

        phi_ = [-2.5 * np.pi]
        az_ = [20]
        d_ = [self.data, merged]

        for d1, name, phi in product(d_, phi_names, phi_):
            d1.plot_slice(name, phi=phi)
            plt.close()
        for d2, name, az in product(d_, az_names, az_):
            d2.plot_slice(name, az_idx=az)
            plt.close()
Exemple #12
0
    def test_plot_line(self):
        self.data.calculate_strain(self.q0)
        self.data.material_parameters(E=200 * 10 ** 9, v=0.3)
        data2 = copy.deepcopy(self.data)
        data2.d1 += 1.0001
        merged = ordered_merge([self.data, data2], [0, 1])

        # Try a few slice extract options
        phi_names = ["strain", "stress", "shear strain", "shear stress"]
        az_names = ["peaks", "fwhm", "strain", "stress", "peak err", "fwhm err", "strain err"]
        phi_, az_ = [-2 * np.pi], [20]
        pnt_, theta_ = [(-0.2, 0.2)], [0, -np.pi / 3]
        d_ = [self.data, merged]

        iterator = product(d_, phi_names, phi_, pnt_, theta_)
        for d1, name, phi, pnt, theta in iterator:
            d1.plot_line(name, phi=phi, pnt=pnt, theta=theta)
            plt.close()

        iterator = product(d_, az_names, phi_, pnt_, theta_)
        for d2, name, az, pnt, theta in iterator:
            d2.plot_line(name, az_idx=az, pnt=pnt, theta=theta)
            plt.close()
Exemple #13
0
        merged = ordered_merge([self.data, data2], [0, 1], 0.1)
        merged.plot_slice('shear strain', phi=np.pi / 3)
        az_lst = [
            'fwhm', 'fwhm error', 'peaks', 'peaks error', 'strain',
            'strain error', 'stress'
        ]
        phi_lst = ['strain', 'shear strain', 'stress', 'shear stress']
        merged.save_to_txt('pyxe/data/test.csv', az_lst, az_idx=2)
        merged.save_to_txt('pyxe/data/test.csv', phi_lst, phi=-np.pi / 3)


if __name__ == '__main__':
    data, q0 = integration()
    data.peak_fit(3.1, 1.)
    q0.peak_fit(3.1, 1.)
    data.calculate_strain(q0)
    data.material_parameters(200 * 10**9, 0.3, G=None)
    data.plot_intensity()
    data.plot_strain_fit()
    shift = 1.00001
    data2 = copy.deepcopy(data)
    data2.d1 += shift
    merged = ordered_merge([data, data2], [0, 1], 0)
    merged.plot_slice('shear strain', phi=0)
    #plt.show()
    merged.save_to_hdf5(overwrite=True)
    merged_reload = PeakAnalysis('_pyxe.h5')
    #print(merged_reload.analysis_state.decode())
    merged_reload.plot_slice('shear strain', phi=0)
    plt.show()
Exemple #14
0
        self.data.material_parameters(200 * 10 ** 9, 0.3)
        data2 = copy.deepcopy(self.data)
        data2.d1 += 1.00001
        merged = ordered_merge([self.data, data2], [0, 1], 0.1)
        merged.plot_slice("shear strain", phi=np.pi / 3)
        az_lst = ["fwhm", "fwhm error", "peaks", "peaks error", "strain", "strain error", "stress"]
        phi_lst = ["strain", "shear strain", "stress", "shear stress"]
        merged.save_to_txt("pyxe/data/test.csv", az_lst, az_idx=2)
        merged.save_to_txt("pyxe/data/test.csv", phi_lst, phi=-np.pi / 3)


if __name__ == "__main__":
    data, q0 = integration()
    data.peak_fit(3.1, 1.0)
    q0.peak_fit(3.1, 1.0)
    data.calculate_strain(q0)
    data.material_parameters(200 * 10 ** 9, 0.3, G=None)
    data.plot_intensity()
    data.plot_strain_fit()
    shift = 1.00001
    data2 = copy.deepcopy(data)
    data2.d1 += shift
    merged = ordered_merge([data, data2], [0, 1], 0)
    merged.plot_slice("shear strain", phi=0)
    # plt.show()
    merged.save_to_hdf5(overwrite=True)
    merged_reload = PeakAnalysis("_pyxe.h5")
    # print(merged_reload.analysis_state.decode())
    merged_reload.plot_slice("shear strain", phi=0)
    plt.show()