Skip to content

Commit 942c27e

Browse files
committed
Enhance profiling prints
1 parent 7bf7767 commit 942c27e

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

src/mdio/converters/segy.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,12 @@ def segy_to_mdio( # noqa: PLR0913, PLR0915
354354
... grid_overrides={"HasDuplicates": True},
355355
... )
356356
"""
357+
from datetime import datetime
358+
import time
359+
360+
start_time = datetime.fromtimestamp(time.time())
361+
print(f"Starting SEG-Y to MDIO conversion at: {start_time.strftime('%H:%M:%S.%f')}")
362+
357363
index_names = index_names or [f"dim_{i}" for i in range(len(index_bytes))]
358364
index_types = index_types or ["int32"] * len(index_bytes)
359365

@@ -377,6 +383,8 @@ def segy_to_mdio( # noqa: PLR0913, PLR0915
377383
binary_header = segy.binary_header
378384
num_traces = segy.num_traces
379385

386+
print(f"SEG-Y file opened with {num_traces} traces at: {datetime.fromtimestamp(time.time()).strftime('%H:%M:%S.%f')}")
387+
380388
# Index the dataset using a spec that interprets the user provided index headers.
381389
index_fields = []
382390
for name, byte, format_ in zip(index_names, index_bytes, index_types, strict=True):
@@ -394,6 +402,8 @@ def segy_to_mdio( # noqa: PLR0913, PLR0915
394402
grid_density_qc(grid, num_traces)
395403
grid.build_map(index_headers)
396404

405+
print(f"Grid built and mapped at: {datetime.fromtimestamp(time.time()).strftime('%H:%M:%S.%f')}")
406+
397407
# Check grid validity by ensuring every trace's header-index is within dimension bounds
398408
valid_mask = np.ones(grid.num_traces, dtype=bool)
399409
for d_idx in range(len(grid.header_index_arrays)):
@@ -441,6 +451,8 @@ def segy_to_mdio( # noqa: PLR0913, PLR0915
441451
)
442452
config = MDIOCreateConfig(path=mdio_path_or_buffer, grid=grid, variables=[var_conf])
443453

454+
print(f"Starting MDIO file creation at: {datetime.fromtimestamp(time.time()).strftime('%H:%M:%S.%f')}")
455+
444456
root_group = create_empty(
445457
config,
446458
overwrite=overwrite,
@@ -457,6 +469,8 @@ def segy_to_mdio( # noqa: PLR0913, PLR0915
457469
# Build a ChunkIterator over the live_mask (no sample axis)
458470
from mdio.core.indexing import ChunkIterator
459471

472+
print(f"Starting live mask creation at: {datetime.fromtimestamp(time.time()).strftime('%H:%M:%S.%f')}")
473+
460474
chunker = ChunkIterator(live_mask_array, chunk_samples=False)
461475
for chunk_indices in chunker:
462476
# chunk_indices is a tuple of N–1 slice objects
@@ -494,9 +508,10 @@ def segy_to_mdio( # noqa: PLR0913, PLR0915
494508
write_attribute(name="text_header", zarr_group=meta_group, attribute=text_header.split("\n"))
495509
write_attribute(name="binary_header", zarr_group=meta_group, attribute=binary_header.to_dict())
496510

497-
from datetime import datetime
511+
local_time = datetime.fromtimestamp(time.time())
512+
print(f"The livemask was written at time: {local_time.strftime('%H:%M:%S.%f')}")
498513

499-
print("The livemask was written at time:", datetime.now().strftime("%H:%M:%S"))
514+
print(f"Starting trace writing at: {datetime.fromtimestamp(time.time()).strftime('%H:%M:%S.%f')}")
500515

501516
# Write traces
502517
stats = blocked_io.to_zarr(
@@ -510,4 +525,9 @@ def segy_to_mdio( # noqa: PLR0913, PLR0915
510525
for key, value in stats.items():
511526
write_attribute(name=key, zarr_group=root_group, attribute=value)
512527

513-
zarr.consolidate_metadata(root_group.store)
528+
zarr.consolidate_metadata(root_group.store)
529+
530+
end_time = datetime.fromtimestamp(time.time())
531+
print(f"SEG-Y to MDIO conversion completed at: {end_time.strftime('%H:%M:%S.%f')}")
532+
duration = end_time - start_time
533+
print(f"Total conversion time: {duration.total_seconds():.2f} seconds")

0 commit comments

Comments
 (0)