uafgeotools / waveform_collection

Collect seismic/infrasound waveforms and metadata from IRIS/WATC/AVO servers, local miniSEED files, etc.
https://uaf-waveform-collection.readthedocs.io/
MIT License
13 stars 7 forks source link

Attempt to round sampling rates to nearest integer in _safe_merge if merging fails #35

Closed darren-tpk closed 7 months ago

darren-tpk commented 1 year ago

As discussed in #34 , we introduce an additional stream merging failsafe by rounding off sampling rates of traces with non-integer sampling rates.

I incorporated the change in the printed statement to show both the initial and final sampling rates of the corrected traces. Note, however, that this falls under warnings.warn and is unaffected by the verbose argument, which mutes non-essential statements. I find that this sampling rate correction is important enough that the user should be made aware.

Here's the test case from #34 :

from waveform_collection import gather_waveforms
from obspy import UTCDateTime
stream = gather_waveforms(source='IRIS', network='AV', station='VNHG',
                          location='', channel='*HZ', starttime=UTCDateTime(2003,1,1), 
                          endtime=UTCDateTime(2003,1,1,1), verbose=False)

which gives:

CollectionWarning: Rounding off AV.VNHG..EHZ sampling rate from 99.999992 Hz to 100.0 Hz for merge compatibility.
CollectionWarning: Rounding off AV.VNHG..EHZ sampling rate from 100.000008 Hz to 100.0 Hz for merge compatibility.
CollectionWarning: Merging with "fill_value=0"
CollectionWarning: Trimming with "fill_value=0"