Skip to content

Commit 5aa4460

Browse files
committed
Numpy updates
1 parent 360e086 commit 5aa4460

File tree

5 files changed

+399
-378
lines changed

5 files changed

+399
-378
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ dependencies = [
2222
"click-params>=0.5.0",
2323
"dask>=2025.9.0",
2424
"fsspec>=2025.9.0",
25+
"numpy>=2.3.3",
2526
"pint>=0.25.0",
2627
"psutil>=7.0.0",
2728
"pydantic>=2.11.9",

src/mdio/segy/_workers.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,8 @@ def trace_worker( # noqa: PLR0913
164164
)
165165
if raw_header_key in worker_variables:
166166
tmp_raw_headers = np.zeros_like(dataset[raw_header_key])
167-
# tmp_raw_headers = np.zeros((traces.header.shape[0], 240), dtype=np.)
168167
# tmp_raw_headers[not_null] = traces.raw_header
169-
np.set_printoptions(threshold=np.inf)
170-
# print(traces.header.copy().view("|V240"))
171-
# print(len(traces.header.view("|V240")))
172-
print(len(traces.header))
173168
tmp_raw_headers[not_null] = np.ascontiguousarray(traces.header.copy()).view("|V240")
174-
# tmp_raw_headers[not_null] = traces.header.view("|V240")
175-
# tmp_raw_headers[not_null] = np.ascontiguousarray(traces.header.copy()).view("|V240")
176169

177170
ds_to_write[raw_header_key] = Variable(
178171
ds_to_write[raw_header_key].dims,

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import pytest
1010

11-
DEBUG_MODE = True
11+
DEBUG_MODE = False
1212

1313
# Suppress Dask's chunk balancing warning
1414
warnings.filterwarnings(

tests/integration/test_segy_import_export_masked.py

Lines changed: 45 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -563,60 +563,62 @@ def read_segy_trace_header(trace_index: int) -> bytes:
563563
# Get SEG-Y header as raw bytes directly from file
564564
segy_raw_header_bytes = read_segy_trace_header(segy_trace_idx)
565565
segy_header_bytes = np.frombuffer(segy_raw_header_bytes, dtype=np.uint8)
566+
567+
assert_array_equal(mdio_header_bytes, segy_header_bytes)
566568

567569
# Compare byte-by-byte
568570
# Write hexdumps to separate files for analysis
569-
def hexdump_to_string(data: bytes, title: str) -> str:
570-
"""Create hexdump string."""
571-
lines = [f"{title}", "=" * len(title), ""]
571+
# def hexdump_to_string(data: bytes, title: str) -> str:
572+
# """Create hexdump string."""
573+
# lines = [f"{title}", "=" * len(title), ""]
572574

573-
for i in range(0, len(data), 16):
574-
# Address
575-
addr = i
576-
hex_part = ""
577-
ascii_part = ""
575+
# for i in range(0, len(data), 16):
576+
# # Address
577+
# addr = i
578+
# hex_part = ""
579+
# ascii_part = ""
578580

579-
# Process 16 bytes at a time
580-
for j in range(16):
581-
if i + j < len(data):
582-
byte_val = data[i + j]
583-
hex_part += f"{byte_val:02x} "
584-
ascii_part += chr(byte_val) if 32 <= byte_val <= 126 else "."
585-
else:
586-
hex_part += " "
587-
ascii_part += " "
581+
# # Process 16 bytes at a time
582+
# for j in range(16):
583+
# if i + j < len(data):
584+
# byte_val = data[i + j]
585+
# hex_part += f"{byte_val:02x} "
586+
# ascii_part += chr(byte_val) if 32 <= byte_val <= 126 else "."
587+
# else:
588+
# hex_part += " "
589+
# ascii_part += " "
588590

589-
lines.append(f"{addr:08x}: {hex_part} |{ascii_part}|")
591+
# lines.append(f"{addr:08x}: {hex_part} |{ascii_part}|")
590592

591-
return "\n".join(lines)
593+
# return "\n".join(lines)
592594

593-
# Generate filenames for this test case
594-
segy_filename = f"segy_headers_{grid_conf.name}.txt"
595-
mdio_filename = f"mdio_headers_{grid_conf.name}.txt"
595+
# # Generate filenames for this test case
596+
# segy_filename = f"segy_headers_{grid_conf.name}.txt"
597+
# mdio_filename = f"mdio_headers_{grid_conf.name}.txt"
596598

597-
# Append SEG-Y hexdump to file
598-
with open(segy_filename, operation) as f:
599-
if segy_trace_idx == 0:
600-
f.write("") # Start fresh for first trace
601-
else:
602-
f.write("\n\n") # Add spacing between traces
603-
f.write(hexdump_to_string(segy_header_bytes,
604-
f"SEG-Y Header - {grid_conf.name} Trace {segy_trace_idx} (240 bytes)"))
599+
# # Append SEG-Y hexdump to file
600+
# with open(segy_filename, operation) as f:
601+
# if segy_trace_idx == 0:
602+
# f.write("") # Start fresh for first trace
603+
# else:
604+
# f.write("\n\n") # Add spacing between traces
605+
# f.write(hexdump_to_string(segy_header_bytes,
606+
# f"SEG-Y Header - {grid_conf.name} Trace {segy_trace_idx} (240 bytes)"))
605607

606-
# Append MDIO hexdump to file
607-
with open(mdio_filename, operation) as f:
608-
if segy_trace_idx == 0:
609-
f.write("") # Start fresh for first trace
610-
else:
611-
f.write("\n\n") # Add spacing between traces
612-
f.write(hexdump_to_string(mdio_header_bytes,
613-
f"MDIO Raw Header - {grid_conf.name} Trace {segy_trace_idx} (240 bytes)"))
614-
operation = 'a'
608+
# # Append MDIO hexdump to file
609+
# with open(mdio_filename, operation) as f:
610+
# if segy_trace_idx == 0:
611+
# f.write("") # Start fresh for first trace
612+
# else:
613+
# f.write("\n\n") # Add spacing between traces
614+
# f.write(hexdump_to_string(mdio_header_bytes,
615+
# f"MDIO Raw Header - {grid_conf.name} Trace {segy_trace_idx} (240 bytes)"))
616+
# operation = 'a'
615617

616-
if segy_trace_idx == 0:
617-
print(f"\nHeader hexdumps being written for {grid_conf.name}:")
618-
print(f" SEG-Y: {segy_filename}")
619-
print(f" MDIO: {mdio_filename}")
618+
# if segy_trace_idx == 0:
619+
# print(f"\nHeader hexdumps being written for {grid_conf.name}:")
620+
# print(f" SEG-Y: {segy_filename}")
621+
# print(f" MDIO: {mdio_filename}")
620622

621623

622624
segy_trace_idx += 1

0 commit comments

Comments
 (0)