Beispiel #1
0
 def test_ManageData_Dump(self):
     md_dump = ManageData(dump_file=self.file_name)
     md_dump.PushData(data=np.random.rand(10), key='paperino')
     md_dump.PushData(data='pippo, pluto', key='pappo')
     chars_n = md_dump.Dump()
     del md_dump
     os.remove(self.file_name)
     self.assertTrue(True)
Beispiel #2
0
    def test_ManageData_Read(self):
        md_dump = ManageData(dump_file=self.file_name)
        md_dump.PushData(data=np.random.rand(10), key='paperino')
        md_dump.PushData(data='pippo, pluto', key='pappo')
        md_dump.Dump()
        del md_dump

        md_read = ManageData(dump_file=self.file_name)
        read_flag = md_read.Read()
        del md_read
        os.remove(self.file_name)
        self.assertTrue(read_flag)
Beispiel #3
0
    def test_ManageData_ReadAndDump(self):
        md_dump = ManageData(dump_file=self.file_name)
        md_dump.PushData(data=np.random.rand(10), key='paperino')
        md_dump.PushData(data='pippo, pluto', key='pappo')
        md_dump.Dump()
        del md_dump

        md_read = ManageData(dump_file=self.file_name)
        md_read.Read()
        os.rename(self.file_name, self.file_name_mv)
        md_read.Dump()
        del md_read
        file_cmp = filecmp.cmp(self.file_name, self.file_name_mv)
        os.remove(self.file_name)
        os.remove(self.file_name_mv)
        self.assertTrue(file_cmp)
        u_bins_iso_E6[G] = np.linspace(np.log(np.amin(norm_2iso_histo)),
                                       np.log(np.amax(norm_2iso_histo)), 2**12)

        u_bins_niso_E6[G] = np.linspace(np.log(np.amin(norm_2niso_histo)),
                                        np.log(np.amax(norm_2niso_histo)),
                                        2**12)

        kde_iso = KernelDensity(bandwidth=0.25, kernel='gaussian')
        kde_iso.fit(np.log(norm_2iso_histo)[:, None])
        logprob_iso_E6[G] = kde_iso.score_samples(u_bins_iso_E6[G][:, None])

        kde_niso = KernelDensity(bandwidth=0.25, kernel='gaussian')
        kde_niso.fit(np.log(norm_2niso_histo)[:, None])
        logprob_niso_E6[G] = kde_niso.score_samples(u_bins_niso_E6[G][:, None])

    MDH.PushData(data=u_bins_iso_E6, key='u_bins_iso' + 'E6')
    MDH.PushData(data=u_bins_niso_E6, key='u_bins_niso' + 'E6')
    MDH.PushData(data=logprob_iso_E6, key='logprob_iso' + 'E6')
    MDH.PushData(data=logprob_niso_E6, key='logprob_niso' + 'E6')

    for G in [-1.75, -3.6]:
        print("G: ", G)
        sim_2iso_u = UFields['G' + str(G) + 'LX' + str(LX) + 'E8P4']
        sim_2niso_u = UFields['G' + str(G) + 'LX' + str(LX) + 'E8P2']

        sim_2iso_U = np.array([sim_2iso_u[i] for i in range(LXA)])
        sim_2iso_V = np.array([sim_2iso_u[i + LXA] for i in range(LXA)])
        sim_2iso_U = sim_2iso_U.reshape((LX, LX))
        sim_2iso_V = sim_2iso_V.reshape((LX, LX))

        sim_2niso_U = np.array([sim_2niso_u[i] for i in range(LXA)])
Beispiel #5
0
            for _delta_theta in np.linspace(0, 1, _n_bins):
                for _r in _r_range:
                    _x_cut = _r * np.cos(_delta_theta * np.pi/4.)
                    _y_cut = _r * np.sin(_delta_theta * np.pi/4.)
                    _u_profiles[_bin_i, _r] = np.sqrt(((UX_spl(_x_cut, _y_cut)) ** 2 + 
                                                       (UY_spl(_x_cut, _y_cut)) ** 2)/c2)
                _bin_i += 1

            _u_profile_ave[_str] = np.zeros(_r_range.shape[0])
            _u_profile_err[_str] = np.zeros(_r_range.shape[0])

            for _r in _r_range:
                _u_profile_ave[_str][_r] = np.mean(_u_profiles[:, _r])
                _u_profile_err[_str][_r] = np.sqrt(np.var(_u_profiles[:, _r])/(_n_bins - 1))

    AveU.PushData(data = _u_profile_ave, key = '_u_profile_ave')
    AveU.PushData(data = _u_profile_err, key = '_u_profile_err')
    AveU.PushData(data = L, key = 'L')

    AveU.Dump()
else:
    _u_profile_ave = AveU.PullData('_u_profile_ave')
    _u_profile_err = AveU.PullData('_u_profile_err')
    L = AveU.PullData('L')
    _r_range = np.arange(0, L//2, 1)

'''
Plotting
'''
from matplotlib import rc, rcParams
import matplotlib