Skip to content

Catch divided by zero error - #8

Open
florentaden wants to merge 2 commits into
GeoNet:mainfrom
florentaden:patch-1
Open

Catch divided by zero error#8
florentaden wants to merge 2 commits into
GeoNet:mainfrom
florentaden:patch-1

Conversation

@florentaden

Copy link
Copy Markdown

Some stations returned a single data point which triggers a divided by zero error in the function _fix_mseed_timing.
Adding a if condition controlling the length of data solve the problem and skipped the few problematic traces.

Error can be reproduced running this:

from geonet_obspy_utils.clients.aws.client import Client
from obspy import UTCDateTime

client = Client("GEONET")
starttime = UTCDateTime("2021-03-04T13:22:35.223606Z")
endtime = UTCDateTime("2021-03-04T13:57:35.223606Z")
st = client.get_waveforms(
            starttime=starttime,
            endtime=endtime,
            network="NZ",
            station="*",
            location="*",
            channel="HHZ,EHZ",
            max_threads=8
)

I used .get_waveforms for specific starttime and endtime, for any station and location available and HHZ,EHZ components. Some trace would contain a single point throwing a divided by zero error. I just added a if condition to catch the problem, only missing one or two stations max. 

I have observed another error related to the mseed package and ctypes that I haven't been able to catch:
```bash
playback-1    | Exception ignored in: <function MSTraceList.__del__ at 0x7f5223340e50>
playback-1    | Traceback (most recent call last):
playback-1    |   File "/usr/local/lib/python3.10/site-packages/mseedlib/mstracelist.py", line 480, in __del__
playback-1    |     for segment in traceid.segments():
playback-1    |   File "/usr/local/lib/python3.10/site-packages/mseedlib/mstracelist.py", line 317, in segments
playback-1    |     current_segment.contents.info.traceid_address = ct.addressof(self)
playback-1    |   File "/usr/local/lib/python3.10/site-packages/mseedlib/mstracelist.py", line 102, in info
playback-1    |     self._prvtptr = ct.cast(raw_buffer, ct.POINTER(TraceSegInfo))
playback-1    | ValueError: ctypes object structure too deep
```
@florentaden
florentaden requested a review from a team as a code owner May 11, 2026 23:43
@salichon

Copy link
Copy Markdown

kia Ora @pasansherath this shoudl be easy ot review ;)
cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants