def loadfunc (): sf = SEGYFile(infile) sf._calcEnsembles() ntr = sf.ntr nsrc = len(sf.ensembles) nrec = ntr / nsrc nsamp = sf.ns dt = sf.bhead['hdt'] / 1.e6 trh0 = sf.trhead[0] scalco = trh0['scalco'] if (scalco < 0): scalco = -1. / scalco scalel = trh0['scalel'] if (scalel < 0): scalel = -1. / scalel datadims = (nsrc,nrec,nsamp) headerdims = (nsrc,nrec) flatdatadims = (ntr,nsamp) params = { 'ntr': ntr, 'nsrc': nsrc, 'nrec': nrec, 'nsamp': nsamp, 'dt': dt, 'scalco': scalco, 'scalel': scalel, 'datadims': datadims, 'headerdims': headerdims, 'flatdatadims': flatdatadims, } dbase['params'] = params sx = np.array([float(abs(trh['sx'])) for trh in sf.trhead]).reshape(headerdims) gx = np.array([float(abs(trh['gx'])) for trh in sf.trhead]).reshape(headerdims) offset = abs(sx - gx) cdp = (sx + gx)/2. water = offset / watervelocity wmute = water / dt headers = { 'sx': sx, 'gx': gx, 'offset': offset, 'cdp': cdp, 'water': water, 'wmute': wmute, } dbase['headers'] = headers if (os.path.exists(tempfile) and os.path.getmtime(tempfile) > os.path.getmtime(infile)): tracebuf = np.memmap(tempfile, dtype=np.float32, shape=datadims, mode='r+') else: tracebuf = np.memmap(tempfile, dtype=np.float32, shape=datadims, mode='w+') tracebuf[:] = sf[:].reshape(datadims) dbase['data_orig'] = tracebuf dbase['data_current'] = tracebuf
else: scalco = trh0["scalco"] scalco = scalco / unit if trh0["scalel"] < 0: scalel = 1.0 / abs(trh0["scalel"]) else: scalel = trh0["scalel"] scalel = scalel / unit # Use SEGYFile internal to calculate shot-gather boundaries sys.stdout.write("Calculating ensemble boundaries...\n") sys.stdout.flush() sf._calcEnsembles() # Find the number of ensembles, and order them by occurrence in the SEG-Y file ngathers = len(sf.ensembles) ordering = np.argsort(sf.ensembles.values()) shotnums = np.array(sf.ensembles.keys())[ordering] sys.stdout.write("Writing output files...\n") sys.stdout.flush() # Create some empty lists to hold upcoming values shotlocs = [[], [], []] shotactive = [] shotnumber = 0 # Create bound thresholds (which will be updated)
else: scalco = trh0['scalco'] scalco = scalco / unit if (trh0['scalel'] < 0): scalel = 1. / abs(trh0['scalel']) else: scalel = trh0['scalel'] scalel = scalel / unit # Use SEGYFile internal to calculate shot-gather boundaries sys.stdout.write('Calculating ensemble boundaries...\n') sys.stdout.flush() sf._calcEnsembles() # Find the number of ensembles, and order them by occurrence in the SEG-Y file ngathers = len(sf.ensembles) ordering = np.argsort(sf.ensembles.values()) shotnums = np.array(sf.ensembles.keys())[ordering] sys.stdout.write('Writing output files...\n') sys.stdout.flush() # Create some empty lists to hold upcoming values shotlocs = [[], [], []] shotactive = [] shotnumber = 0 # Create bound thresholds (which will be updated)
def loadfunc(): sf = SEGYFile(infile) sf._calcEnsembles() ntr = sf.ntr nsrc = len(sf.ensembles) nrec = ntr / nsrc nsamp = sf.ns dt = sf.bhead['hdt'] / 1.e6 trh0 = sf.trhead[0] scalco = trh0['scalco'] if (scalco < 0): scalco = -1. / scalco scalel = trh0['scalel'] if (scalel < 0): scalel = -1. / scalel datadims = (nsrc, nrec, nsamp) headerdims = (nsrc, nrec) flatdatadims = (ntr, nsamp) params = { 'ntr': ntr, 'nsrc': nsrc, 'nrec': nrec, 'nsamp': nsamp, 'dt': dt, 'scalco': scalco, 'scalel': scalel, 'datadims': datadims, 'headerdims': headerdims, 'flatdatadims': flatdatadims, } dbase['params'] = params sx = np.array([float(abs(trh['sx'])) for trh in sf.trhead]).reshape(headerdims) gx = np.array([float(abs(trh['gx'])) for trh in sf.trhead]).reshape(headerdims) offset = abs(sx - gx) cdp = (sx + gx) / 2. water = offset / watervelocity wmute = water / dt headers = { 'sx': sx, 'gx': gx, 'offset': offset, 'cdp': cdp, 'water': water, 'wmute': wmute, } dbase['headers'] = headers if (os.path.exists(tempfile) and os.path.getmtime(tempfile) > os.path.getmtime(infile)): tracebuf = np.memmap(tempfile, dtype=np.float32, shape=datadims, mode='r+') else: tracebuf = np.memmap(tempfile, dtype=np.float32, shape=datadims, mode='w+') tracebuf[:] = sf[:].reshape(datadims) dbase['data_orig'] = tracebuf dbase['data_current'] = tracebuf