Skip to content

Commit

Permalink
Apply DelayScalar to get correct samples offset
Browse files Browse the repository at this point in the history
  • Loading branch information
dawad committed Feb 27, 2023
1 parent 6107089 commit 3f692e8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion python/segyio/open.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,13 @@ def open(filename, mode="r", iline = 189,
)

try:
delay_scalar = f.header[0][segyio.TraceField.ScalarTraceHeader]
if delay_scalar == 0:
delay_scalar = 1
elif delay_scalar < 0:
delay_scalar = 1.0 / delay_scalar
dt = segyio.tools.dt(f, fallback_dt = 4000.0) / 1000.0
t0 = f.header[0][segyio.TraceField.DelayRecordingTime]
t0 = f.header[0][segyio.TraceField.DelayRecordingTime] * abs(delay_scalar)
samples = metrics['samplecount']
f._samples = (numpy.arange(samples) * dt) + t0

Expand Down
4 changes: 4 additions & 0 deletions python/test/segy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1968,3 +1968,7 @@ def test_groups_gather_equivalence():

# group[(il, xl)] == gather[il, xl]
npt.assert_array_equal(from_group, from_gather)

def test_delay_scalar_applied():
with segyio.open(testdata / 'delay-scalar.sgy') as f:
assert f.samples[0] == 1000
Binary file added test-data/delay-scalar.sgy
Binary file not shown.

0 comments on commit 3f692e8

Please sign in to comment.