def scan_segy_header(sfile, outfile=None): """Scan a SEGY file header and print info to screen or file. Args: sfile (str): Name of SEGY file outfile (str): File where store header info, if empty or None output goes to screen (STDOUT). """ flag = False # if outfile is none, it means that you want to print on STDOUT if outfile is None: fc = tempfile.NamedTemporaryFile(delete=False, prefix="tmpxtgeo") fc.close() outfile = fc.name logger.info("TMP file name is %s", outfile) flag = True _cube_import._import_segy_xtgeo(sfile, scanheadermode=True, scantracemode=False, outfile=outfile) if flag: logger.info("OUTPUT to screen...") with open(outfile, "r") as out: for line in out: print(line.rstrip("\r\n")) os.remove(outfile)
def scan_segy_traces(sfile, outfile=None): """Scan a SEGY file traces and print limits info to STDOUT or file. Args: sfile (str): Name of SEGY file outfile: File where store scanned trace info, if empty or None output goes to STDOUT. """ oflag = False # if outfile is none, it means that you want to plot on STDOUT if outfile is None: fx = tempfile.NamedTemporaryFile(delete=False, prefix="tmpxgeo") fx.close() outfile = fx.name logger.info("TMP file name is %s", outfile) oflag = True _cube_import._import_segy_xtgeo(sfile, scanheadermode=False, scantracemode=True, outfile=outfile) if oflag: # pass logger.info("OUTPUT to screen...") with open(outfile, "r") as out: for line in out: print(line.rstrip("\r\n")) os.remove(outfile)