@@ -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"\n Header 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