PIC-IRIS / PH5

Library of PH5 clients, apis, and utilities
Other
15 stars 9 forks source link

[BUG] ph5toevt: Event table entries with a numeric description_s cause ph5toevt crash with '-x U' #523

Closed Stephen-Veitch closed 6 months ago

Stephen-Veitch commented 8 months ago

When attempting to write segys for events whose description_s entry is a 9-digit numeric value ph5toevt crashes after producing a segy file with a single trace if 'extended_header_style' is set to U, 'Menlo USGS' (this is the default value).

This case produces a terminal output with handled errors prior to the crash, but the ERROR lines lack descriptions. The crash appears as python error messages. See terminal output below:

With the same event table, ph5toevt WILL NOT crash if the extended_header_style (-x) is set to P or S, and will generate complete and successful output.


[2023-12-22 22:48:50,073] - ph5.clients.ph5toevt - INFO: 2022.144: ['/home/ph5/anaconda3/envs/ph5/bin/ph5toevt', '-n', 'master.ph5', '--shot_line', '010', '--event_list', '01', '-c', '1', '-l', '30', '-A', '010', '-o', '../../testdata_0']
[2023-12-22 22:48:50,079] - ph5.clients.ph5toevt - INFO: Experiment: Advancing_Forest_Health_Assessment_Through_Mult-Method_Geophysical_Surveys_Case_Study_in_Snodgrass_Colorado
[2023-12-22 22:48:50,080] - ph5.clients.ph5toevt - INFO: Summary: [Summary paragraph scrubbed ]
[2023-12-22 22:48:50,080] - ph5.clients.ph5toevt - INFO: Extracting receivers for event 01.
[2023-12-22 22:48:50,120] - ph5.clients.ph5toevt - INFO: -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[2023-12-22 22:48:50,120] - ph5.clients.ph5toevt - INFO: Attempting to find data for station 00250.
[2023-12-22 22:48:50,170] - ph5.clients.ph5toevt - INFO: Applied time drift correction by                        shifting trace by -0.0 samples.
[2023-12-22 22:48:50,170] - ph5.clients.ph5toevt - INFO: Correction is 0 ms.
[2023-12-22 22:48:50,170] - ph5.clients.ph5toevt - INFO: Clock drift (seconds/second): 0.0
[2023-12-22 22:48:50,170] - ph5.clients.ph5toevt - INFO: Clock comment: No clock drift information available.
[2023-12-22 22:48:50,170] - ph5.clients.ph5toevt - INFO: =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
[2023-12-22 22:48:50,170] - ph5.clients.ph5toevt - INFO: trace: 1
[2023-12-22 22:48:50,170] - ph5.clients.ph5toevt - INFO: Extracted: Station ID 00250
[2023-12-22 22:48:50,170] - ph5.clients.ph5toevt - INFO: Chan: 1 Start: 2023-10-11 17:19:00+00:00, Stop: 2023-10-11 17:19:30+00:00.
[2023-12-22 22:48:50,170] - ph5.clients.ph5toevt - INFO: Lat: 38.930012 Lon: -106.976867 Elev: 3108.610000 m
[2023-12-22 22:48:50,170] - ph5.clients.ph5toevt - INFO: DAS: 1X4025, Node ID: 453014025
[2023-12-22 22:48:50,172] - ph5.clients.ph5toevt - INFO: Opened: ../../testdata_0/Snodgrass_Case_Study_010_01_1_0001.SGY
[2023-12-22 22:48:50,173] - ph5.core.segyfactory - ERROR:
[2023-12-22 22:48:50,173] - ph5.clients.ph5toevt - INFO:
[2023-12-22 22:48:50,173] - ph5.clients.ph5toevt - INFO: Wrote: 15000 samples with 0 sample padding.
[2023-12-22 22:48:50,173] - ph5.clients.ph5toevt - INFO: =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
[2023-12-22 22:48:50,173] - ph5.clients.ph5toevt - INFO: -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[2023-12-22 22:48:50,173] - ph5.clients.ph5toevt - INFO: Attempting to find data for station 00520.
[2023-12-22 22:48:50,218] - ph5.clients.ph5toevt - INFO: Applied time drift correction by                        shifting trace by -0.0 samples.
[2023-12-22 22:48:50,218] - ph5.clients.ph5toevt - INFO: Correction is 0 ms.
[2023-12-22 22:48:50,219] - ph5.clients.ph5toevt - INFO: Clock drift (seconds/second): 0.0
[2023-12-22 22:48:50,219] - ph5.clients.ph5toevt - INFO: Clock comment: No clock drift information available.
[2023-12-22 22:48:50,219] - ph5.clients.ph5toevt - INFO: =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
[2023-12-22 22:48:50,219] - ph5.clients.ph5toevt - INFO: trace: 2
[2023-12-22 22:48:50,219] - ph5.clients.ph5toevt - INFO: Extracted: Station ID 00520
[2023-12-22 22:48:50,219] - ph5.clients.ph5toevt - INFO: Chan: 1 Start: 2023-10-11 17:19:00+00:00, Stop: 2023-10-11 17:19:30+00:00.
[2023-12-22 22:48:50,219] - ph5.clients.ph5toevt - INFO: Lat: 38.930056 Lon: -106.976983 Elev: 3109.810000 m
[2023-12-22 22:48:50,219] - ph5.clients.ph5toevt - INFO: DAS: 1X3052, Node ID: 453013052
Traceback (most recent call last):
  File "/home/ph5/anaconda3/envs/ph5/bin/ph5toevt", line 11, in <module>
    load_entry_point('ph5', 'console_scripts', 'ph5toevt')()
  File "/home/ph5/PH5/ph5/clients/ph5toevt.py", line 655, in main
    gather(args, p5)
  File "/home/ph5/PH5/ph5/clients/ph5toevt.py", line 582, in gather
    logs = segyfactory.write_segy(trace, fh, sf)
  File "/home/ph5/PH5/ph5/core/segyfactory.py", line 1184, in write_segy
    e.message))
ph5.core.segyfactory.SEGYError: (('Error: Failed to write trace or trace header. \n',), {})
Closing remaining open files:././miniPH5_00023.ph5...done././miniPH5_00012.ph5...done./master.ph5...done```
Stephen-Veitch commented 8 months ago

ph5toevt_error.txt

See error messages here in a more legible version. Undescribed ERROR on line 19

damhuonglan commented 7 months ago

@Stephen-Veitch I modified the code so it print out the error. This is the new error file: new_ph5toevt_error.txt

The error line is:

[2024-01-23 18:44:55,653] - ph5.core.segyfactory - ERROR: Failed to write extended portion of SEG-Y trace header: 'H' format requires 0 <= number <= 65535

It still isn't clear but it reports the number in event_t['description_s'] to be 0 <= number <= 65535 while it is currently 14530055261. Currently the structure for this field in SEGY is INT16. If I change to INT32, no error will happen. But I don't have the format for SEGY extended trace header style Menlo USGS to check if that is correct or not. But I believe it is.

I have a suggestion for this which is to check the description, if it satisfies the limit range it will be added to segy, if not it won't be added to segy and a warning will be added as following

[2024-01-23 19:01:35,892] - ph5.core.segyfactory - WARNING: event_t[description_s]=453005526 is ignored because it doesn't satisfy the limit range [0, 65535] 

How do you think about the suggestion above?

Stephen-Veitch commented 7 months ago

Suggest moving forward with this fix with warning message as follows: "WARNING: description_s not added to segy header: Descriptions must be numeric values in range [0,65535] to be added to header."