How to get a lat/lon for each trace from SEG-Y file?

Hi,

I want to create a map with GPR-tracks. I have file.sgy (SEG-Y file format) and I'm trying to use obspy to extract lat/lon from this file for each trace, but without any success.

There is my code:

from obspy.core import read

filename = '/data/file.sgy'
st = read(filename)
tr = st[0] # first trace

print tr.stats.segy # metadata for trace 1

'''
AttribDict({'trace_header': LazyTraceHeaderAttribDict({'x_coordinate_of_ensemble_position_of_this_trace': -1353777152, 'year_data_recorded': 0, u'unpacked_header': '\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\t\x00\x01\x00\x01\x00\x01\x00\x00\x00\x00\x00ff\x14B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x18\xfcC\xb8\xd5E\xf3-\xbdE\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\xd1\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00O\xaf\x94e\x08\xb7\xba@\xc4B\xadi\xbe\xa5\xb7@\x1c\x0e\x8f\xf2\xfd\xc0YAG\xb8\x98\xe75\\\x1dA*\xf0\x07\xceJ\xaf\xe1\xeaH\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00UU\xff\x00', 'y_coordinate_of_ensemble_position_of_this_trace': -1224186476, 'trace_sequence_number_within_line': 1, u'endian': u'<', 'sample_interval_in_ms_for_this_trace': 977})})

'''

# get coords
x_coord = tr.stats.segy.trace_header.x_coordinate_of_ensemble_position_of_this_trace
y_coord = tr.stats.segy.trace_header.y_coordinate_of_ensemble_position_of_this_trace

print str(x_coord) + ' ' + str(y_coord)

The result is a couple coords in strange format: -1353777152 -1224186476. What kind of coordinate system? Maybe I'm doing something wrong?

Hi,

the trace headers are unpacked lazily, if you want to unpack them during reading, use

obspy.read(filename, unpack_trace_headers=True)

What the header values actually are and especially the coordinate system is fairly complex, please consult the SEG-Y documentation for that:

http://www.seg.org/documents/10161/77915/seg_y_rev1.pdf

Cheers!

Lion

Thanks, Lion

After applying unpack_trace_headers flag, the metadata route now looks like this:

'''
         network:
         station:
        location:
         channel:
       starttime: 1970-01-01T00:00:00.000000Z
         endtime: 1970-01-01T00:00:00.499247Z
   sampling_rate: 1023.54145343
           delta: 0.000977
            npts: 512
           calib: 1.0
         _format: SEGY
            segy: AttribDict({'trace_header': AttribDict({'receiver_group_elevation': 1108633190, 'ensemble_number': 2, 'unassigned': '\x00\x00\x00\x00UU\x00\x00', 'sweep_length_in_ms': 0, 'data_use': 1, 'original_field_record_number': 2, 'year_data_recorded': 0, 'datum_elevation_at_receiver_group': 0, 'day_of_year': 0, 'hour_of_day': 0, 'sample_interval_in_ms_for_this_trace': 977, 'number_of_samples_in_this_trace': 512, 'taper_type': 0, 'x_coordinate_of_ensemble_position_of_this_trace': -1353777152, 'gap_size': 0, 'geophone_group_number_of_trace_number_one': 0, 'low_cut_slope': 0, 'coordinate_units': 2, 'group_coordinate_y': 0, 'group_coordinate_x': 32, 'source_measurement_exponent': 0, 'instrument_early_or_initial_gain': 0, 'for_3d_poststack_data_this_field_is_for_in_line_number': 1120157882, 'source_energy_direction_exponent': 72, 'distance_from_center_of_the_source_point_to_the_center_of_the_receiver_group': 0, 'trace_weighting_factor': 0, 'mute_time_end_time_in_ms': 0, 'trace_number_within_the_ensemble': 1, 'number_of_horizontally_stacked_traces_yielding_this_trace': 1, 'geophone_group_number_of_last_trace': 0, 'over_travel_associated_with_taper': 0, 'number_of_vertically_summed_traces_yielding_this_trace': 1, 'unpacked_header': None, 'scalar_to_be_applied_to_times': -3841, 'scalar_to_be_applied_to_all_elevations_and_depths': 1, 'energy_source_point_number': 0, 'water_depth_at_source': 0, 'for_3d_poststack_data_this_field_is_for_cross_line_number': -1514247763, 'notch_filter_frequency': 0, 'source_static_correction_in_ms': 0, 'instrument_gain_constant': 0, 'sweep_trace_taper_length_at_start_in_ms': 0, 'high_cut_frequency': 0, 'lag_time_B': 0, 'lag_time_A': 0, 'high_cut_slope': 0, 'minute_of_hour': 0, 'uphole_time_at_source_in_ms': 0, 'scalar_to_be_applied_to_all_coordinates': -1000, 'shotpoint_number': 236732599, 'device_trace_identifier': 16669, 'subweathering_velocity': 0, 'source_depth_below_surface': 0, 'trace_sequence_number_within_line': 2, 'sweep_trace_taper_length_at_end_in_ms': 0, 'delay_recording_time': 0, 'weathering_velocity': 0, 'source_coordinate_x': 1171634243, 'source_coordinate_y': 1170025971, 'source_type_orientation': -12793, 'mute_time_start_time_in_ms': 0, 'sweep_frequency_at_end': 0, 'total_static_applied_in_ms': 0, 'time_basis_code': 2, 'group_static_correction_in_ms': 0, 'sweep_type': 0, 'surface_elevation_at_source': 0, 'alias_filter_frequency': 0, 'low_cut_frequency': 0, 'endian': u'<', 'trace_identification_code': 9, 'source_measurement_mantissa': 0, 'scalar_to_be_applied_to_the_shotpoint_number': -3441, 'source_measurement_unit': 0, 'source_energy_direction_mantissa': -354308278, 'second_of_minute': 0, 'trace_sequence_number_within_segy_file': 0, 'transduction_constant_exponent': -6248, 'alias_filter_slope': 0, 'sweep_frequency_at_start': 0, 'uphole_time_at_group_in_ms': 0, 'gain_type_of_field_instruments': 0, 'trace_value_measurement_unit': -16131, 'trace_number_within_the_original_field_record': 1, 'transduction_units': 23605, 'y_coordinate_of_ensemble_position_of_this_trace': -1224186476, 'notch_filter_slope': 0, 'geophone_group_number_of_roll_switch_position_one': 0, 'correlated': 0, 'datum_elevation_at_source': 0, 'water_depth_at_group': 0, 'transduction_constant_mantissa': -1203289767})})
'''

After reading the SEG-Y documentation I find that:

if trace.stats.segy.trace_header.scalar_to_be_applied_to_all_coordinates = 1000, then we should divide source coordinates by 1000

if trace.stats.segy.trace_header.coordinate_units = 2, then coordinate units are in Seconds of arc (need to divide by 3600 to degree conversion)

As result the formula to decimal degree conversion from raw SEG-Y data is:

decimal degree = source_coordinate / 1000 / 3600 = 1170025971 / 3600000 = 325

But I expect to see the value near 60 degree.
Maybe I have something I do not take into account?

Hi,

the trace headers are unpacked lazily, if you want to unpack them during reading, use

obspy.read(filename, unpack_trace_headers=True)

What the header values actually are and especially the coordinate system is fairly complex, please consult the SEG-Y documentation for that:

http://www.seg.org/documents/10161/77915/seg_y_rev1.pdf

Cheers!

Lion

Hi,

I want to create a map with GPR-tracks. I have file.sgy (SEG-Y file format) and I'm trying
to use obspy to extract lat/lon from this file for each trace, but without any success.

There is my code:

from obspy.core import read

filename = '/data/file.sgy'
st = read(filename)
tr = st[0] # first trace

print tr.stats.segy # metadata for trace 1

'''
AttribDict({'trace_header': LazyTraceHeaderAttribDict({'x_coordinate_of_ensemble_position_of_this_trace':
-1353777152, 'year_data_recorded': 0, u'unpacked_header': '\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\t\x00\x01\x00\x01\x00\x01\x00\x00\x00\x00\x00ff\x14B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x18\xfcC\xb8\xd5E\xf3-\xbdE\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\xd1\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00O\xaf\x94e\x08\xb7\xba@\xc4B\xadi\xbe\xa5\xb7@\x1c\x0e\x8f\xf2\xfd\xc0YAG\xb8\x98\xe75\\\x1dA*\xf0\x07\xceJ\xaf\xe1\xeaH
\x00\x00
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00UU\xff\x00', 'y_coordinate_of_ensemble_position_of_this_trace':
-1224186476, 'trace_sequence_number_within_line': 1, u'endian': u'<', 'sample_interval_in_ms_for_this_trace':
977})})

'''

# get coords
x_coord = tr.stats.segy.trace_header.x_coordinate_of_ensemble_position_of_this_trace
y_coord = tr.stats.segy.trace_header.y_coordinate_of_ensemble_position_of_this_trace

print str(x_coord) + ' ' + str(y_coord)

The result is a couple coords in strange format: -1353777152 -1224186476. What kind
of coordinate system? Maybe I'm doing something wrong?

_______________________________________________
obspy-users mailing list
obspy-users@lists.swapbytes.de
http://lists.swapbytes.de/mailman/listinfo/obspy-users

_______________________________________________
obspy-users mailing list
obspy-users@lists.swapbytes.de
http://lists.swapbytes.de/mailman/listinfo/obspy-users

- - - - - - - - - - -
Ilya Filippov
Yugra State University (Chekhova str. 16, Khanty-Mansiysk, Tyumen' Region, Russian Federation, 628012):

1. Environmental Dynamics & Global Climate Change Research Centre, Senior Engineer
2. Biology Chair, Docent
3. Journal of Environmental Dynamics & Global Climate Change, Editorial Board Member

GoogleScholar profile: http://scholar.google.ru/citations?user=Prc5qkMAAAAJ

Tel: +79088817605

Hi Ilya.

Appendix D in the SEG-Y manual deals with coordinate systems at length. You will need to figure out the coordinate system used in the SEG-Y file and then convert to whatever coordinate system you need.

To get the file wide headers, you will have to directly use the underlying readSEGY() function as the file wide headers are otherwise lost.

from obspy.segy.segy import readSEGY
st = readSEGY(filename)

then the headers are at st.stats.

Cheers!

Lion

I'm trying:

from obspy.segy.segy import readSEGY
st = readSEGY(filename)
st.stats

But I have an error: 'SEGYFile' object has no attribute 'stats'

Then I try:

tr = st.traces[0]
tr.header

As result we have headers, but I'm don't find CRS params:

trace_sequence_number_within_line: 1
trace_sequence_number_within_segy_file: 0
original_field_record_number: 1
trace_number_within_the_original_field_record: 1
energy_source_point_number: 0
ensemble_number: 1
trace_number_within_the_ensemble: 1
trace_identification_code: 9
number_of_vertically_summed_traces_yielding_this_trace: 1
number_of_horizontally_stacked_traces_yielding_this_trace: 1
data_use: 1
distance_from_center_of_the_source_point_to_the_center_of_the_receiver_group: 0
receiver_group_elevation: 1110101197
surface_elevation_at_source: 0
source_depth_below_surface: 0
datum_elevation_at_receiver_group: 0
datum_elevation_at_source: 0
water_depth_at_source: 0
water_depth_at_group: 0
scalar_to_be_applied_to_all_elevations_and_depths: 1
scalar_to_be_applied_to_all_coordinates: -1000
source_coordinate_x: 1171639576
source_coordinate_y: 1170025897
group_coordinate_x: 0
group_coordinate_y: 0
coordinate_units: 2
weathering_velocity: 0
subweathering_velocity: 0
uphole_time_at_source_in_ms: 0
uphole_time_at_group_in_ms: 0
source_static_correction_in_ms: 0
group_static_correction_in_ms: 0
total_static_applied_in_ms: 0
lag_time_A: 0
lag_time_B: 0
delay_recording_time: 20547
mute_time_start_time_in_ms: 0
mute_time_end_time_in_ms: 0
number_of_samples_in_this_trace: 512
sample_interval_in_ms_for_this_trace: 977
gain_type_of_field_instruments: 0
instrument_gain_constant: 0
instrument_early_or_initial_gain: 0
correlated: 0
sweep_frequency_at_start: 0
sweep_frequency_at_end: 0
sweep_length_in_ms: 0
sweep_type: 0
sweep_trace_taper_length_at_start_in_ms: 0
sweep_trace_taper_length_at_end_in_ms: 0
taper_type: 0
alias_filter_frequency: 0
alias_filter_slope: 0
notch_filter_frequency: 0
notch_filter_slope: 0
low_cut_frequency: 0
high_cut_frequency: 0
low_cut_slope: 0
high_cut_slope: 0
year_data_recorded: 0
day_of_year: 0
hour_of_day: 0
minute_of_hour: 0
second_of_minute: 0
time_basis_code: 2
trace_weighting_factor: 0
geophone_group_number_of_roll_switch_position_one: 0
geophone_group_number_of_trace_number_one: 0
geophone_group_number_of_last_trace: 0
gap_size: 0
over_travel_associated_with_taper: 0
x_coordinate_of_ensemble_position_of_this_trace: -556597248
y_coordinate_of_ensemble_position_of_this_trace: -1180496928
for_3d_poststack_data_this_field_is_for_in_line_number: 178667706
for_3d_poststack_data_this_field_is_for_cross_line_number: -1514855098
shotpoint_number: 908411063
scalar_to_be_applied_to_the_shotpoint_number: 14515
trace_value_measurement_unit: -16150
transduction_constant_mantissa: 791757145
transduction_constant_exponent: 27515
transduction_units: -32511
device_trace_identifier: 16669
scalar_to_be_applied_to_times: 21034
source_type_orientation: -12793
source_energy_direction_mantissa: -335017142
source_energy_direction_exponent: 72
source_measurement_mantissa: 0
source_measurement_exponent: 0
source_measurement_unit: 0

Hi Ilya.

Appendix D in the SEG-Y manual deals with coordinate systems at length. You will need to figure out the coordinate system used in the SEG-Y file and then convert to whatever coordinate system you need.

To get the file wide headers, you will have to directly use the underlying readSEGY() function as the file wide headers are otherwise lost.

�from obspy.segy.segy import readSEGY
�st = readSEGY(filename)

then the headers are at st.stats.

Cheers!

Lion

�Thanks, Lion

�After applying unpack_trace_headers flag, the metadata route now looks like this:

�'''
�network:
�station:
�location:
�channel:
�starttime: 1970-01-01T00:00:00.000000Z
�endtime: 1970-01-01T00:00:00.499247Z
�sampling_rate: 1023.54145343
�delta: 0.000977
�npts: 512
�calib: 1.0
�_format: SEGY
�segy: AttribDict({'trace_header': AttribDict({'receiver_group_elevation':
�1108633190, 'ensemble_number': 2, 'unassigned': '\x00\x00\x00\x00UU\x00\x00',
�'sweep_length_in_ms': 0, 'data_use': 1, 'original_field_record_number': 2, 'year_data_recorded':
�0, 'datum_elevation_at_receiver_group': 0, 'day_of_year': 0, 'hour_of_day': 0,
�'sample_interval_in_ms_for_this_trace': 977, 'number_of_samples_in_this_trace':
�512, 'taper_type': 0, 'x_coordinate_of_ensemble_position_of_this_trace': -1353777152,
�'gap_size': 0, 'geophone_group_number_of_trace_number_one': 0, 'low_cut_slope':
�0, 'coordinate_units': 2, 'group_coordinate_y': 0, 'group_coordinate_x': 32, 'source_measurement_exponent':
�0, 'instrument_early_or_initial_gain': 0, 'for_3d_poststack_data_this_field_is_for_in_line_number':
�1120157882, 'source_energy_direction_exponent': 72, 'distance_from_center_of_the_source_point_to_the_center_of_the_receiver_group':
�0, 'trace_weighting_factor': 0, 'mute_time_end_time_in_ms': 0, 'trace_number_within_the_ensemble':
�1, 'number_of_horizontally_stacked_traces_yielding_this_trace': 1, 'geophone_group_number_of_last_trace':
�0, 'over_travel_associated_with_taper': 0, 'number_of_vertically_summed_traces_yielding_this_trace':
�1, 'unpacked_header': None, 'scalar_to_be_applied_to_times': -3841, 'scalar_to_be_applied_to_all_elevations_and_depths':
�1, 'energy_source_point_number': 0, 'water_depth_at_source': 0, 'for_3d_poststack_data_this_field_is_for_cross_line_number':
�-1514247763, 'notch_filter_frequency': 0, 'source_static_correction_in_ms':
�0, 'instrument_gain_constant': 0, 'sweep_trace_taper_length_at_start_in_ms':
�0, 'high_cut_frequency': 0, 'lag_time_B': 0, 'lag_time_A': 0, 'high_cut_slope':
�0, 'minute_of_hour': 0, 'uphole_time_at_source_in_ms': 0, 'scalar_to_be_applied_to_all_coordinates':
�-1000, 'shotpoint_number': 236732599, 'device_trace_identifier': 16669, 'subweathering_velocity':
�0, 'source_depth_below_surface': 0, 'trace_sequence_number_within_line': 2,
�'sweep_trace_taper_length_at_end_in_ms': 0, 'delay_recording_time': 0, 'weathering_velocity':
�0, 'source_coordinate_x': 1171634243, 'source_coordinate_y': 1170025971, 'source_type_orientation':
�-12793, 'mute_time_start_time_in_ms': 0, 'sweep_frequency_at_end': 0, 'total_static_applied_in_ms':
�0, 'time_basis_code': 2, 'group_static_correction_in_ms': 0, 'sweep_type': 0,
�'surface_elevation_at_source': 0, 'alias_filter_frequency': 0, 'low_cut_frequency':
�0, 'endian': u'<', 'trace_identification_code': 9, 'source_measurement_mantissa':
�0, 'scalar_to_be_applied_to_the_shotpoint_number': -3441, 'source_measurement_unit':
�0, 'source_energy_direction_mantissa': -354308278, 'second_of_minute': 0, 'trace_sequence_number_within_segy_file':
�0, 'transduction_constant_exponent': -6248, 'alias_filter_slope': 0, 'sweep_frequency_at_start':
�0, 'uphole_time_at_group_in_ms': 0, 'gain_type_of_field_instruments': 0, 'trace_value_measurement_unit':
�-16131, 'trace_number_within_the_original_field_record': 1, 'transduction_units':
�23605, 'y_coordinate_of_ensemble_position_of_this_trace': -1224186476, 'notch_filter_slope':
�0, 'geophone_group_number_of_roll_switch_position_one': 0, 'correlated': 0,
�'datum_elevation_at_source': 0, 'water_depth_at_group': 0, 'transduction_constant_mantissa':
�-1203289767})})
�'''

�After reading the SEG-Y documentation I find that:

�if trace.stats.segy.trace_header.scalar_to_be_applied_to_all_coordinates
�= 1000, then we should divide source coordinates by 1000

�if trace.stats.segy.trace_header.coordinate_units = 2, then coordinate units are
�in Seconds of arc (need to divide by 3600 to degree conversion)

�As result the formula to decimal degree conversion from raw SEG-Y data is:

�decimal degree = source_coordinate / 1000 / 3600 = 1170025971 / 3600000 = 325

�But I expect to see the value near 60 degree.
�Maybe I have something I do not take into account?

�31.03.2015, 15:01, "Lion Krischer" :

�Hi,

�the trace headers are unpacked lazily, if you want to unpack them during reading, use

�obspy.read(filename, unpack_trace_headers=True)

�What the header values actually are and especially the coordinate system is fairly

�complex, please consult the SEG-Y documentation for that:

�http://www.seg.org/documents/10161/77915/seg_y_rev1.pdf

�Cheers!

�Lion

�Hi,

�I want to create a map with GPR-tracks. I have file.sgy (SEG-Y file format) and I'm trying
�to use obspy to extract lat/lon from this file for each trace, but without any success.

�There is my code:

�from obspy.core import read

�filename = '/data/file.sgy'
�st = read(filename)
�tr = st[0] # first trace

�print tr.stats.segy # metadata for trace 1

�'''
�AttribDict({'trace_header': LazyTraceHeaderAttribDict({'x_coordinate_of_ensemble_position_of_this_trace':
�-1353777152, 'year_data_recorded': 0, u'unpacked_header': '\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\t\x00\x01\x00\x01\x00\x01\x00\x00\x00\x00\x00ff\x14B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x18\xfcC\xb8\xd5E\xf3-\xbdE\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\xd1\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00O\xaf\x94e\x08\xb7\xba@\xc4B\xadi\xbe\xa5\xb7@\x1c\x0e\x8f\xf2\xfd\xc0YAG\xb8\x98\xe75\\\x1dA*\xf0\x07\xceJ\xaf\xe1\xeaH
�\x00\x00
�\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00UU\xff\x00', 'y_coordinate_of_ensemble_position_of_this_trace':
�-1224186476, 'trace_sequence_number_within_line': 1, u'endian': u'<', 'sample_interval_in_ms_for_this_trace':
�977})})

�'''

�# get coords
�x_coord = tr.stats.segy.trace_header.x_coordinate_of_ensemble_position_of_this_trace
�y_coord = tr.stats.segy.trace_header.y_coordinate_of_ensemble_position_of_this_trace

�print str(x_coord) + ' ' + str(y_coord)

�The result is a couple coords in strange format: -1353777152 -1224186476. What kind
�of coordinate system? Maybe I'm doing something wrong?

�_______________________________________________
�obspy-users mailing list
�obspy-users@lists.swapbytes.de
�http://lists.swapbytes.de/mailman/listinfo/obspy-users

�_______________________________________________
�obspy-users mailing list
�obspy-users@lists.swapbytes.de
�http://lists.swapbytes.de/mailman/listinfo/obspy-users

�- - - - - - - - - - -
�Ilya Filippov
�Yugra State University (Chekhova str. 16, Khanty-Mansiysk, Tyumen' Region, Russian
�Federation, 628012):

�1. Environmental Dynamics & Global Climate Change Research Centre, Senior Engineer
�2. Biology Chair, Docent
�3. Journal of Environmental Dynamics & Global Climate Change, Editorial Board Member

�GoogleScholar profile: http://scholar.google.ru/citations?user=Prc5qkMAAAAJ

�Tel: +79088817605
�_______________________________________________
�obspy-users mailing list
�obspy-users@lists.swapbytes.de
�http://lists.swapbytes.de/mailman/listinfo/obspy-users

_______________________________________________
obspy-users mailing list
obspy-users@lists.swapbytes.de
http://lists.swapbytes.de/mailman/listinfo/obspy-users

- - - - - - - - - - -
Ilya Filippov
Yugra State University (Chekhova str. 16, Khanty-Mansiysk, Tyumen' Region, Russian Federation, 628012):

1. Environmental Dynamics & Global Climate Change Research Centre, Senior Engineer
2. Biology Chair, Docent
3. Journal of Environmental Dynamics & Global Climate Change, Editorial Board Member

GoogleScholar profile: http://scholar.google.ru/citations?user=Prc5qkMAAAAJ

Tel: +79088817605

My bad. The following works:

from obspy.segy.segy import readSEGY
st = readSEGY(filename)

binary file header:

st.binary_file_header

textual file header:

st.textual_file_header

These things are really easy to figure out by just executing it in ipython and using tab completion.

Cheers!

Lion

Thanks for ipython, I have discovered ipython notebook - it is very powerful feature!

from obspy.segy.segy import readSEGY
st = readSEGY(filename)
print st.binary_file_header
print st.textual_file_header

Below is a print output. Text header is in cyrillic, but it not contain useful information about CRS, and looks like
"Positioning: GPS + take into account WGS-84 geoid correction"

I can guess, that CRS is UTM zone 42, but I'm not understand how I may get right coordinates from SEG-Y with ObsPy.

Real coordinates of first point in geographic system (WGS-84) (from proprietary soft): 60°53'42.4512''N;68°41'38.2031''E
Real coordinates of first point in UTM zone 42N (WGS-84) (from proprietary soft): 6751144.89;483392.35

The source coordinates from ts.header output is and it looks very strange:

source_coordinate_x: 1171639576
source_coordinate_y: 1170025897

I also attach sample sgy file.

Binary File Header:
  job_identification_number: 1
  line_number: 1
  reel_number: 1
  number_of_data_traces_per_ensemble: 1
  number_of_auxiliary_traces_per_ensemble: 0
  sample_interval_in_microseconds: 977
  sample_interval_in_microseconds_of_original_field_recording: 0
  number_of_samples_per_data_trace: 512
  number_of_samples_per_data_trace_for_original_field_recording: 0
  data_sample_format_code: 3
  ensemble_fold: 1
  trace_sorting_code: 0
  vertical_sum_code: 0
  sweep_frequency_at_start: 0
  sweep_frequency_at_end: 0
  sweep_length: 0
  sweep_type_code: 0
  trace_number_of_sweep_channel: 0
  sweep_trace_taper_length_in_ms_at_start: 0
  sweep_trace_taper_length_in_ms_at_end: 0
  taper_type: 0
  correlated_data_traces: 0
  binary_gain_recovered: 0
  amplitude_recovery_method: 0
  measurement_system: 1
  impulse_signal_polarity: 0
  vibratory_polarity_code: 0
  unassigned_1:
  seg_y_format_revision_number: 0
  fixed_length_trace_flag: 0
  number_of_3200_byte_ext_file_header_records_following: 0
  unassigned_2:

print st.textual_file_header

This SEG-Y format data file was generated by Prism 2.59.3 (Build 12.0319) software. (c) Radar Systems, Inc. (www.radsys.lv)
The SEG-Y format is intended for seismic (not georadar) data.
Due to this fact, some lucks of correspondence to SEG-Y format occur:
1. The SEG-Y EDCBIC Reel Header filled by this textual information.
2. All time-based values represented in PICOseconds (not in MICROseconds!).
3. Relative dielectric constant of medium stored here: E=64
4. Any trace may have so-called mark (positive number). This mark
   placed as unsigned integer (2 bytes) in 239 and 240-th bytes of Trace Header.
   A 237 and 238-th bytes are always equal to 55H. It is mark's indicator.

Georadar's settings information:

����: 28.03.2015
�������: 300 Mhz, shielded
��������� ��������: 500 ��, 9.38 �
����� ������������: �������� ����, 64
������� � ������: 512
����� �������: ����� 1
��������: 0 / 48
���: ����� �������
����������: ����.
������� �����: 80
��������: 279
����������������: GPS + ��������� �������� ������������ ������ WGS-84
Prism version 2.59.3 (Build 12.0319)

My bad. The following works:

from obspy.segy.segy import readSEGY
st = readSEGY(filename)

binary file header:

st.binary_file_header

textual file header:

st.textual_file_header

These things are really easy to figure out by just executing it in ipython and using tab completion.

Cheers!

Lion

I'm trying:

from obspy.segy.segy import readSEGY
st = readSEGY(filename)
st.stats

But I have an error: 'SEGYFile' object has no attribute 'stats'

Then I try:

tr = st.traces[0]
tr.header

As result we have headers, but I'm don't find CRS params:

trace_sequence_number_within_line: 1
trace_sequence_number_within_segy_file: 0
original_field_record_number: 1
trace_number_within_the_original_field_record: 1
energy_source_point_number: 0
ensemble_number: 1
trace_number_within_the_ensemble: 1
trace_identification_code: 9
number_of_vertically_summed_traces_yielding_this_trace: 1
number_of_horizontally_stacked_traces_yielding_this_trace: 1
data_use: 1
distance_from_center_of_the_source_point_to_the_center_of_the_receiver_group:
0
receiver_group_elevation: 1110101197
surface_elevation_at_source: 0
source_depth_below_surface: 0
datum_elevation_at_receiver_group: 0
datum_elevation_at_source: 0
water_depth_at_source: 0
water_depth_at_group: 0
scalar_to_be_applied_to_all_elevations_and_depths: 1
scalar_to_be_applied_to_all_coordinates: -1000
source_coordinate_x: 1171639576
source_coordinate_y: 1170025897
group_coordinate_x: 0
group_coordinate_y: 0
coordinate_units: 2
weathering_velocity: 0
subweathering_velocity: 0
uphole_time_at_source_in_ms: 0
uphole_time_at_group_in_ms: 0
source_static_correction_in_ms: 0
group_static_correction_in_ms: 0
total_static_applied_in_ms: 0
lag_time_A: 0
lag_time_B: 0
delay_recording_time: 20547
mute_time_start_time_in_ms: 0
mute_time_end_time_in_ms: 0
number_of_samples_in_this_trace: 512
sample_interval_in_ms_for_this_trace: 977
gain_type_of_field_instruments: 0
instrument_gain_constant: 0
instrument_early_or_initial_gain: 0
correlated: 0
sweep_frequency_at_start: 0
sweep_frequency_at_end: 0
sweep_length_in_ms: 0
sweep_type: 0
sweep_trace_taper_length_at_start_in_ms: 0
sweep_trace_taper_length_at_end_in_ms: 0
taper_type: 0
alias_filter_frequency: 0
alias_filter_slope: 0
notch_filter_frequency: 0
notch_filter_slope: 0
low_cut_frequency: 0
high_cut_frequency: 0
low_cut_slope: 0
high_cut_slope: 0
year_data_recorded: 0
day_of_year: 0
hour_of_day: 0
minute_of_hour: 0
second_of_minute: 0
time_basis_code: 2
trace_weighting_factor: 0
geophone_group_number_of_roll_switch_position_one: 0
geophone_group_number_of_trace_number_one: 0
geophone_group_number_of_last_trace: 0
gap_size: 0
over_travel_associated_with_taper: 0
x_coordinate_of_ensemble_position_of_this_trace: -556597248
y_coordinate_of_ensemble_position_of_this_trace: -1180496928
for_3d_poststack_data_this_field_is_for_in_line_number: 178667706
for_3d_poststack_data_this_field_is_for_cross_line_number: -1514855098
shotpoint_number: 908411063
scalar_to_be_applied_to_the_shotpoint_number: 14515
trace_value_measurement_unit: -16150
transduction_constant_mantissa: 791757145
transduction_constant_exponent: 27515
transduction_units: -32511
device_trace_identifier: 16669
scalar_to_be_applied_to_times: 21034
source_type_orientation: -12793
source_energy_direction_mantissa: -335017142
source_energy_direction_exponent: 72
source_measurement_mantissa: 0
source_measurement_exponent: 0
source_measurement_unit: 0

31.03.2015, 17:16, "Lion Krischer" :

Hi Ilya.

Appendix D in the SEG-Y manual deals with coordinate systems at length. You will need

to figure out the coordinate system used in the SEG-Y file and then convert to whatever
coordinate system you need.

To get the file wide headers, you will have to directly use the underlying readSEGY()

function as the file wide headers are otherwise lost.

from obspy.segy.segy import readSEGY
st = readSEGY(filename)

then the headers are at st.stats.

Cheers!

Lion

Thanks, Lion

After applying unpack_trace_headers flag, the metadata route now looks like this:

'''
network:
station:
location:
channel:
starttime: 1970-01-01T00:00:00.000000Z
endtime: 1970-01-01T00:00:00.499247Z
sampling_rate: 1023.54145343
delta: 0.000977
npts: 512
calib: 1.0
_format: SEGY
segy: AttribDict({'trace_header': AttribDict({'receiver_group_elevation':
1108633190, 'ensemble_number': 2, 'unassigned': '\x00\x00\x00\x00UU\x00\x00',
'sweep_length_in_ms': 0, 'data_use': 1, 'original_field_record_number': 2,

'year_data_recorded':

0, 'datum_elevation_at_receiver_group': 0, 'day_of_year': 0, 'hour_of_day':

0,

'sample_interval_in_ms_for_this_trace': 977, 'number_of_samples_in_this_trace':
512, 'taper_type': 0, 'x_coordinate_of_ensemble_position_of_this_trace':

-1353777152,

'gap_size': 0, 'geophone_group_number_of_trace_number_one': 0, 'low_cut_slope':
0, 'coordinate_units': 2, 'group_coordinate_y': 0, 'group_coordinate_x': 32,

'source_measurement_exponent':

0, 'instrument_early_or_initial_gain': 0, 'for_3d_poststack_data_this_field_is_for_in_line_number':
1120157882, 'source_energy_direction_exponent': 72, 'distance_from_center_of_the_source_point_to_the_center_of_the_receiver_group':
0, 'trace_weighting_factor': 0, 'mute_time_end_time_in_ms': 0, 'trace_number_within_the_ensemble':
1, 'number_of_horizontally_stacked_traces_yielding_this_trace': 1, 'geophone_group_number_of_last_trace':
0, 'over_travel_associated_with_taper': 0, 'number_of_vertically_summed_traces_yielding_this_trace':
1, 'unpacked_header': None, 'scalar_to_be_applied_to_times': -3841, 'scalar_to_be_applied_to_all_elevations_and_depths':
1, 'energy_source_point_number': 0, 'water_depth_at_source': 0, 'for_3d_poststack_data_this_field_is_for_cross_line_number':
-1514247763, 'notch_filter_frequency': 0, 'source_static_correction_in_ms':
0, 'instrument_gain_constant': 0, 'sweep_trace_taper_length_at_start_in_ms':
0, 'high_cut_frequency': 0, 'lag_time_B': 0, 'lag_time_A': 0, 'high_cut_slope':
0, 'minute_of_hour': 0, 'uphole_time_at_source_in_ms': 0, 'scalar_to_be_applied_to_all_coordinates':
-1000, 'shotpoint_number': 236732599, 'device_trace_identifier': 16669, 'subweathering_velocity':
0, 'source_depth_below_surface': 0, 'trace_sequence_number_within_line':

2,

'sweep_trace_taper_length_at_end_in_ms': 0, 'delay_recording_time': 0, 'weathering_velocity':
0, 'source_coordinate_x': 1171634243, 'source_coordinate_y': 1170025971, 'source_type_orientation':
-12793, 'mute_time_start_time_in_ms': 0, 'sweep_frequency_at_end': 0, 'total_static_applied_in_ms':
0, 'time_basis_code': 2, 'group_static_correction_in_ms': 0, 'sweep_type':

0,

'surface_elevation_at_source': 0, 'alias_filter_frequency': 0, 'low_cut_frequency':
0, 'endian': u'<', 'trace_identification_code': 9, 'source_measurement_mantissa':
0, 'scalar_to_be_applied_to_the_shotpoint_number': -3441, 'source_measurement_unit':
0, 'source_energy_direction_mantissa': -354308278, 'second_of_minute': 0,

'trace_sequence_number_within_segy_file':

0, 'transduction_constant_exponent': -6248, 'alias_filter_slope': 0, 'sweep_frequency_at_start':
0, 'uphole_time_at_group_in_ms': 0, 'gain_type_of_field_instruments': 0, 'trace_value_measurement_unit':
-16131, 'trace_number_within_the_original_field_record': 1, 'transduction_units':
23605, 'y_coordinate_of_ensemble_position_of_this_trace': -1224186476, 'notch_filter_slope':
0, 'geophone_group_number_of_roll_switch_position_one': 0, 'correlated':

0,

'datum_elevation_at_source': 0, 'water_depth_at_group': 0, 'transduction_constant_mantissa':
-1203289767})})
'''

After reading the SEG-Y documentation I find that:

if trace.stats.segy.trace_header.scalar_to_be_applied_to_all_coordinates
= 1000, then we should divide source coordinates by 1000

if trace.stats.segy.trace_header.coordinate_units = 2, then coordinate units

are

in Seconds of arc (need to divide by 3600 to degree conversion)

As result the formula to decimal degree conversion from raw SEG-Y data is:

decimal degree = source_coordinate / 1000 / 3600 = 1170025971 / 3600000 = 325

But I expect to see the value near 60 degree.
Maybe I have something I do not take into account?

31.03.2015, 15:01, "Lion Krischer" :

Hi,

the trace headers are unpacked lazily, if you want to unpack them during reading,

use

obspy.read(filename, unpack_trace_headers=True)

What the header values actually are and especially the coordinate system is fairly

complex, please consult the SEG-Y documentation for that:

http://www.seg.org/documents/10161/77915/seg_y_rev1.pdf

Cheers!

Lion

Hi,

I want to create a map with GPR-tracks. I have file.sgy (SEG-Y file format) and I'm

trying

to use obspy to extract lat/lon from this file for each trace, but without any success.

There is my code:

from obspy.core import read

filename = '/data/file.sgy'
st = read(filename)
tr = st[0] # first trace

print tr.stats.segy # metadata for trace 1

'''
AttribDict({'trace_header': LazyTraceHeaderAttribDict({'x_coordinate_of_ensemble_position_of_this_trace':
-1353777152, 'year_data_recorded': 0, u'unpacked_header': '\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\t\x00\x01\x00\x01\x00\x01\x00\x00\x00\x00\x00ff\x14B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x18\xfcC\xb8\xd5E\xf3-\xbdE\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\xd1\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00O\xaf\x94e\x08\xb7\xba@\xc4B\xadi\xbe\xa5\xb7@\x1c\x0e\x8f\xf2\xfd\xc0YAG\xb8\x98\xe75\\\x1dA*\xf0\x07\xceJ\xaf\xe1\xeaH
\x00\x00
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00UU\xff\x00', 'y_coordinate_of_ensemble_position_of_this_trace':
-1224186476, 'trace_sequence_number_within_line': 1, u'endian': u'<', 'sample_interval_in_ms_for_this_trace':
977})})

'''

# get coords
x_coord = tr.stats.segy.trace_header.x_coordinate_of_ensemble_position_of_this_trace
y_coord = tr.stats.segy.trace_header.y_coordinate_of_ensemble_position_of_this_trace

print str(x_coord) + ' ' + str(y_coord)

The result is a couple coords in strange format: -1353777152 -1224186476. What

kind

of coordinate system? Maybe I'm doing something wrong?

_______________________________________________
obspy-users mailing list
obspy-users@lists.swapbytes.de
http://lists.swapbytes.de/mailman/listinfo/obspy-users

_______________________________________________
obspy-users mailing list
obspy-users@lists.swapbytes.de
http://lists.swapbytes.de/mailman/listinfo/obspy-users

- - - - - - - - - - -
Ilya Filippov
Yugra State University (Chekhova str. 16, Khanty-Mansiysk, Tyumen' Region, Russian
Federation, 628012):

1. Environmental Dynamics & Global Climate Change Research Centre, Senior Engineer
2. Biology Chair, Docent
3. Journal of Environmental Dynamics & Global Climate Change, Editorial Board Member

GoogleScholar profile: http://scholar.google.ru/citations?user=Prc5qkMAAAAJ

Tel: +79088817605
_______________________________________________
obspy-users mailing list
obspy-users@lists.swapbytes.de
http://lists.swapbytes.de/mailman/listinfo/obspy-users

_______________________________________________
obspy-users mailing list
obspy-users@lists.swapbytes.de
http://lists.swapbytes.de/mailman/listinfo/obspy-users

- - - - - - - - - - -
Ilya Filippov
Yugra State University (Chekhova str. 16, Khanty-Mansiysk, Tyumen' Region, Russian
Federation, 628012):

1. Environmental Dynamics & Global Climate Change Research Centre, Senior Engineer
2. Biology Chair, Docent
3. Journal of Environmental Dynamics & Global Climate Change, Editorial Board Member

GoogleScholar profile: http://scholar.google.ru/citations?user=Prc5qkMAAAAJ

Tel: +79088817605
_______________________________________________
obspy-users mailing list
obspy-users@lists.swapbytes.de
http://lists.swapbytes.de/mailman/listinfo/obspy-users

_______________________________________________
obspy-users mailing list
obspy-users@lists.swapbytes.de
http://lists.swapbytes.de/mailman/listinfo/obspy-users

- - - - - - - - - - -
Ilya Filippov
Yugra State University (Chekhova str. 16, Khanty-Mansiysk, Tyumen' Region, Russian Federation, 628012):

1. Environmental Dynamics & Global Climate Change Research Centre, Senior Engineer
2. Biology Chair, Docent
3. Journal of Environmental Dynamics & Global Climate Change, Editorial Board Member

GoogleScholar profile: http://scholar.google.ru/citations?user=Prc5qkMAAAAJ

Tel: +79088817605

DAT_0350.sgy.zip (5.56 MB)