Beispiel #1
0
def seg2scan(fname):
    """
    Scan the SEG-2 file and return the file header and trace headers.
    """

    scalco = 1
    scalel = 1

    try:
        # Try to open file
        fpointer = open(fname, 'rb')
        # Create a Stream object
        seg2stream = Stream()
        # File format
        seg2stream.format = 'seg-2'
        # Read the file header
        endian, seg2stream.revision, trace_pointer, seg2stream.file_descriptor, string_term_char, line_term_char = _read_file_descriptor(
            fpointer)
        # Read trace descriptor and data blocks
        _read_traces(seg2stream, fpointer, endian, trace_pointer,
                     string_term_char, line_term_char, scalco, scalel)

        return seg2stream.file_descriptor, seg2stream.trace_descriptor

    except FileNotFoundError:
        pass
Beispiel #2
0
def seg2read(fname, **options):
    """
    Read SEG-2 files and store in NESSI data structure.

    :param fname: SEG-2 filename and path

    .. rubric:: Basic usage

    >>> # Import seg2read from nessi package
    >>> from nessi.io import seg2read
    >>> # Read SEG-2 file
    >>> sdata = seg2read('NESSI_TEST_DATA.seg2')

    """

    # Get options
    scalco = options.get('scalco', 1)
    scalel = options.get('scalel', 1)

    try:
        # Try to open file
        fpointer = open(fname, 'rb')
        # Create a Stream object
        seg2stream = Stream()
        # File format
        seg2stream.format = 'seg-2'
        # Read the file header
        endian, seg2stream.revision, trace_pointer, seg2stream.file_descriptor, string_term_char, line_term_char = _read_file_descriptor(
            fpointer)
        # Read trace descriptor and data blocks
        _read_traces(seg2stream, fpointer, endian, trace_pointer,
                     string_term_char, line_term_char, scalco, scalel)

        return seg2stream

    except FileNotFoundError:
        pass