Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add segy endian check #19

Merged
merged 2 commits into from
Jun 6, 2023
Merged

Conversation

kerim371
Copy link
Contributor

@kerim371 kerim371 commented Jun 6, 2023

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.

kerim371 added 2 commits June 6, 2023 16:04
SEGY may have BIG or LITTLE endian byte order.
Machine also may have BIG or LITTLE endian order.
If machine and SEGY have different byte order then we have to swap bytes while reading data.

To check whether machine and SEGY byte order are same we can use 3225-3226 bytes (Data Sample Format).
According to SEGY revision document this value may have only value in range 1-16.
Than concerns any type greater > 1 byte (even INT16, FLOAT32 or IBMFLOAT32 or any other).

For `bswap_needed` correct work it is important that stream (`s::IO)` is opened from the begining of the file.
Thus we can"t use the stream when reading traces or trace header (there we pass stream that is opened from some offset).
That is why in some functions we don"t have default value for `swap_bytes::Bool` argument.
@mloubout mloubout merged commit ed5c1c6 into slimgroup:master Jun 6, 2023
@mloubout
Copy link
Member

mloubout commented Jun 7, 2023

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

mloubout added a commit that referenced this pull request Jun 7, 2023
@kerim371
Copy link
Contributor Author

kerim371 commented Jun 7, 2023

PR reopened here #21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants