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

Apply endianness override if spec was provided #191

Merged
merged 2 commits into from
Sep 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/segy/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ def __init__(
self._info = self.fs.info(self.url)

# Spec setting overrides.
# The control flow here is terrible; needs a refactor.
if self.settings.binary.revision is not None:
self.spec = get_segy_standard(self.settings.binary.revision)

Expand All @@ -151,9 +152,14 @@ def __init__(
# If spec is provided set to it and update endianness if its None.
else:
self.spec = spec

# Override/Infer endianness
if self.spec.endianness is None:
scan_result = infer_endianness(self.fs, self.url, self.spec)
self.spec.endianness = scan_result.endianness
if self.settings.endianness is None:
scan_result = infer_endianness(self.fs, self.url, self.spec)
self.spec.endianness = scan_result.endianness
else:
self.spec.endianness = self.settings.endianness

self._update_spec()
self.accessors = TraceAccessor(self.spec.trace)
Expand Down
Loading