| A Python module to read and write SEG-Y files from Python, implemented using the syntax of the SEG-Y format : SEG-Y revsision 0 (1975) and revision 1 (May 2002) |
|
SegyPY aims at being both simple to use to read SEG-Y files, and extensive enough to aid in writing complex seismic data.
SegyPy is based on the SegyMAT, a Matlab implementation of a SEG-Y library for reading/writing SEG-Y formatted files.
The current version is 0.3 (Oct 2005) :
segypy-0.3.tgz
segypy-0.3.zip
You can get the latest developments ia CVS from :
cvs -d:pserver:anonymous@segymat.cvs.sourceforge.net:/cvsroot/segymat login cvs -z3 -d:pserver:anonymous@segymat.cvs.sourceforge.net:/cvsroot/segymat co -P SegyPY
You can also browse the CVS repository.
The following example was run in 'ipython'
In [1]: import segypy SegyPY : Using numarray moduleRead SEGY file example file : ld0057_file_00095.sgy from Continental Geoscience Division
In [2]:Data,SH,STH = segypy.readSegy('ld0057_file_00095.sgy');
SegyPY 0.2 : readSegy : Trying to read ld0057_file_00095.sgy
SegyPY 0.2 : getSegyHeader : succesfully read ld0057_file_00095.sgy
SegyPY 0.2 : readSegy : Length of data : 3185784
SegyPY 0.2 : readSegy : ntraces=386 nsamples=2001
SegyPY 0.2 : getAllSegyTraceHeaders : trying to get all segy trace headers
SegyPY 0.2 : readSegy : reading segy data
SegyPY 0.2 : readSegy : SEG-Y revision = 0
SegyPY 0.2 : readSegy : DataSampleFormat=1(IBM Float)
SegyPY 0.2 : readSegy : Assuming DSF=1, IBM FLOATS
SegyPY 0.2 : readSegy : - reshaping
SegyPY 0.2 : readSegy : - stripping header dummy data
SegyPY 0.2 : readSegy : - transposing
SegyPY 0.2 : readSegy : read data
In [2]:segypy.writeSegyStructure('outfile.segy',Data,SH,STH)
SegyPY 0.2 : writeSegy : Trying to write outfile.segy
In [3]:segypy.wiggle(Data,SH)results in :
In [3]: whos
Variable Type Data/Info
--------------------------------
Data NumArray [[0 0 0 ..., 0 0 0]
[0 0<...>0 0]
[0 0 0 ..., 0 0 0]]
SH dict {'SweepFrequencyStart': 0<...>CorrelatedDataTraces': 0}
STH dict {'Inline3D': array([0, 0,<...>0, 0, 0, 0, 0, 0, 0, 0])}
segypy module
In [4]: SH
{'AmplitudeRecoveryMethod': 0,
'AuxiliaryTracePerEnsemble': 0,
'BinaryGain': 0,
'CorrelatedDataTraces': 0,
'DataSampleFormat': 3,
'DataTracePerEnsemble': 0,
'EnsembleFold': 0,
'FixedLengthTraceFlag': 1,
'ImpulseSignalPolarity': 0,
'Job': 0,
'Line': 0,
'MeasurementSystem': 1,
'NumberOfExtTextualHeaders': 0,
'Reel': 0,
'SegyFormatRevisionNumber': 100,
'SweepChannel': 0,
'SweepFrequencyEnd': 0,
'SweepFrequencyStart': 0,
'SweepLength': 0,
'SweepTaperLengthEnd': 0,
'SweepTaperlengthStart': 0,
'SweepType': 0,
'TaperType': 0,
'TraceSorting': 0,
'Unassigned1': 0,
'Unassigned2': 0,
'VerticalSumCode': 0,
'VibratoryPolarityCode': 0,
'dt': 4000,
'dtOrig': 0,
'filename': 'data_2byteINT.segy',
'ns': 200,
'nsOrig': 0,
'ntraces': 200}
In [1]: import segypy
SegyPY : Using numarray module
In [2]: segypy.STH_def
Out[2]:
{'AliasFilterFrequency': {'type': 'int16', 'pos': 140},
'AliasFilterSlope': {'type': 'int16', 'pos': 142},
'CoordinateUnits': {'descr': {1: {1: 'Length (meters or feet)',
2: 'Seconds of arc',
3: 'Decimal degrees',
4: 'Degrees, minutes, seconds (DMS)'}},
'pos': 88,
'type': 'int16'},
'Correlated': {'descr': {0: {1: 'No', 2: 'Yes'}, 1: {1: 'No', 2: 'Yes'}},
'pos': 124,
'type': 'int16'},
'Crossline3D': {'type': 'int32', 'pos': 192},
'DataUse': {'descr': {0: {1: 'Production', 2: 'Test'},
1: {1: 'Production', 2: 'Test'}},
'pos': 34,
'type': 'int16'},
'DayOfYear': {'type': 'int16', 'pos': 158},
'DelayRecordingTime': {'type': 'int16', 'pos': 108},
'ElevationScalar': {'type': 'int16', 'pos': 68},
'EnergySourcePoint': {'type': 'int32', 'pos': 16},
'FieldRecord': {'type': 'int32', 'pos': 8},
'GainType': {'descr': {0: {1: 'Fixes', 2: 'Binary', 3: 'Floating point'},
1: {1: 'Fixes', 2: 'Binary', 3: 'Floating point'}},
'pos': 119,
'type': 'int16'},
'GapSize': {'type': 'int16', 'pos': 176},
'GeophoneGroupNumberFirstTraceOrigField': {'type': 'int16', 'pos': 172},
'GeophoneGroupNumberLastTraceOrigField': {'type': 'int16', 'pos': 174},
'GeophoneGroupNumberRoll1': {'type': 'int16', 'pos': 170},
'GroupStaticCorrection': {'type': 'int16', 'pos': 100},
'GroupUpholeTime': {'type': 'int16', 'pos': 96},
'GroupWaterDepth': {'type': 'int32', 'pos': 64},
'GroupX': {'type': 'int32', 'pos': 80},
'GroupY': {'type': 'int32', 'pos': 84},
'HighCutFrequency': {'type': 'int16', 'pos': 150},
'HighCutSlope': {'type': 'int16', 'pos': 154},
'HourOfDay': {'type': 'int16', 'pos': 160},
'Inline3D': {'type': 'int32', 'pos': 188},
'InstrumentGainConstant': {'type': 'int16', 'pos': 120},
'InstrumentInitialGain': {'type': 'int16', 'pos': 122},
'LagTimeA': {'type': 'int16', 'pos': 104},
'LagTimeB': {'type': 'int16', 'pos': 106},
'LowCutFrequency': {'type': 'int16', 'pos': 148},
'LowCutSlope': {'type': 'int16', 'pos': 152},
'MinuteOfHour': {'type': 'int16', 'pos': 162},
'MuteTimeEND': {'type': 'int16', 'pos': 112},
'MuteTimeStart': {'type': 'int16', 'pos': 110},
'NStackedTraces': {'type': 'int16', 'pos': 32},
'NSummedTraces': {'type': 'int16', 'pos': 30},
'NotchFilterFrequency': {'type': 'int16', 'pos': 144},
'NotchFilterSlope': {'type': 'int16', 'pos': 146},
'OverTravel': {'descr': {0: {1: 'down (or behind)',
2: 'up (or ahead)',
3: 'other'},
1: {1: 'down (or behind)',
2: 'up (or ahead)',
3: 'other'}},
'pos': 178,
'type': 'int16'},
'ReceiverDatumElevation': {'type': 'int32', 'pos': 52},
'ReceiverGroupElevation': {'type': 'int32', 'pos': 40},
'ScalarTraceHeader': {'type': 'int16', 'pos': 214},
'SecondOfMinute': {'type': 'int16', 'pos': 164},
'ShotPoint': {'type': 'int32', 'pos': 192},
'ShotPointScalar': {'type': 'int16', 'pos': 200},
'SourceDatumElevation': {'type': 'int32', 'pos': 56},
'SourceDepth': {'type': 'int32', 'pos': 48},
'SourceEnergyDirectionExponent': {'type': 'int16', 'pos': 222},
'SourceEnergyDirectionMantissa': {'type': 'int32', 'pos': 218},
'SourceGroupScalar': {'type': 'int16', 'pos': 70},
'SourceMeasurementExponent': {'type': 'int16', 'pos': 228},
'SourceMeasurementMantissa': {'type': 'int32', 'pos': 224},
'SourceMeasurementUnit': {'descr': {1: {-1: 'Other (should be described in Source Measurement Unit stanza)',
0: 'Unknown',
1: 'Joule (J)',
2: 'Kilowatt (kW)',
3: 'Pascal (Pa)',
4: 'Bar-meter (Bar-m)',
5: 'Newton (N)',
6: 'Kilograms (kg)'}},
'pos': 230,
'type': 'int16'},
'SourceStaticCorrection': {'type': 'int16', 'pos': 98},
'SourceSurfaceElevation': {'type': 'int32', 'pos': 44},
'SourceType': {'descr': {1: {-1: 'Other (should be described in Source Type/Orientation stanza)',
0: 'Unknown',
1: 'Vibratory - Vertical orientation',
2: 'Vibratory - Cross-line orientation',
3: 'Vibratory - In-line orientation',
4: 'Impulsive - Vertical orientation',
5: 'Impulsive - Cross-line orientation',
6: 'Impulsive - In-line orientation',
7: 'Distributed Impulsive - Vertical orientation', 8: 'Distributed Impulsive - Cross-line orientation',
9: 'Distributed Impulsive - In-line orientation'}},
'pos': 216,
'type': 'int16'},
'SourceUpholeTime': {'type': 'int16', 'pos': 94},
'SourceWaterDepth': {'type': 'int32', 'pos': 60},
'SourceX': {'type': 'int32', 'pos': 72},
'SourceY': {'type': 'int32', 'pos': 76},
'SubWeatheringVelocity': {'type': 'int16', 'pos': 92},
'SweepFrequenceEnd': {'type': 'int16', 'pos': 128},
'SweepFrequenceStart': {'type': 'int16', 'pos': 126},
'SweepLength': {'type': 'int16', 'pos': 130},
'SweepTraceTaperLengthEnd': {'type': 'int16', 'pos': 136},
'SweepTraceTaperLengthStart': {'type': 'int16', 'pos': 134},
'SweepType': {'descr': {0: {1: 'linear',
2: 'parabolic',
3: 'exponential',
4: 'other'},
1: {1: 'linear',
2: 'parabolic',
3: 'exponential',
4: 'other'}},
'pos': 132,
'type': 'int16'},
'TaperType': {'descr': {0: {1: 'linear', 2: 'cos2c', 3: 'other'},
1: {1: 'linear', 2: 'cos2c', 3: 'other'}},
'pos': 138,
'type': 'int16'},
'TimeBaseCode': {'descr': {0: {1: 'Local', 2: 'GMT', 3: 'Other'},
1: {1: 'Local', 2: 'GMT', 3: 'Other', 4: 'UTC'}},
'pos': 166,
'type': 'int16'},
'TotalStaticApplied': {'type': 'int16', 'pos': 102},
'TraceIdenitifactionCode': {'descr': {0: {1: 'Seismic data',
2: 'Dead',
3: 'Dummy',
4: 'Time Break',
5: 'Uphole',
6: 'Sweep',
7: 'Timing',
8: 'Water Break'},
1: {-1: 'Other',
0: 'Unknown',
1: 'Seismic data',
2: 'Dead',
3: 'Dummy',
4: 'Time break',
5: 'Uphole',
6: 'Sweep',
7: 'Timing',
8: 'Waterbreak',
9: 'Near-field gun signature',
10: 'Far-field gun signature',
11: 'Seismic pressure sensor',
12: 'Multicomponent seismic sensor - Vertical component',
13: 'Multicomponent seismic sensor - Cross-line component',
14: 'Multicomponent seismic sensor - In-line component',
15: 'Rotated multicomponent seismic sensor - Vertical component',
16: 'Rotated multicomponent seismic sensor - Transverse component',
17: 'Rotated multicomponent seismic sensor - Radial component',
18: 'Vibrator reaction mass',
19: 'Vibrator baseplate',
20: 'Vibrator estimated ground force',
21: 'Vibrator reference',
22: 'Time-velocity pairs'}},
'pos': 28,
'type': 'uint16'},
'TraceIdentifier': {'type': 'int16', 'pos': 212},
'TraceNumber': {'type': 'int32', 'pos': 12},
'TraceSequenceFile': {'type': 'int32', 'pos': 4},
'TraceSequenceLine': {'type': 'int32', 'pos': 0},
'TraceValueMeasurementUnit': {'descr': {1: {-1: 'Other',
0: 'Unknown (should be described in Data Sample Measurement Units Stanza) ',
1: 'Pascal (Pa)',
2: 'Volts (V)',
3: 'Millivolts (v)',
4: 'Amperes (A)',
5: 'Meters (m)',
6: 'Meters Per Second (m/s)',
7: 'Meters Per Second squared (m/&s2)Other',
8: 'Newton (N)',
9: 'Watt (W)'}},
'pos': 202,
'type': 'int16'},
'TraceWeightningFactor': {'type': 'int16', 'pos': 168},
'TransductionConstantMantissa': {'type': 'int32', 'pos': 204},
'TransductionConstantPower': {'type': 'int16', 'pos': 208},
'TransductionUnit': {'descr': {1: {-1: 'Other',
0: 'Unknown (should be described in Data Sample Measurement Units Stanza) ',
1: 'Pascal (Pa)',
2: 'Volts (V)',
3: 'Millivolts (v)',
4: 'Amperes (A)',
5: 'Meters (m)',
6: 'Meters Per Second (m/s)',
7: 'Meters Per Second squared (m/&s2)Other', 8: 'Newton (N)',
9: 'Watt (W)'}},
'pos': 210,
'type': 'int16'},
'UnassignedInt1': {'type': 'int32', 'pos': 232},
'UnassignedInt2': {'type': 'int32', 'pos': 236},
'WeatheringVelocity': {'type': 'int16', 'pos': 90},
'YearDataRecorded': {'type': 'int16', 'pos': 156},
'cdp': {'type': 'int32', 'pos': 20},
'cdpTrace': {'type': 'int32', 'pos': 24},
'cdpX': {'type': 'int32', 'pos': 180},
'cdpY': {'type': 'int32', 'pos': 184},
'dt': {'type': 'uint16', 'pos': 116},
'ns': {'type': 'uint16', 'pos': 114},
'offset': {'type': 'int32', 'pos': 36}}