adjtomo / pysep

Seismogram Extraction and Processing: Seismic data retrieval and record sections
https://pysep.readthedocs.io
MIT License
29 stars 15 forks source link

Preprocessing error due to trace with zero length? #117

Closed rmodrak closed 1 year ago

rmodrak commented 1 year ago

Is this an issue someone has encountered before by chance?

Traceback (most recent call last):
  File "/home/rmodrak/virtual/miniconda3/envs/pysep/bin/pysep", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/rmodrak/devel/pysep/pysep/pysep.py", line 2111, in main
    sep.run()
  File "/home/rmodrak/devel/pysep/pysep/pysep.py", line 1869, in run
    self.st = self.preprocess()
              ^^^^^^^^^^^^^^^^^
  File "/home/rmodrak/devel/pysep/pysep/pysep.py", line 1237, in preprocess
    _pre_filt = estimate_prefilter_corners(tr)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rmodrak/devel/pysep/pysep/utils/process.py", line 493, in estimate_prefilter_corners
    f1 = fcut1_par / (tr.stats.endtime - tr.stats.starttime)
         ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ZeroDivisionError: float division by zero
rmodrak commented 1 year ago

The above exception occurs with the PySEP yaml file below (takes a very long time...) pysep_config.yaml.txt

PySEP finishes without error with pre_filt: None as in modified yaml file below: pysep_config.yaml.txt

bch0w commented 1 year ago

Thanks for bringing this up @rmodrak, I would have thought one of the checks along the way would kick out such a Trace but it seems like this one sneaks through with a data array of length 1. I was able to re-create your issue and the offending trace that raised the Error was:

In [1]: tr
Out[1]: C0.S22A.00.LHE | 2020-01-17T21:11:42.000000Z - 2020-01-17T21:11:42.000000Z | 1.0 Hz, 1 samples

In [2]: tr.stats
Out[2]: 
               network: C0
               station: S22A
              location: 00
               channel: LHE
             starttime: 2020-01-17T21:11:42.000000Z
               endtime: 2020-01-17T21:11:42.000000Z
         sampling_rate: 1.0
                 delta: 1.0
                  npts: 1
                 calib: 1.0
_fdsnws_dataselect_url: http://service.iris.edu/fdsnws/dataselect/1/query
               _format: MSEED
          back_azimuth: 11.048223140454004
                 mseed: AttribDict({'dataquality': 'M', 'number_of_records': 1, 'encoding': 'STEIM2', 'byteorder': '>', 'record_length': 512, 'filesize': 70579712})
            processing: ["ObsPy 1.4.0: detrend(options={}::type='linear')"]
                   sac: AttribDict({'iztype': 9, 'b': 226.0, 'e': 1.0, 'evla': 43.76, 'evlo': -105.21, 'stla': 37.74612, 'stlo': -106.82926, 'stel': 2.6237, 'kevnm': '20200117210756000', 'nzyear': 2020, 'nzjday': 17, 'nzhour': 21, 'nzmin': 7, 'nzsec': 56, 'nzmsec': 0, 'dist': 681.6518919994126, 'az': 192.10677801423543, 'baz': 11.048223140454004, 'gcarc': 6.130242741904528, 'lpspol': 0, 'lcalda': 1, 'cmpinc': 0.0, 'cmpaz': 90.0, 'evdp': 0.5, 'mag': 3.2, 'a': 91.74284473995216, 'ka': 'P', 't5': 91.74284473995216, 'kt5': 'P', 'user1': 45.76615068346142, 'kuser1': 'p_IncAng', 'user3': 45.77076973837979, 'kuser3': 'p_TkfAng', 't6': 91.9336230985831, 'kt6': 'sP', 'user2': 45.76634651275574, 'kuser2': 's_IncAng', 'user4': 154.69330825055403, 'kuser4': 's_TkfAng'})

In [3]: tr.data
Out[3]: array([4.54747351e-13])

I will throw in a catch somewhere on the pipeline to kick out Traces that exhibit this characteristic

bch0w commented 1 year ago

Hey @rmodrak, just addressed this in #121; I was successfully able to run your config file. Can you check if this works for you?

rmodrak commented 1 year ago

Hi Bryant, works great, thank you!

On Mon, Aug 28, 2023 at 4:27 PM Bryant Chow @.***> wrote:

Hey @rmodrak https://github.com/rmodrak, just addressed this in #121 https://github.com/adjtomo/pysep/pull/121; I was successfully able to run your config file. Can you check if this works for you?

— Reply to this email directly, view it on GitHub https://github.com/adjtomo/pysep/issues/117#issuecomment-1696510029, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABCGSSUP5QXXIYABBEYDVSLXXULLVANCNFSM6AAAAAA33U3LGI . You are receiving this because you were mentioned.Message ID: @.***>

bch0w commented 1 year ago

No problem! Closing as completed now