From 8d6b763659a9b254dffa135d9f497ac2152040d2 Mon Sep 17 00:00:00 2001 From: Aaron Close Date: Mon, 13 May 2019 12:03:16 -0500 Subject: [PATCH 1/9] Improvements to stablity by adding defaults to enum fields --- segpy/trace_header.py | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/segpy/trace_header.py b/segpy/trace_header.py index 8baa5c0..bb3356b 100644 --- a/segpy/trace_header.py +++ b/segpy/trace_header.py @@ -8,6 +8,10 @@ class DataUse(IntEnum): """Data use: 1 = Production, 2 = Test""" + def _missing_(cls, name): + return cls.UNKNOWN + + UNKNOWN = 0 PRODUCTION = 1 TEST = 2 @@ -26,6 +30,9 @@ class ScalarFactor(IntEnum): Scalar = 1, +10, +100, +1000, or +10,000. If positive, scalar is used as a multiplier; if negative, scalar is used as a divisor. """ + def _missing_(cls, name): + return cls.UNKNOWN + UNKNOWN = 0 POS_1 = 1 POS_10 = 10 @@ -51,6 +58,9 @@ class CoordinateUnits(IntEnum): to 1; To encode ±DDDMMSS.ss this value equals ±DDD*106 + MM*104 + SS*102 with xy_scalar set to -100. """ + def _missing_(cls, name): + return cls.UNKNOWN + UNKNOWN = 0 LENGTH = 1 SECONDS_OF_ARC = 2 @@ -64,7 +74,11 @@ class CoordinateUnitsField(metaclass=IntEnumFieldMeta, class Correlated(IntEnum): - "Correlated: 1 = no, 2 = yes." + """Correlated: 0 = unknown, 1 = no, 2 = yes""" + def _missing_(cls, name): + return cls.UNKNOWN + + UNKNOWN = 0 NO = 1 YES = 2 @@ -81,6 +95,9 @@ class SweepType(IntEnum): 3 = exponential 4 = other. """ + def _missing_(cls, name): + return cls.UNKNOWN + UNKNOWN = 0 LINEAR = 1 PARABOLIC = 2 @@ -99,6 +116,9 @@ class TaperType(IntEnum): 2 = cos2, 3 = other """ + def _missing_(cls, name): + return cls.UNKNOWN + UNKNOWN = 0 LINEAR = 1 COS_SQUARED = 2 @@ -147,6 +167,9 @@ class TimeBasisCode(IntEnum): be explained in a user defined stanza in the Extended Textual File Header, 4 = UTC (Coordinated Universal Time). """ + def _missing_(cls, name): + return cls.UNKNOWN + UNKNOWN = 0 LOCAL = 1 GMT = 2 @@ -164,6 +187,9 @@ class OverTravel(IntEnum): 1 = down (or behind) 2 = up (or ahead) """ + def _missing_(cls, name): + return cls.UNKNOWN + UNKNOWN = 0 DOWN = 1 UP = 2 @@ -187,6 +213,11 @@ class SampleUnit(IntEnum): 8 = Newton (N), 9 = Watt (W) """ + + @classmethod + def _missing_(cls, name): + return cls.UNKNOWN + OTHER = -1 UNKNOWN = 0 PASCAL = 1 @@ -199,7 +230,6 @@ class SampleUnit(IntEnum): NEWTON = 8 WATT = 9 - class SampleUnitField(metaclass=IntEnumFieldMeta, enum=SampleUnit): pass @@ -238,6 +268,9 @@ class SourceMeasurementUnit(IntEnum): 5 = Newton (N), 6 = Kilograms (kg) """ + def _missing_(cls, name): + return cls.UNKNOWN + OTHER = -1 UNKNOWN = 0 JOULE = 1 From 2b6e532eabb8e0c86730356684f73031c6dd6dcf Mon Sep 17 00:00:00 2001 From: Aaron Close Date: Thu, 21 Nov 2019 17:37:38 -0600 Subject: [PATCH 2/9] Taking out things that tend to break for non segy Rev 1 Data --- segpy/binary_reel_header.py | 213 ++++++++++++++++++------------------ 1 file changed, 107 insertions(+), 106 deletions(-) diff --git a/segpy/binary_reel_header.py b/segpy/binary_reel_header.py index f2079fc..6eba725 100644 --- a/segpy/binary_reel_header.py +++ b/segpy/binary_reel_header.py @@ -187,39 +187,40 @@ class BinaryReelHeader(Header): START_OFFSET_IN_BYTES = 3201 LENGTH_IN_BYTES = 400 - job_id_num = field( - Int32, offset=3201, default=0, documentation= - "Job identification number") + # job_id_num = field( + # Int32, offset=3201, default=0, documentation= + # "Job identification number") + # line_num = field( NNInt32, offset=3205, default=0, documentation= "Line number. For 3-D poststack data, this will typically contain the in-line number." ) - - reel_num = field( - Int32, offset=3209, default=0, documentation= - "Reel number." - ) - - data_traces_per_ensemble = field( - NNInt16, offset=3213, default=0, documentation= - "Number of data traces per ensemble. Mandatory for prestack data." - ) - - auxiliary_traces_per_ensemble = field( - NNInt16, offset=3215, default=0, documentation= - "Number of auxiliary traces per ensemble. Mandatory for prestack data." - ) + # + # reel_num = field( + # Int32, offset=3209, default=0, documentation= + # "Reel number." + # ) + # + # data_traces_per_ensemble = field( + # NNInt16, offset=3213, default=0, documentation= + # "Number of data traces per ensemble. Mandatory for prestack data." + # ) + # + # auxiliary_traces_per_ensemble = field( + # NNInt16, offset=3215, default=0, documentation= + # "Number of auxiliary traces per ensemble. Mandatory for prestack data." + # ) sample_interval = field( NNInt16, offset=3217, default=0, documentation= "Sample interval in microseconds (μs). Mandatory for all data types." ) - original_field_sample_interval = field( - NNInt16, offset=3219, default=0, documentation= - "Sample interval in microseconds (μs) of original field recording." - ) + # original_field_sample_interval = field( + # NNInt16, offset=3219, default=0, documentation= + # "Sample interval in microseconds (μs) of original field recording." + # ) num_samples = field( NNInt16, offset=3221, default=0, documentation= @@ -238,95 +239,95 @@ class BinaryReelHeader(Header): documentation=DataSampleFormat.__doc__ ) - ensemble_fold = field( - NNInt16, offset=3227, default=0, documentation= - """Ensemble fold. The expected number of data traces per trace ensemble (e.g. the CMP fold). - Highly recommended for all types of data.""" - ) + # ensemble_fold = field( + # NNInt16, offset=3227, default=0, documentation= + # """Ensemble fold. The expected number of data traces per trace ensemble (e.g. the CMP fold). + # Highly recommended for all types of data.""" + # ) trace_sorting = field( TraceSortingField, offset=3229, default=0, documentation=TraceSorting.__doc__) - vertical_sum_code = field( - NNInt16, offset=3231, default=0, documentation= - """Vertical sum code: - 1 = no sum, - 2 = two sum, - ..., - N=M-1 sum (M=2to32,767).""" - ) - - sweep_frequency_at_start = field( - NNInt16, offset=3233, default=0, documentation= - "Sweep frequency at start (Hz)." - ) - - sweep_frequency_at_end = field( - NNInt16, offset=3235, default=0, documentation= - "Sweep frequency at end (Hz)." - ) - - sweep_length = field( - NNInt16, offset=3237, default=0, documentation= - "Sweep length in milliseconds." - ) - - sweep_type = field( - segpy.trace_header.SweepTypeField, offset=3239, default=0, - documentation=segpy.trace_header.SweepType.__doc__ - ) - - sweep_trace_number = field( - Int16, offset=3241, default=0, documentation= - "Trace number of sweep channel." - ) - - sweep_trace_taper_length_at_start = field( - NNInt16, offset=3243, default=0, documentation= - "Sweep trace taper length at start in milliseconds." - ) - - sweep_trace_taper_length_at_end = field( - NNInt16, offset=3245, default=0, documentation= - "Sweep trace taper length at end in milliseconds." - ) - - taper_type = field( - segpy.trace_header.TaperTypeField, offset=3247, default=0, - documentation=segpy.trace_header.TaperType.__doc__ - ) - - correlated_data_traces = field( - CorrelatedDataTracesField, offset=3249, default=0, - documentation=CorrelatedDataTraces.__doc__ - ) - - binary_gain_recovered = field( - BinaryGainRecoveredField, offset=3251, default=0, - documentation=BinaryGainRecovered.__doc__ - ) - - amplitude_recovery_method = field( - AmplitudeRecoveryMethodField, offset=3253, default=0, - documentation=AmplitudeRecoveryMethod.__doc__ - ) - - measurement_system = field( - MeasurementSystemField, offset=3255, default=0, - documentation=MeasurementSystem.__doc__ - ) - - impulse_signal_polarity = field( - ImpulseSignalPolarityField, offset=3257, default=0, - documentation=ImpulseSignalPolarity.__doc__ - ) - - vibratory_polarity_code = field( - VibratoryPolarityCodeField, - offset=3259, default=0, - documentation=VibratoryPolarityCode.__doc__ - ) + # vertical_sum_code = field( + # NNInt16, offset=3231, default=0, documentation= + # """Vertical sum code: + # 1 = no sum, + # 2 = two sum, + # ..., + # N=M-1 sum (M=2to32,767).""" + # ) + # + # sweep_frequency_at_start = field( + # NNInt16, offset=3233, default=0, documentation= + # "Sweep frequency at start (Hz)." + # ) + # + # sweep_frequency_at_end = field( + # NNInt16, offset=3235, default=0, documentation= + # "Sweep frequency at end (Hz)." + # ) + # + # sweep_length = field( + # NNInt16, offset=3237, default=0, documentation= + # "Sweep length in milliseconds." + # ) + # + # sweep_type = field( + # segpy.trace_header.SweepTypeField, offset=3239, default=0, + # documentation=segpy.trace_header.SweepType.__doc__ + # ) + # + # sweep_trace_number = field( + # Int16, offset=3241, default=0, documentation= + # "Trace number of sweep channel." + # ) + # + # sweep_trace_taper_length_at_start = field( + # NNInt16, offset=3243, default=0, documentation= + # "Sweep trace taper length at start in milliseconds." + # ) + # + # sweep_trace_taper_length_at_end = field( + # NNInt16, offset=3245, default=0, documentation= + # "Sweep trace taper length at end in milliseconds." + # ) + # + # taper_type = field( + # segpy.trace_header.TaperTypeField, offset=3247, default=0, + # documentation=segpy.trace_header.TaperType.__doc__ + # ) + # + # correlated_data_traces = field( + # CorrelatedDataTracesField, offset=3249, default=0, + # documentation=CorrelatedDataTraces.__doc__ + # ) + # + # binary_gain_recovered = field( + # BinaryGainRecoveredField, offset=3251, default=0, + # documentation=BinaryGainRecovered.__doc__ + # ) + # + # amplitude_recovery_method = field( + # AmplitudeRecoveryMethodField, offset=3253, default=0, + # documentation=AmplitudeRecoveryMethod.__doc__ + # ) + # + # measurement_system = field( + # MeasurementSystemField, offset=3255, default=0, + # documentation=MeasurementSystem.__doc__ + # ) + # + # impulse_signal_polarity = field( + # ImpulseSignalPolarityField, offset=3257, default=0, + # documentation=ImpulseSignalPolarity.__doc__ + # ) + # + # vibratory_polarity_code = field( + # VibratoryPolarityCodeField, + # offset=3259, default=0, + # documentation=VibratoryPolarityCode.__doc__ + # ) format_revision_num = field( FormatRevisionNumField, offset=3501, default=0x100, documentation= From cf431d544c59b8eb42797eeabb1e0bb5a59c085a Mon Sep 17 00:00:00 2001 From: Aaron Close Date: Thu, 21 Nov 2019 21:08:26 -0600 Subject: [PATCH 3/9] Taking out things that tend to break for non segy Rev 1 Data --- .python-version | 1 + segpy/__init__.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.python-version b/.python-version index 7f9de95..eabee2d 100644 --- a/.python-version +++ b/.python-version @@ -1,2 +1,3 @@ +3.7.1 3.6.3 3.5.4 diff --git a/segpy/__init__.py b/segpy/__init__.py index 9e7d0a5..32fd856 100644 --- a/segpy/__init__.py +++ b/segpy/__init__.py @@ -1,6 +1,6 @@ import logging -__version__ = '2.0.4' +__version__ = '2.0.5' log = logging.getLogger(__name__) log.addHandler(logging.NullHandler()) From dcc881e6a41db70c5046d04edc147b0de3c856d5 Mon Sep 17 00:00:00 2001 From: Aaron Close Date: Sat, 30 Nov 2019 16:32:38 -0600 Subject: [PATCH 4/9] Taking out things that tend to break for non segy Rev 1 Data --- segpy/__init__.py | 2 +- segpy/header.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/segpy/__init__.py b/segpy/__init__.py index 32fd856..dd81f70 100644 --- a/segpy/__init__.py +++ b/segpy/__init__.py @@ -1,6 +1,6 @@ import logging -__version__ = '2.0.5' +__version__ = '2.0.6' log = logging.getLogger(__name__) log.addHandler(logging.NullHandler()) diff --git a/segpy/header.py b/segpy/header.py index 0349392..8e1ad2e 100644 --- a/segpy/header.py +++ b/segpy/header.py @@ -298,8 +298,9 @@ def __set__(self, instance, value): try: self._instance_data[instance] = self._named_field._value_type(value) except ValueError as e: - raise ValueError("Assigned value {!r} for {} attribute must be convertible to {}: {}" - .format(value, self._name, self._named_field._value_type.__name__, e)) from e + # self._instance_data[instance] = self._named_field._value_type(self.df) + # raise ValueError("Assigned value {!r} for {} attribute must be convertible to {}: {}" + # .format(value, self._name, self._named_field._value_type.__name__, e)) from e def __delete__(self, instance): raise AttributeError("Can't delete {} attribute".format(self._name)) From c0c5bd586ab5f9c1b5b6519af4c6217cf9321160 Mon Sep 17 00:00:00 2001 From: Aaron Close Date: Sat, 30 Nov 2019 16:43:33 -0600 Subject: [PATCH 5/9] Taking out things that tend to break for non segy Rev 1 Data --- segpy/header.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/segpy/header.py b/segpy/header.py index 8e1ad2e..9aea36d 100644 --- a/segpy/header.py +++ b/segpy/header.py @@ -298,7 +298,7 @@ def __set__(self, instance, value): try: self._instance_data[instance] = self._named_field._value_type(value) except ValueError as e: - # self._instance_data[instance] = self._named_field._value_type(self.df) + self._instance_data[instance] = self._named_field.default # raise ValueError("Assigned value {!r} for {} attribute must be convertible to {}: {}" # .format(value, self._name, self._named_field._value_type.__name__, e)) from e From b1d5e97665122d0e4117873783492c2b6b424c23 Mon Sep 17 00:00:00 2001 From: Aaron Close Date: Sat, 30 Nov 2019 16:47:08 -0600 Subject: [PATCH 6/9] Taking out things that tend to break for non segy Rev 1 Data --- segpy/header.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/segpy/header.py b/segpy/header.py index 9aea36d..bf830b3 100644 --- a/segpy/header.py +++ b/segpy/header.py @@ -308,4 +308,4 @@ def __delete__(self, instance): class Header(BaseHeader, metaclass=FormatMeta): """A base class for header definition classes.""" - pass + pass \ No newline at end of file From 58c86f4a92bf487c65f72ae4060a2b5ce9a3b538 Mon Sep 17 00:00:00 2001 From: Aaron Close Date: Sat, 30 Nov 2019 16:49:53 -0600 Subject: [PATCH 7/9] Taking out things that tend to break for non segy Rev 1 Data --- segpy/header.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/segpy/header.py b/segpy/header.py index bf830b3..f840e71 100644 --- a/segpy/header.py +++ b/segpy/header.py @@ -299,8 +299,8 @@ def __set__(self, instance, value): self._instance_data[instance] = self._named_field._value_type(value) except ValueError as e: self._instance_data[instance] = self._named_field.default - # raise ValueError("Assigned value {!r} for {} attribute must be convertible to {}: {}" - # .format(value, self._name, self._named_field._value_type.__name__, e)) from e + # # raise ValueError("Assigned value {!r} for {} attribute must be convertible to {}: {}" + # # .format(value, self._name, self._named_field._value_type.__name__, e)) from e def __delete__(self, instance): raise AttributeError("Can't delete {} attribute".format(self._name)) From c3a42f26d5cc8f1c95b88328b915ff5585322431 Mon Sep 17 00:00:00 2001 From: Aaron Close Date: Sat, 30 Nov 2019 16:57:27 -0600 Subject: [PATCH 8/9] Taking out things that tend to break for non segy Rev 1 Data --- segpy/header.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/segpy/header.py b/segpy/header.py index f840e71..ee29a2f 100644 --- a/segpy/header.py +++ b/segpy/header.py @@ -308,4 +308,5 @@ def __delete__(self, instance): class Header(BaseHeader, metaclass=FormatMeta): """A base class for header definition classes.""" - pass \ No newline at end of file + pass + From 38fed3025a5b112cec12b45436b14557a0ccbed2 Mon Sep 17 00:00:00 2001 From: Aaron Close Date: Tue, 3 Dec 2019 13:49:46 -0600 Subject: [PATCH 9/9] Update README.rst --- README.rst | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index 4b3e76d..17f2efb 100644 --- a/README.rst +++ b/README.rst @@ -2,12 +2,11 @@ Segpy 2 ======= -Segpy is open source software created by Sixty North and licensed under the GNU Affero General Public License. +This is the SSIO port of SEGPY and is maintained by SSIO. -Alternative commercial license terms are available from Sixty North AS if you wish to redistribute Segpy as -part of a proprietary closed source product or deliver software software-as-a-service (SaaS) using Segpy as part -of a proprietary closed source service. +Segpy is open source software created by Sixty North and licensed under the GNU Affero General Public License. +As such it is free to use for any purposes as defined in the Affero GPU License hereto attached. Status ======