Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions seismic_zfp/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ def write_headers(header_detection, header_info, out_filehandle):
if header_detection != 'strip':
for header_array in header_info.headers_dict.values():
# Pad to 512-bytes for page blobs
out_filehandle.write(header_array.tobytes() + bytes(512-len(header_array.tobytes()) % 512))
byte_array = header_array.tobytes()
out_filehandle.write(byte_array + bytes(pad(len(byte_array), 512) - len(byte_array)))

@staticmethod
def write_hash(hash, out_filehandle):
Expand Down Expand Up @@ -442,7 +443,8 @@ def __exit__(self, exc_type, exc_val, exc_tb):
def write_headers(header_info, out_filehandle):
for header_array in header_info.headers_dict.values():
# Pad to 512-bytes for page blobs
out_filehandle.write(header_array.tobytes() + bytes(512-len(header_array.tobytes()) % 512))
byte_array = header_array.tobytes()
out_filehandle.write(byte_array + bytes(pad(len(byte_array), 512) - len(byte_array)))

@staticmethod
def write_hash(hash, out_filehandle):
Expand Down
4 changes: 2 additions & 2 deletions seismic_zfp/headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ def __init__(self, n_traces, seismicfile=None,
cdp_x, cdp_y, iline_headers, xline_headers = self.get_zgy_header_arrays()

# Keep them in memory until file is ready for them to be written
self.headers_dict = {181: cdp_x, 185: cdp_y, 189: iline_headers, 193: xline_headers}

self.headers_dict = collections.OrderedDict([(181, cdp_x), (185, cdp_y),
(189, iline_headers), (193, xline_headers)])
else:
raise RuntimeError("Only SEG-Y and ZGY files supported for header generation")

Expand Down
Binary file added test_data/tracecount512.sgy
Binary file not shown.
2 changes: 2 additions & 0 deletions tests/test_compress.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
SGY_FILE_NEGATIVE_SAMPLES = 'test_data/small-negative-samples.sgy'
SGY_FILE_TRACEHEADER_SAMPLERATE = 'test_data/small-traceheader-samplerate.sgy'
SGY_FILE_DUPLICATE_TRACEHEADERS = 'test_data/small-duplicate-traceheaders.sgy'
SGY_FILE_512 = 'test_data/tracecount512.sgy'
SGZ_FILE = 'test_data/small_8bit.sgz'
SGZ_FILE_2 = 'test_data/small_2bit.sgz'

Expand Down Expand Up @@ -319,6 +320,7 @@ def test_compress_headers(tmp_path):
compress_compare_headers(SGY_FILE_2D, tmp_path, strict=False)
compress_compare_headers(SGY_FILE_2D_CROSSLINE_3D, tmp_path, strict=False)
compress_compare_headers(SGY_FILE_2D_INLINE_3D, tmp_path, strict=False)
compress_compare_headers(SGY_FILE_512, tmp_path)


def test_compress_headers_errors(tmp_path):
Expand Down
Loading