mirror of
https://github.com/wassname/segpy.git
synced 2026-06-27 20:22:56 +08:00
35 lines
898 B
Python
35 lines
898 B
Python
SEGY_REVISION_0 = 0
|
|
SEGY_REVISION_1 = 1
|
|
|
|
VARIANTS = {SEGY_REVISION_0: SEGY_REVISION_0,
|
|
SEGY_REVISION_1: SEGY_REVISION_1,
|
|
0: SEGY_REVISION_0,
|
|
1: SEGY_REVISION_1,
|
|
100: SEGY_REVISION_1,
|
|
256: SEGY_REVISION_1}
|
|
|
|
|
|
class SegYRevisionError(Exception):
|
|
pass
|
|
|
|
|
|
def canonicalize_revision(revision):
|
|
"""Canonicalize a SEG Y revision.
|
|
|
|
Various SEG Y revisions are seen in the wild; this function canonicalizes the supplies revision
|
|
to either SEGY_REVISION_0 or SEGY_REVISION_1.
|
|
|
|
Args:
|
|
revision: Any object representing a SEG Y revision.
|
|
|
|
Returns:
|
|
Either SEGY_REVISION_0 or SEGY_REVISION_1.
|
|
|
|
Raises:
|
|
SegYRevisionError: If the revision is not known.
|
|
"""
|
|
try:
|
|
return VARIANTS[revision]
|
|
except KeyError:
|
|
raise SegYRevisionError("Unknown SEG Y Revision {!r}".format(revision))
|