slimgroup / SegyIO.jl

SegyIO.jl provides methods to read, write, and scan SEGY datasets.
MIT License
16 stars 5 forks source link

Add segy endian check #19

Closed kerim371 closed 1 year ago

kerim371 commented 1 year ago

Before that commit all SEGY file were supposed to be BIG endian and the host machine is LITTLE endian. It weren't working with LITTLE endian SEGY on LITTLE endian machine.

Now the endianness of machine is cheked using Base.ENDIAN_BOM value and SEGY endian is checked using 3225-3226 file binare header value (Data Sample Format code) wich is supposed to be in range 1-16 (from the SEGY Revision).

The most importnat here is the function bswap_needed(s::IO) that checks whether swap bytes is needed or not. It is important that s::IO was opened from the beginning of the file. That is thrue when reading file_header but this is not true when reading traces or trace_headers. That is why swap_bytes argument for these functions doesn't have default value.

Also bigendian::Bool argument for some functions was renamed to swap_bytes::Bool.

I locally checked the correctness of reading and scanning IEEE little/big endian SEGY and IBMFLOAT32 big endian SEGY on my LITTLE endian machine and it is working correctly.

mloubout commented 1 year ago

I had to revert it because it breaks a lot of tests in JUDI reading segy files incorrectly. Please reopen it and we can try to see what is wrong

kerim371 commented 1 year ago

PR reopened here #21