[segyio] 196/376: sample_indexes -> sample_indices; double -> float

Jørgen Kvalsvik jokva-guest at moszumanska.debian.org
Wed Sep 20 08:04:32 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 3256ca3442ed2607b56bd994afc24120a9c4ba03
Author: Jørgen Kvalsvik <jokva at statoil.com>
Date:   Wed Feb 15 13:05:05 2017 +0100

    sample_indexes -> sample_indices; double -> float
    
    In order to be consistent with the rest of segyio-C, segy_sample_indexes
    has been renamed to segy_sample_indices, and the buffer and arguments
    are floats, not doubles.
---
 lib/include/segyio/segy.h |  8 ++++++--
 lib/src/segy.c            | 15 +++++++++------
 lib/src/segy.def          |  2 +-
 mex/segyspec_mex.c        |  5 ++---
 mex/segyutil.c            | 13 ++++++-------
 mex/segyutil.h            |  4 ++--
 python/segyio/_segyio.c   |  7 ++++---
 7 files changed, 30 insertions(+), 24 deletions(-)

diff --git a/lib/include/segyio/segy.h b/lib/include/segyio/segy.h
index b94b75f..a62dc16 100644
--- a/lib/include/segyio/segy.h
+++ b/lib/include/segyio/segy.h
@@ -53,7 +53,7 @@ int segy_write_binheader( segy_file*, const char* buf );
  * allocates 2 octets for this, so it comfortably sits inside an int
  */
 int segy_samples( const char* binheader );
-int segy_sample_interval( segy_file*, double* dt);
+int segy_sample_interval( segy_file*, float* dt );
 /* exception: the int returned is an enum, SEGY_SORTING, not an error code */
 int segy_format( const char* binheader );
 int segy_get_field( const char* traceheader, int field, int32_t* f );
@@ -71,7 +71,11 @@ long segy_trace0( const char* binheader );
 /* number of traces in this file */
 int segy_traces( segy_file*, int*, long trace0, int trace_bsize );
 
-int segy_sample_indexes(segy_file* fp, double* buf, double t0, double dt, size_t count);
+int segy_sample_indices( segy_file*,
+                         float t0,
+                         float dt,
+                         int count,
+                         float* buf );
 
 /* text header operations */
 int segy_read_textheader( segy_file*, char *buf);
diff --git a/lib/src/segy.c b/lib/src/segy.c
index f310f18..f3f40dc 100644
--- a/lib/src/segy.c
+++ b/lib/src/segy.c
@@ -681,10 +681,10 @@ int segy_traces( segy_file* fp,
     return SEGY_OK;
 }
 
-int segy_sample_interval( segy_file* fp, double* dt) {
+int segy_sample_interval( segy_file* fp, float* dt ) {
 
     char bin_header[ SEGY_BINARY_HEADER_SIZE ];
-    char trace_header[SEGY_TRACE_HEADER_SIZE];
+    char trace_header[ SEGY_TRACE_HEADER_SIZE ];
 
     int err = segy_binheader( fp, bin_header );
     if (err != 0) {
@@ -725,19 +725,22 @@ int segy_sample_interval( segy_file* fp, double* dt) {
 
 }
 
-int segy_sample_indexes( segy_file* fp, double* buf, double t0, double dt, size_t count) {
+int segy_sample_indices( segy_file* fp,
+                         float t0,
+                         float dt,
+                         int count,
+                         float* buf ) {
 
     int err = segy_sample_interval(fp, &dt);
     if (err != 0) {
         return err;
     }
 
-    for (size_t i = 0; i < count; i++) {
+    for( int i = 0; i < count; i++ ) {
         buf[i] = t0 + i * dt;
     }
 
-    return 0;
-
+    return SEGY_OK;
 }
 
 /*
diff --git a/lib/src/segy.def b/lib/src/segy.def
index 58b6e5e..b224243 100644
--- a/lib/src/segy.def
+++ b/lib/src/segy.def
@@ -17,7 +17,7 @@ segy_set_bfield
 segy_trace_bsize
 segy_trace0
 segy_traces
-segy_sample_indexes
+segy_sample_indices
 segy_read_textheader
 segy_textheader_size
 segy_write_textheader
diff --git a/mex/segyspec_mex.c b/mex/segyspec_mex.c
index 7f47bca..936bd9d 100644
--- a/mex/segyspec_mex.c
+++ b/mex/segyspec_mex.c
@@ -122,7 +122,7 @@ void mexFunction( int nlhs, mxArray *plhs[],
     mxArray *mx_sample_indexes = mxCreateDoubleMatrix(spec.sample_count,1, mxREAL);
     double *mx_sample_indexes_ptr = mxGetPr(mx_sample_indexes);
     for (int i = 0; i < spec.sample_count; i++) {
-        mx_sample_indexes_ptr[i] = spec.sample_indexes[i];
+        mx_sample_indexes_ptr[i] = spec.sample_indices[i];
     }
     mxSetFieldByNumber(plhs[0], 0, 4, mx_sample_indexes);
 
@@ -137,8 +137,7 @@ void mexFunction( int nlhs, mxArray *plhs[],
         free(spec.crossline_indexes);
     if (spec.inline_indexes != NULL)
         free(spec.inline_indexes);
-    if (spec.sample_indexes != NULL)
-        free(spec.sample_indexes);
+    free(spec.sample_indices);
     if (spec.filename != NULL)
         free(spec.filename);
     mxFree(filename);
diff --git a/mex/segyutil.c b/mex/segyutil.c
index cb6cff3..34e16c8 100644
--- a/mex/segyutil.c
+++ b/mex/segyutil.c
@@ -13,7 +13,7 @@ static char* copyString(const char* path) {
 }
 
 
-int segyCreateSpec(SegySpec* spec, const char* file, unsigned int inline_field, unsigned int crossline_field, double t0, double dt) {
+int segyCreateSpec(SegySpec* spec, const char* file, unsigned int inline_field, unsigned int crossline_field, float t0, float dt) {
 
     int errc = 0;
 
@@ -23,7 +23,7 @@ int segyCreateSpec(SegySpec* spec, const char* file, unsigned int inline_field,
         return -1;
     }
 
-    spec->sample_indexes = NULL;
+    spec->sample_indices = NULL;
     spec->inline_indexes = NULL;
     spec->crossline_indexes = NULL;
 
@@ -37,8 +37,8 @@ int segyCreateSpec(SegySpec* spec, const char* file, unsigned int inline_field,
     spec->sample_format = segy_format( header );
     spec->sample_count = segy_samples( header );
 
-    spec->sample_indexes = malloc(sizeof(double) * spec->sample_count);
-    errc = segy_sample_indexes(fp, spec->sample_indexes, t0, dt, spec->sample_count);
+    spec->sample_indices = malloc(sizeof(float) * spec->sample_count);
+    errc = segy_sample_indices(fp, t0, dt, spec->sample_count, spec->sample_indices );
     if (errc != 0) {
         goto CLEANUP;
     }
@@ -121,8 +121,7 @@ int segyCreateSpec(SegySpec* spec, const char* file, unsigned int inline_field,
         free(spec->crossline_indexes);
     if (spec->inline_indexes != NULL)
         free(spec->inline_indexes);
-    if (spec->sample_indexes != NULL)
-        free(spec->sample_indexes);
+    free(spec->sample_indices);
     free(spec->filename);
 
     segy_close(fp);
@@ -161,7 +160,7 @@ void recreateSpec(SegySpec *spec, const mxArray* mex_spec) {
 
     mxArray* sample_indexes = mxGetProperty(mex_spec, 0, "sample_indexes");
     spec->sample_count = getMaxDim(sample_indexes);
-    spec->sample_indexes = mxGetData(sample_indexes);
+    spec->sample_indices = mxGetData(sample_indexes);
 
 }
 
diff --git a/mex/segyutil.h b/mex/segyutil.h
index 98fe1a5..0d0c4ed 100644
--- a/mex/segyutil.h
+++ b/mex/segyutil.h
@@ -21,7 +21,7 @@ typedef struct {
 
     int offset_count;
 
-    double* sample_indexes;
+    float* sample_indices;
     int sample_count;
 
     int trace_sorting_format;
@@ -33,7 +33,7 @@ typedef struct {
 
 } SegySpec;
 
-int segyCreateSpec(SegySpec* spec, const char* file, unsigned int inline_field, unsigned int crossline_field, double t0, double dt);
+int segyCreateSpec(SegySpec* spec, const char* file, unsigned int inline_field, unsigned int crossline_field, float t0, float dt);
 
 void recreateSpec(SegySpec* spec, const mxArray* mex_spec);
 
diff --git a/python/segyio/_segyio.c b/python/segyio/_segyio.c
index aa39749..f18751b 100644
--- a/python/segyio/_segyio.c
+++ b/python/segyio/_segyio.c
@@ -506,8 +506,8 @@ static PyObject *py_get_dt(PyObject *self, PyObject *args) {
     errno = 0;
 
     PyObject *file_capsule = NULL;
-    double dt;
-    PyArg_ParseTuple(args, "Od", &file_capsule, &dt);
+    float dt;
+    PyArg_ParseTuple(args, "Of", &file_capsule, &dt);
     segy_file *p_FILE = get_FILE_pointer_from_capsule(file_capsule);
 
     if (PyErr_Occurred()) { return NULL; }
@@ -515,7 +515,8 @@ static PyObject *py_get_dt(PyObject *self, PyObject *args) {
     int error = segy_sample_interval(p_FILE, &dt);
     if (error != 0) { return py_handle_segy_error(error, errno); }
 
-    return PyFloat_FromDouble(dt);
+    double ddt = dt;
+    return PyFloat_FromDouble(ddt);
 }
 
 

-- 
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