[segyio] 155/376: Fix wrong trace begin/end in mex/get_traces
Jørgen Kvalsvik
jokva-guest at moszumanska.debian.org
Wed Sep 20 08:04:24 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 7cafb534504da28bcb26ca499224c21dd6841605
Author: Jørgen Kvalsvik <jokva at statoil.com>
Date: Mon Jan 16 11:57:55 2017 +0100
Fix wrong trace begin/end in mex/get_traces
Fix a bug that shows up when not all traces are being read at
once.
---
mex/segy_get_traces_mex.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/mex/segy_get_traces_mex.c b/mex/segy_get_traces_mex.c
index 8583b91..30fde3f 100644
--- a/mex/segy_get_traces_mex.c
+++ b/mex/segy_get_traces_mex.c
@@ -29,21 +29,22 @@ void mexFunction(int nlhs, mxArray *plhs[],
goto cleanup;
}
- if( last_trace != -1 && last_trace < fmt.traces )
- fmt.traces = (last_trace + 1);
+ // if last_trace was defaulted we assign it to the last trace in the file
+ if( last_trace == -1 )
+ last_trace = fmt.traces - 1;
- fmt.traces -= first_trace;
+ int traces = 1 + (last_trace - first_trace);
- plhs[0] = mxCreateNumericMatrix( fmt.samples, fmt.traces, mxSINGLE_CLASS, mxREAL );
+ plhs[0] = mxCreateNumericMatrix( fmt.samples, traces, mxSINGLE_CLASS, mxREAL );
float* out = mxGetData( plhs[ 0 ] );
- if( first_trace > fmt.traces ) {
+ if( first_trace > last_trace ) {
msg1 = "segy:get_traces:bounds";
msg2 = "first trace must be smaller than last trace";
goto cleanup;
}
- for( size_t i = first_trace; i < fmt.traces; ++i ) {
+ for( int i = first_trace; i <= last_trace; ++i ) {
err = segy_readtrace( fp, i, out, fmt.trace0, fmt.trace_bsize );
out += fmt.samples;
@@ -59,7 +60,7 @@ void mexFunction(int nlhs, mxArray *plhs[],
if( notype != -1 )
fmt.format = notype;
- segy_to_native( fmt.format, fmt.samples * fmt.traces, mxGetData( plhs[ 0 ] ) );
+ segy_to_native( fmt.format, fmt.samples * traces, mxGetData( plhs[ 0 ] ) );
int interval;
segy_get_bfield( binary, BIN_Interval, &interval );
--
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