[segyio] 113/376: segy_offset_indices

Jørgen Kvalsvik jokva-guest at moszumanska.debian.org
Wed Sep 20 08:04:17 UTC 2017


This is an automated email from the git hooks/post-receive script.

jokva-guest pushed a commit to branch debian
in repository segyio.

commit 57cd4eacbd4e1f7e3da53f90cd102f703fb401fa
Author: Jørgen Kvalsvik <jokva at statoil.com>
Date:   Wed Nov 9 14:32:56 2016 +0100

    segy_offset_indices
    
    A simple function that gathers the offset indicies/names.
---
 src/segyio/segy.c | 24 ++++++++++++++++++++++++
 src/segyio/segy.h | 11 +++++++++++
 tests/test_segy.c |  5 +++++
 3 files changed, 40 insertions(+)

diff --git a/src/segyio/segy.c b/src/segyio/segy.c
index 52be92b..6c76d47 100644
--- a/src/segyio/segy.c
+++ b/src/segyio/segy.c
@@ -808,6 +808,30 @@ int segy_offsets( segy_file* fp,
     return SEGY_OK;
 }
 
+int segy_offset_indices( segy_file* fp,
+                         int offset_field,
+                         int offsets,
+                         int* out,
+                         long trace0,
+                         unsigned int trace_bsize ) {
+    int err = 0;
+    int32_t x = 0;
+    char header[ SEGY_TRACE_HEADER_SIZE ];
+
+    if( field_size[ offset_field ] == 0 )
+        return SEGY_INVALID_FIELD;
+
+    for( int i = 0; i < offsets; ++i ) {
+        err = segy_traceheader( fp, i, header, trace0, trace_bsize );
+        if( err != SEGY_OK ) return err;
+
+        segy_get_field( header, offset_field, &x );
+        *out++ = x;
+    }
+
+    return SEGY_OK;
+}
+
 static int segy_line_indices( segy_file* fp,
                               int field,
                               unsigned int traceno,
diff --git a/src/segyio/segy.h b/src/segyio/segy.h
index 8ea1b85..3beceb0 100644
--- a/src/segyio/segy.h
+++ b/src/segyio/segy.h
@@ -104,6 +104,17 @@ int segy_offsets( segy_file*,
                   unsigned int trace_bsize );
 
 /*
+ * The names of the individual offsets. `out` must be a buffer of
+ * `segy_offsets` elements.
+ */
+int segy_offset_indices( segy_file*,
+                         int offset_field,
+                         int offsets,
+                         int* out,
+                         long trace0,
+                         unsigned int trace_bsize );
+
+/*
  * read/write traces. Does not manipulate the buffers at all, i.e. in order to
  * make sense of the read trace it must be converted to native floats, and the
  * buffer sent to write must be converted to target float.
diff --git a/tests/test_segy.c b/tests/test_segy.c
index 061c521..84551b8 100644
--- a/tests/test_segy.c
+++ b/tests/test_segy.c
@@ -56,6 +56,11 @@ static void test_interpret_file() {
     assertTrue( err == 0, "Could not figure out offsets." );
     assertTrue( offsets == 1, "Expected offsets to be 1 (no extra offsets)." );
 
+    int offset_index = -1;
+    err = segy_offset_indices( fp, 37, 1, &offset_index, trace0, trace_bsize );
+    assertTrue( err == 0, "Could not figure out offset indices." );
+    assertTrue( offset_index == 1, "Expected offset index to be 1." );
+
     err = segy_count_lines( fp, xl, offsets, &inlines_sz, &crosslines_sz, trace0, trace_bsize );
     assertTrue( err == 0, "Could not determine line count in this file." );
     assertTrue( inlines_sz == 5, "Expected 5 inlines." );

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/segyio.git



More information about the debian-science-commits mailing list