Comments (5)
Can you supply me with the file that is causing you problems? Perfect roundtripping of SEG Y files is definite goal of Segpy, so I'd like to address this.
from segpy.
Thank you for looking into this! The data file I used for this, can be found here.
from segpy.
I have the file. Rest assured that none of the test data is made public as most of it is proprietary.
from segpy.
Some notes during debugging:
The diffs are regularly spaced and are five bytes long. The first four are at offsets of 0xefb, 0x13d3, 0x18ab, 0x1d83. The offsets of the first four trace headers are 0xe10, 0x12e8, 0x17c0, 0x1c98.
>>> 0xefb - 0xe10
235
>>> 0x13d3 - 0x12e8
235
>>> 0x18ab - 0x17c0
235
>>> 0x1d83 - 0x1c98
235
The zero-based offset of 235 is in the "unassigned" block of the SEG Y trace header between one-based offsets 233-240. These unassigned bytes are currently neither read nor written by Segpy.
The solution is to derive a custom trace header description class from TraceHeaderRev1
which defines these additional field(s) and then pass the new class as the trace_header_format
argument of create_reader()
and write_segy()
. I've modified your example code to do exactly this. With this change in place your file roundtrips perfectly :-)
#!/usr/bin/env python3
from segpy.reader import create_reader
from segpy.trace_header import TraceHeaderRev1
from segpy.types import Int16
from segpy.writer import write_segy
from segpy.header import are_equal, field
class CustomTraceHeader(TraceHeaderRev1):
unassigned_1 = field(
Int16, offset=233, default=0, documentation="Unassigned 1")
unassigned_2 = field(
Int16, offset=235, default=0, documentation="Unassigned 2")
unassigned_3 = field(
Int16, offset=237, default=0, documentation="Unassigned 3")
unassigned_4 = field(
Int16, offset=239, default=0, documentation="Unassigned 4")
in_filename = "data/rth.segy"
out_filename = "data/rth_out2.segy"
in_file = open(in_filename, 'rb')
with open(out_filename, 'wb') as out_file:
segy_reader_in = create_reader(in_file, trace_header_format=CustomTraceHeader)
write_segy(out_file, segy_reader_in, trace_header_format=CustomTraceHeader)
out_file = open(out_filename, 'rb')
segy_reader_out = create_reader(in_file, trace_header_format=CustomTraceHeader)
for trace_index in segy_reader_in.trace_indexes():
trace_offset = segy_reader_in._trace_offset_catalog[trace_index]
print(trace_index, hex(trace_offset))
head0 = segy_reader_in.trace_header(trace_index)
head1 = segy_reader_out.trace_header(trace_index)
assert are_equal(head0, head1), "Error {}".format(trace_index)
data0 = segy_reader_in.trace_samples(trace_index)
data1 = segy_reader_out.trace_samples(trace_index)
assert data0==data1
from segpy.
That makes sens. Thanks for the workaround solution!
from segpy.
Related Issues (20)
- Fix invalid license change in `segpy-lite` HOT 4
- `_cdp_catalog` can be `None` in `SegYReader2D.cdp_numbers`. HOT 5
- `header()` strategy produces unusable binary reel headers HOT 11
- Investigate using AFL to generate SEG-Y files for testing
- Sporadic health-check failures for `test_regular_mapping` HOT 1
- Small error in segpy-numpy
- Confusion about dimensionality detection heuristic HOT 3
- Python <= 3.4 compatibility
- Use plugins and named extensions for trace headers HOT 3
- segy 3d read error HOT 12
- Use our exit-codes modules for exit codes
- how to get data HOT 3
- How to read latitude/longitude or xcoordinate/ycoordinate information?? HOT 17
- Unable to read shot_gather.sgy file with error: ValueError: Assigned value 43690 for num_samples HOT 1
- How to process the massive data? HOT 1
- How to read minimum and maximum values of time (ms) from .sgy files using segpy or any other seismic reader library?
- Read illegal trace lengths? HOT 5
- cannot get the trace header HOT 1
- Mapping, Sequence and Iterable are not referenced
- TraceHeaderRev0 is not compatible with CatalogSubFormat
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from segpy.