Aug-12-2020, 02:07 AM
Thanks, I tried that. Although it runs fine, I wonder why the information is not stores in the map.dat files created.
That is, when I read via print(f[:10]), I get all zeros. Do you know what's happening?
That is, when I read via print(f[:10]), I get all zeros. Do you know what's happening?
L = 1000 data = np.random.rand(4064, 1) print(data.shape[0]) for j in range(data.shape[0] // L): mapper = np.memmap(f'map{j}.dat', dtype='float64', mode='w+', shape=(L, 1)) mapper = data[j * L:j * L + L] print(mapper[:10]) if data.shape[0] % L != 0: mapper = np.memmap(f'map{j + 1}.dat', dtype='float64', mode='w+', shape=(data.shape[0] % L, 1)) mapper = data[j * L + L:] print(mapper.shape) # Reading the maps L = 10**3 M = 1 f = np.memmap('map1.dat', dtype='float64', mode='r', shape=(L,M)) print(f[:10])
(Aug-12-2020, 12:51 AM)scidam Wrote: I didn't test it, but something like the following should help you:
L = 1000 data = np.random.rand(4064, 1) for j in range(data.shape[0] // L): mapper = np.memmap(f'map{j}.dat', dtype='float64', mode='w+', shape=(L,1)) mapper = data[j*L:j*L+L] if data.shape[0] % L != 0: mapper = np.memmap(f'map{j+1}.dat', dtype='float64', mode='w+', shape=(data.shape[0] % L,1)) mapper = data[j*L + L:]