All pastes #32011 Raw Edit

Unnamed

public python v1 · immutable
#32011 ·published 2005-12-01 19:54 UTC
rendered paste body
#!/usr/bin/pythontopo_in = open("../../gebco_bathy.21601x10801.bin","r")topo_out = {}for i in range(0,65536,256):    topo_out[i] = open("gebco_bathy.21601x10801-%s.bin" % (("00000" + str(i))[-5:]),"w")import array,time,ost = time.time()while 1:    data = topo_in.read(1024)    if not data:        break    a = array.array("H")    a.fromstring(data)    l = {}    for i in range(0,65536,256):        l[i] = array.array("B")    for d in a:        for i in range(0,65536,256):            if d < i:                l[i].append(0)            else:                l[i].append(255)    for i in range(0,65536,256):        pass        topo_out[i].write(l[i].tostring())        topo_out[i].flush()    nt = time.time()    if t + 1 < nt:        t = nt    print len(data), "%f" % (float(topo_in.tell()) / float(os.fstat(topo_in.fileno())[6]) * 100)