PIC-IRIS / PH5

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

[BUG] ph5toevt crashes with option '-u X' when value in 'sensor/serial_number_s' is >+/- 32767 #529

Closed Stephen-Veitch closed 1 month ago

Stephen-Veitch commented 4 months ago

When requesting a segy which includes a trace whose value in array-table entry 'sensor/serial_number_s' is larger (or smaller) than +/- 32767 ph5toevt crashes with the following error message:

[2024-04-24 17:58:33,827] - ph5.clients.ph5toevt - INFO: =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
[2024-04-24 17:58:33,827] - ph5.clients.ph5toevt - INFO: trace: 62
[2024-04-24 17:58:33,827] - ph5.clients.ph5toevt - INFO: Extracted: Station ID 16221
[2024-04-24 17:58:33,827] - ph5.clients.ph5toevt - INFO: Chan: 3 Start: 2024-01-08 22:26:59.016999+00:00, Stop: 2024-01-08 22:27:02.016999+00:00.
[2024-04-24 17:58:33,827] - ph5.clients.ph5toevt - INFO: Lat: -76.482572 Lon: -103.070956 Elev: 1174.490000 m
[2024-04-24 17:58:33,827] - ph5.clients.ph5toevt - INFO: DAS: 16X16221, Node ID: 7969
[2024-04-24 17:58:33,828] - ph5.clients.ph5toevt - INFO: Wrote: 3000 samples with 0 sample padding.
[2024-04-24 17:58:33,828] - ph5.clients.ph5toevt - INFO: -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[2024-04-24 17:58:33,828] - ph5.clients.ph5toevt - INFO: Attempting to find data for station 16156.
[2024-04-24 17:58:33,863] - ph5.clients.ph5toevt - INFO: Applied time drift correction by                        shifting trace by -0.0 samples.
[2024-04-24 17:58:33,863] - ph5.clients.ph5toevt - INFO: Correction is 0 ms.
[2024-04-24 17:58:33,863] - ph5.clients.ph5toevt - INFO: Clock drift (seconds/second): 0.0
[2024-04-24 17:58:33,863] - ph5.clients.ph5toevt - INFO: Clock comment: No clock drift information available.
[2024-04-24 17:58:33,863] - ph5.clients.ph5toevt - INFO: =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
[2024-04-24 17:58:33,864] - ph5.clients.ph5toevt - INFO: trace: 63
[2024-04-24 17:58:33,864] - ph5.clients.ph5toevt - INFO: Extracted: Station ID 16156
[2024-04-24 17:58:33,864] - ph5.clients.ph5toevt - INFO: Chan: 3 Start: 2024-01-08 22:26:59.016999+00:00, Stop: 2024-01-08 22:27:02.016999+00:00.
[2024-04-24 17:58:33,864] - ph5.clients.ph5toevt - INFO: Lat: -76.505299 Lon: -103.368036 Elev: 1158.240000 m
[2024-04-24 17:58:33,864] - ph5.clients.ph5toevt - INFO: DAS: 1X289, Node ID: 453013843
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 1192, in write_segy
    e.message))
ph5.core.segyfactory.SEGYError: (("Error: Failed to write trace or trace header. Failed to write extended portion of SEG-Y trace header: 'h' format requires -32768 <= number <= 32767\n",), {})

This error does not occur with -u S of -u P.

This field in the array tables is optional, and often left blank. Consequently many requests will have null values for this field anyways.

Suggest modifying ph5toevt to skip writing values that are non-compliant for this trace-header entry.