forked from learnedsystems/SOSD
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdownsample.py
More file actions
31 lines (22 loc) · 750 Bytes
/
downsample.py
File metadata and controls
31 lines (22 loc) · 750 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import numpy as np
import struct
import os
def downsample(fn):
if os.path.exists("data/" + fn + "_600M_uint64"):
return
print("Downsampling", fn)
d = np.fromfile("data/" + fn + "_800M_uint64", dtype=np.uint64)[1:]
nd = np.delete(d, np.arange(0, d.size, 4))
#with open("data/" + fn + "_600M_uint64", "wb") as f:
# f.write(struct.pack("Q", len(nd)))
# nd.tofile(f)
#nd = d[::2]
#with open("data/" + fn + "_400M_uint64", "wb") as f:
# f.write(struct.pack("Q", len(nd)))
# nd.tofile(f)
nd = d[::4]
with open("data/" + fn + "_200M_uint64", "wb") as f:
f.write(struct.pack("Q", len(nd)))
nd.tofile(f)
downsample("books")
downsample("osm_cellids")