0.2/(1-0.2) %run -i load_bromo.py SIM_PH_DIR #ls $SIM_PH_DIR/*ID1+2+3+4+5+6* pybromo_ts_params = dict( ID = '1+2+3+4+5+6', t_tot = '480', num_p = '30', pM = '64', t_step = 0.5e-6, D = 1.2e-11, dir_=SIM_PH_DIR, ) pybromo_ts_params.update( d_em_kHz = 20., a_em_kHz = 180., d_bg_kHz = 6, a_bg_kHz = 3, ) fname_d, fname_a, name, clk_p, E_sim = lu.get_bromo_fnames_da(**pybromo_ts_params) ph_times_d = np.load(fname_d) ph_times_a = np.load(fname_a) ph_times, a_em = merge_DA_ph_times(ph_times_d, ph_times_a) clk_p = t_step/32. # with t_step=0.5us -> 156.25 ns ph_times_int = (ph_times/clk_p).astype('int64') from scipy.io import savemat data_to_save = dict(timestamps_donor=ph_times_d, timestamps_acceptor=ph_times_a) savemat('timestamps_matlab_example', data_to_save, oned_as='row') ph_times_d.tofile('timestamps_donor.txt', sep='\n', format="%15e") ph_times_int.dtype ph_times_int.dtype.byteorder import sys sys.byteorder # Convert to int32 ph_times_int32 = ph_times_int.astype('int32') # Swap the bytes in memory to change endianess (byteswap) # and change also the "declared" byte order (newbyteorder) ph_times_int32_bigendian = ph_times_int32.byteswap().newbyteorder() print ph_times_int32_bigendian.dtype ph_times_int32_bigendian.tofile('times_bigend_int32.dat') new_ph_times = np.fromfile('times_bigend_int32.dat', dtype='>i4') (new_ph_times == ph_times_int32_bigendian).all() with open('times_bigend_int32.dat', 'rb') as f: data = f.read() new_ph_times = np.ndarray(len(data)/4, dtype='>i4', buffer=data) (new_ph_times == ph_times_int32_bigendian).all() print new_ph_times[0], hex(new_ph_times[0]) print new_ph_times[1], hex(new_ph_times[1]) [hex(ord(d)) for d in data[:8]] from IPython.core.display import HTML def css_styling(): styles = open("./styles/custom2.css", "r").read() return HTML(styles) css_styling()