Skip to content

Commit

Permalink
Changes source energy direction trace header
Browse files Browse the repository at this point in the history
Previously, bytes 219-224 of trace headers were specified in the code
to contain a 4-byte mantissa and 2-byte exponent for the source energy
direction.

The SEG-Y revision 2 standard, however, says that these bytes contain:

"
Source Energy Direction with respect to the source orientation — Three two-
byte two’s complement binary integers for vertical, cross-line and in-line
inclinations respectively. The positive orientation direction is defined in Bytes
217–218 of the Standard Trace Header. The energy direction is encoded in
tenths of degrees (i.e. 347.8o is encoded as 3478 10 (0D96 16 )).
"

This commit removes the trace headers
SEGY_TR_SOURCE_ENERGY_DIR_MANT
SEGY_TR_SOURCE_ENERGY_DIR_EXP

and replaces them with
SEGY_TR_SOURCE_ENERGY_DIR_VERT
SEGY_TR_SOURCE_ENERGY_DIR_XLINE
SEGY_TR_SOURCE_ENERGY_DIR_ILINE
  • Loading branch information
ar4 committed May 14, 2021
1 parent 5bf27cc commit 28e42d0
Show file tree
Hide file tree
Showing 14 changed files with 84 additions and 57 deletions.
27 changes: 16 additions & 11 deletions applications/segyio-catr.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,17 @@ static const int fields[] = {
SEGY_TR_DEVICE_ID ,
SEGY_TR_SCALAR_TRACE_HEADER ,
SEGY_TR_SOURCE_TYPE ,
SEGY_TR_SOURCE_ENERGY_DIR_MANT ,
SEGY_TR_SOURCE_ENERGY_DIR_EXP ,
SEGY_TR_SOURCE_ENERGY_DIR_VERT ,
SEGY_TR_SOURCE_ENERGY_DIR_XLINE ,
SEGY_TR_SOURCE_ENERGY_DIR_ILINE ,
SEGY_TR_SOURCE_MEASURE_MANT ,
SEGY_TR_SOURCE_MEASURE_EXP ,
SEGY_TR_SOURCE_MEASURE_UNIT ,
SEGY_TR_UNASSIGNED1 ,
SEGY_TR_UNASSIGNED2
};

static const char* su[91] = {
static const char* su[92] = {
"tracl" ,
"tracr" ,
"fldr" ,
Expand Down Expand Up @@ -191,16 +192,17 @@ static const char* su[91] = {
"triden" ,
"sctrh" ,
"stype" ,
"sedm" ,
"sede" ,
"sedv" ,
"sedxl" ,
"sedil" ,
"smm" ,
"sme" ,
"smunit" ,
"uint1" ,
"uint2"
};

static const char* segynames[91] = {
static const char* segynames[92] = {
"SEQ_LINE" ,
"SEQ_FILE" ,
"FIELD_RECORD" ,
Expand Down Expand Up @@ -285,16 +287,17 @@ static const char* segynames[91] = {
"DEVICE_ID" ,
"SCALAR_TRACE_HEADER" ,
"SOURCE_TYPE" ,
"SOURCE_ENERGY_DIR_MA",
"SOURCE_ENERGY_DIR_EX",
"SOURCE_ENERGY_DIR_V" ,
"SOURCE_ENERGY_DIR_XL",
"SOURCE_ENERGY_DIR_IL",
"SOURCE_MEASURE_MANT" ,
"SOURCE_MEASURE_EXP" ,
"SOURCE_MEASURE_UNIT" ,
"UNASSIGNED1" ,
"UNASSIGNED2"
};

static const char* desc[91] = {
static const char* desc[92] = {
"Trace sequence number within line" ,
"Trace sequence number within SEG Y file" ,
"Original field record number" ,
Expand Down Expand Up @@ -385,7 +388,9 @@ static const char* desc[91] = {
"to give the true time value in milliseconds" ,
"Source Type/Orientation" ,
"Source Energy Direction with respect to the source orientation "
"(vertical and crossline)" ,
"(vertical)" ,
"Source Energy Direction with respect to the source orientation "
"(crossline)" ,
"Source Energy Direction with respect to the source orientation "
"(inline)" ,
"Source Measurement (mantissa)" ,
Expand Down Expand Up @@ -693,7 +698,7 @@ int main( int argc, char** argv ) {
if( err )
exit( errmsg( errno, "Unable to read trace header" ) );

for( int j = 0; j < 91; j++ ) {
for( int j = 0; j < 92; j++ ) {
int f;
segy_get_field( trheader, fields[j], &f );
if( opts.nonzero && !f ) continue;
Expand Down
5 changes: 3 additions & 2 deletions applications/segyio-crop.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,9 @@ static int valid_trfield( int x ) {
case SEGY_TR_DEVICE_ID:
case SEGY_TR_SCALAR_TRACE_HEADER:
case SEGY_TR_SOURCE_TYPE:
case SEGY_TR_SOURCE_ENERGY_DIR_MANT:
case SEGY_TR_SOURCE_ENERGY_DIR_EXP:
case SEGY_TR_SOURCE_ENERGY_DIR_VERT:
case SEGY_TR_SOURCE_ENERGY_DIR_XLINE:
case SEGY_TR_SOURCE_ENERGY_DIR_ILINE:
case SEGY_TR_SOURCE_MEASURE_MANT:
case SEGY_TR_SOURCE_MEASURE_EXP:
case SEGY_TR_SOURCE_MEASURE_UNIT:
Expand Down
35 changes: 21 additions & 14 deletions applications/test/catr.output
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ tdunit 0
triden 0
sctrh 0
stype 0
sedm 0
sede 0
sedv 0
sedxl 0
sedil 0
smm 0
sme 0
smunit 0
Expand Down Expand Up @@ -173,8 +174,9 @@ tdunit 0
triden 0
sctrh 0
stype 0
sedm 0
sede 0
sedv 0
sedxl 0
sedil 0
smm 0
sme 0
smunit 0
Expand Down Expand Up @@ -264,8 +266,9 @@ tdunit 0
triden 0
sctrh 0
stype 0
sedm 0
sede 0
sedv 0
sedxl 0
sedil 0
smm 0
sme 0
smunit 0
Expand Down Expand Up @@ -355,8 +358,9 @@ tdunit 0
triden 0
sctrh 0
stype 0
sedm 0
sede 0
sedv 0
sedxl 0
sedil 0
smm 0
sme 0
smunit 0
Expand Down Expand Up @@ -446,8 +450,9 @@ tdunit 0
triden 0
sctrh 0
stype 0
sedm 0
sede 0
sedv 0
sedxl 0
sedil 0
smm 0
sme 0
smunit 0
Expand Down Expand Up @@ -537,8 +542,9 @@ tdunit 0
triden 0
sctrh 0
stype 0
sedm 0
sede 0
sedv 0
sedxl 0
sedil 0
smm 0
sme 0
smunit 0
Expand Down Expand Up @@ -628,8 +634,9 @@ tdunit 0
triden 0
sctrh 0
stype 0
sedm 0
sede 0
sedv 0
sedxl 0
sedil 0
smm 0
sme 0
smunit 0
Expand Down
5 changes: 3 additions & 2 deletions applications/test/crop-ns.output
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ tdunit 0
triden 0
sctrh 0
stype 0
sedm 0
sede 0
sedv 0
sedxl 0
sedil 0
smm 0
sme 0
smunit 0
Expand Down
10 changes: 6 additions & 4 deletions lib/experimental/segyio/segyio.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -744,8 +744,9 @@ struct trace_header {
int device_id = 0;
int scalar_trace_header = 0;
int source_type = 0;
int source_energy_dir_mant = 0;
int source_energy_dir_exp = 0;
int source_energy_dir_vert = 0;
int source_energy_dir_xline = 0;
int source_energy_dir_iline = 0;
int source_measure_mant = 0;
int source_measure_exp = 0;
int source_measure_unit = 0;
Expand Down Expand Up @@ -1471,8 +1472,9 @@ trace_header trace_header_reader< Derived >::get_th( int i ) noexcept(false) {
h.device_id = getf( SEGY_TR_DEVICE_ID );
h.scalar_trace_header = getf( SEGY_TR_SCALAR_TRACE_HEADER );
h.source_type = getf( SEGY_TR_SOURCE_TYPE );
h.source_energy_dir_mant = getf( SEGY_TR_SOURCE_ENERGY_DIR_MANT );
h.source_energy_dir_exp = getf( SEGY_TR_SOURCE_ENERGY_DIR_EXP );
h.source_energy_dir_vert = getf( SEGY_TR_SOURCE_ENERGY_DIR_VERT );
h.source_energy_dir_xline= getf( SEGY_TR_SOURCE_ENERGY_DIR_XLINE );
h.source_energy_dir_iline= getf( SEGY_TR_SOURCE_ENERGY_DIR_ILINE );
h.source_measure_mant = getf( SEGY_TR_SOURCE_MEASURE_MANT );
h.source_measure_exp = getf( SEGY_TR_SOURCE_MEASURE_EXP );
h.source_measure_unit = getf( SEGY_TR_SOURCE_MEASURE_UNIT );
Expand Down
5 changes: 3 additions & 2 deletions lib/include/segyio/segy.h
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,9 @@ typedef enum {
SEGY_TR_DEVICE_ID = 213,
SEGY_TR_SCALAR_TRACE_HEADER = 215,
SEGY_TR_SOURCE_TYPE = 217,
SEGY_TR_SOURCE_ENERGY_DIR_MANT = 219,
SEGY_TR_SOURCE_ENERGY_DIR_EXP = 223,
SEGY_TR_SOURCE_ENERGY_DIR_VERT = 219,
SEGY_TR_SOURCE_ENERGY_DIR_XLINE = 221,
SEGY_TR_SOURCE_ENERGY_DIR_ILINE = 223,
SEGY_TR_SOURCE_MEASURE_MANT = 225,
SEGY_TR_SOURCE_MEASURE_EXP = 229,
SEGY_TR_SOURCE_MEASURE_UNIT = 231,
Expand Down
10 changes: 6 additions & 4 deletions lib/src/segy.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ static int field_size[] = {
[SEGY_TR_SHOT_POINT ] = 4,
[SEGY_TR_SOURCE_DATUM_ELEV ] = 4,
[SEGY_TR_SOURCE_DEPTH ] = 4,
[SEGY_TR_SOURCE_ENERGY_DIR_MANT ] = 4,
[SEGY_TR_SOURCE_MEASURE_MANT ] = 4,
[SEGY_TR_SOURCE_SURF_ELEV ] = 4,
[SEGY_TR_SOURCE_WATER_DEPTH ] = 4,
Expand Down Expand Up @@ -291,7 +290,9 @@ static int field_size[] = {
[SEGY_TR_SCALAR_TRACE_HEADER ] = 2,
[SEGY_TR_SEC_OF_MIN ] = 2,
[SEGY_TR_SHOT_POINT_SCALAR ] = 2,
[SEGY_TR_SOURCE_ENERGY_DIR_EXP ] = 2,
[SEGY_TR_SOURCE_ENERGY_DIR_VERT ] = 2,
[SEGY_TR_SOURCE_ENERGY_DIR_XLINE] = 2,
[SEGY_TR_SOURCE_ENERGY_DIR_ILINE] = 2,
[SEGY_TR_SOURCE_GROUP_SCALAR ] = 2,
[SEGY_TR_SOURCE_MEASURE_EXP ] = 2,
[SEGY_TR_SOURCE_MEASURE_UNIT ] = 2,
Expand Down Expand Up @@ -1103,7 +1104,6 @@ static int bswap_th( char* xs, int lsb ) {
SEGY_TR_SHOT_POINT,
SEGY_TR_SOURCE_DATUM_ELEV,
SEGY_TR_SOURCE_DEPTH,
SEGY_TR_SOURCE_ENERGY_DIR_MANT,
SEGY_TR_SOURCE_MEASURE_MANT,
SEGY_TR_SOURCE_SURF_ELEV,
SEGY_TR_SOURCE_WATER_DEPTH,
Expand Down Expand Up @@ -1160,7 +1160,9 @@ static int bswap_th( char* xs, int lsb ) {
SEGY_TR_SCALAR_TRACE_HEADER,
SEGY_TR_SEC_OF_MIN,
SEGY_TR_SHOT_POINT_SCALAR,
SEGY_TR_SOURCE_ENERGY_DIR_EXP,
SEGY_TR_SOURCE_ENERGY_DIR_VERT,
SEGY_TR_SOURCE_ENERGY_DIR_XLINE,
SEGY_TR_SOURCE_ENERGY_DIR_ILINE,
SEGY_TR_SOURCE_GROUP_SCALAR,
SEGY_TR_SOURCE_MEASURE_EXP,
SEGY_TR_SOURCE_MEASURE_UNIT,
Expand Down
5 changes: 3 additions & 2 deletions lib/test/segy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,6 @@ TEST_CASE("testing size", "[c.segy]") {
CHECK( 4 == size( SEGY_TR_SHOT_POINT ));
CHECK( 4 == size( SEGY_TR_SOURCE_DATUM_ELEV ));
CHECK( 4 == size( SEGY_TR_SOURCE_DEPTH ));
CHECK( 4 == size( SEGY_TR_SOURCE_ENERGY_DIR_MANT ));
CHECK( 4 == size( SEGY_TR_SOURCE_SURF_ELEV ));
CHECK( 4 == size( SEGY_TR_SOURCE_X ));
CHECK( 4 == size( SEGY_TR_SOURCE_Y ));
Expand Down Expand Up @@ -606,7 +605,9 @@ TEST_CASE("testing size", "[c.segy]") {
CHECK( 2 == size( SEGY_TR_SCALAR_TRACE_HEADER ));
CHECK( 2 == size( SEGY_TR_SEC_OF_MIN ));
CHECK( 2 == size( SEGY_TR_SHOT_POINT_SCALAR ));
CHECK( 2 == size( SEGY_TR_SOURCE_ENERGY_DIR_EXP ));
CHECK( 2 == size( SEGY_TR_SOURCE_ENERGY_DIR_VERT ));
CHECK( 2 == size( SEGY_TR_SOURCE_ENERGY_DIR_XLINE ));
CHECK( 2 == size( SEGY_TR_SOURCE_ENERGY_DIR_ILINE ));
CHECK( 2 == size( SEGY_TR_SOURCE_MEASURE_EXP ));
CHECK( 2 == size( SEGY_TR_SOURCE_MEASURE_UNIT ));
CHECK( 2 == size( SEGY_TR_SOURCE_STATIC_CORR ));
Expand Down
5 changes: 3 additions & 2 deletions mex/Segy.m
Original file line number Diff line number Diff line change
Expand Up @@ -603,8 +603,9 @@
tr_heads.TraceIdentifier = segy_get_field_mex( header, 213 );
tr_heads.ScalarTraceHeader = segy_get_field_mex( header, 215 );
tr_heads.SourceType = segy_get_field_mex( header, 217 );
tr_heads.SourceEnergyDirectionMantissa = segy_get_field_mex( header, 219 );
tr_heads.SourceEnergyDirectionExponent = segy_get_field_mex( header, 223 );
tr_heads.SourceEnergyDirectionVert = segy_get_field_mex( header, 219 );
tr_heads.SourceEnergyDirectionXline = segy_get_field_mex( header, 221 );
tr_heads.SourceEnergyDirectionIline = segy_get_field_mex( header, 223 );
tr_heads.SourceMeasurementMantissa = segy_get_field_mex( header, 225 );
tr_heads.SourceMeasurementExponent = segy_get_field_mex( header, 229 );
tr_heads.SourceMeasurementUnit = segy_get_field_mex( header, 231 );
Expand Down
5 changes: 3 additions & 2 deletions mex/TraceField.m
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@
TraceIdentifier (213)
ScalarTraceHeader (215)
SourceType (217)
SourceEnergyDirectionMantissa (219)
SourceEnergyDirectionExponent (223)
SourceEnergyDirectionVert (219)
SourceEnergyDirectionXline (221)
SourceEnergyDirectionIline (223)
SourceMeasurementMantissa (225)
SourceMeasurementExponent (229)
SourceMeasurementUnit (231)
Expand Down
5 changes: 3 additions & 2 deletions python/segyio/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,9 @@ class Field(MutableMapping):
'triden': TraceField.TraceIdentifier,
'sctrh' : TraceField.ScalarTraceHeader,
'stype' : TraceField.SourceType,
'sedm' : TraceField.SourceEnergyDirectionMantissa,
'sede' : TraceField.SourceEnergyDirectionExponent,
'sedv' : TraceField.SourceEnergyDirectionVert,
'sedxl' : TraceField.SourceEnergyDirectionXline,
'sedil' : TraceField.SourceEnergyDirectionIline,
'smm' : TraceField.SourceMeasurementMantissa,
'sme' : TraceField.SourceMeasurementExponent,
'smunit': TraceField.SourceMeasurementUnit,
Expand Down
6 changes: 4 additions & 2 deletions python/segyio/su/words.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,11 @@
#:
stype = tf.SourceType
#:
sedm = tf.SourceEnergyDirectionMantissa
sedv = tf.SourceEnergyDirectionVert
#:
sede = tf.SourceEnergyDirectionExponent
sedxl = tf.SourceEnergyDirectionXline
#:
sedil = tf.SourceEnergyDirectionIline
#:
smm = tf.SourceMeasurementMantissa
#:
Expand Down
10 changes: 6 additions & 4 deletions python/segyio/tracefield.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ class TraceField(Enum):
TraceIdentifier = 213
ScalarTraceHeader = 215
SourceType = 217
SourceEnergyDirectionMantissa = 219
SourceEnergyDirectionExponent = 223
SourceEnergyDirectionVert = 219
SourceEnergyDirectionXline = 221
SourceEnergyDirectionIline = 223
SourceMeasurementMantissa = 225
SourceMeasurementExponent = 229
SourceMeasurementUnit = 231
Expand Down Expand Up @@ -185,8 +186,9 @@ class TraceField(Enum):
'TraceIdentifier' : 213,
'ScalarTraceHeader' : 215,
'SourceType' : 217,
'SourceEnergyDirectionMantissa' : 219,
'SourceEnergyDirectionExponent' : 223,
'SourceEnergyDirectionVert' : 219,
'SourceEnergyDirectionXline' : 221,
'SourceEnergyDirectionIline' : 223,
'SourceMeasurementMantissa' : 225,
'SourceMeasurementExponent' : 229,
'SourceMeasurementUnit' : 231,
Expand Down
8 changes: 4 additions & 4 deletions python/test/segy.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,10 @@ def test_disabled_methods_seismic_unix(openfn, kwargs):
@pytest.mark.parametrize(('openfn', 'kwargs'), small_segys)
def test_header_dict_methods(openfn, kwargs):
with openfn(**kwargs) as f:
assert 89 == len(list(f.header[0].keys()))
assert 89 == len(list(f.header[1].values()))
assert 89 == len(list(f.header[2].items()))
assert 89 == len(list(f.header[3]))
assert 90 == len(list(f.header[0].keys()))
assert 90 == len(list(f.header[1].values()))
assert 90 == len(list(f.header[2].items()))
assert 90 == len(list(f.header[3]))
assert 0 not in f.header[0]
assert 1 in f.header[0]
assert segyio.su.cdpx in f.header[0]
Expand Down

0 comments on commit 28e42d0

Please sign in to comment.