Exemplo n.º 1
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)
Exemplo n.º 2
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)
Exemplo n.º 3
0
def test_no_analysis_save_load():
    data, q0 = integration()
    data.save_to_hdf5(fpath='pyxe/data/energy_test_pyxe.h5', overwrite=True)
    PeakAnalysis(fpath='pyxe/data/energy_test_pyxe.h5')
Exemplo n.º 4
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()
Exemplo n.º 5
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()