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

gather_waveforms_bulk throws AttributeError: 'NoneType' object has no attribute 'value' #32

Closed alexjcwitsil closed 1 year ago

alexjcwitsil commented 1 year ago

I am trying to run the code below:

cur_start = UTCDateTime(datetime.datetime(2019, 8, 5, 8, 43, 32, 0))  
cur_stop = cur_start + 60*60*1                                        

cur_lat = 61.57568                                                    
cur_lon = 13.77739                                                    
max_radius = 400                                                      
st_org = gather_waveforms_bulk(                                       
    cur_lon,                                                          
    cur_lat,                                                          
    max_radius,                                                       
    cur_start,                                                        
    cur_stop,                                                         
    channel="*Z",                                                     
    remove_response=True,                                             
)                                         

but get the following error:

Traceback (most recent call last):
  File "<string>", line 17, in __PYTHON_EL_eval
  File "/home/awitsil/projects/shield/scripts/plot_iris_data.py", line 42, in <module>
    st_org = gather_waveforms_bulk(
  File "/home/awitsil/python_modules/waveform_collection/waveform_collection/server.py", li\
ne 413, in gather_waveforms_bulk
    iris_st, iris_failed = gather_waveforms(source='IRIS', network=network,
  File "/home/awitsil/python_modules/waveform_collection/waveform_collection/server.py", li\
ne 250, in gather_waveforms
    tr.remove_sensitivity()
  File "/home/awitsil/miniconda3/envs/dev_baml/lib/python3.10/site-packages/decorator.py", \
line 232, in fun
    return caller(func, *(extras + args), **kw)
  File "/home/awitsil/miniconda3/envs/dev_baml/lib/python3.10/site-packages/obspy/core/trac\
e.py", line 273, in _add_processing_info
    result = func(*args, **kwargs)
  File "/home/awitsil/miniconda3/envs/dev_baml/lib/python3.10/site-packages/obspy/core/trac\
e.py", line 2964, in remove_sensitivity
    self.data = self.data / response.instrument_sensitivity.value
AttributeError: 'NoneType' object has no attribute 'value'

Looks like there is a problem in the file server.py between lines 237 and 255 where try is used in an attempt to remove the instrument response. I am not an expert in error handling, otherwise I would have tried editing the code and performing a pull request. :)

davidfee5 commented 1 year ago

Hey Alex! I think the issue here is actually related to insufficient metadata. The error occurs during the response removal phase, and it appears at least one of the channels does not have a sensitivity value. Your *Z channel requests returns a mix of different sensors (seismometers, accelerometers, etc), so you might try to narrow that down or find the station with incorrect metadata and exclude it. Hope that helps!

davidfee5 commented 1 year ago

Yep, looks like IU.KONO.00.VMZ is the culprit.

alexjcwitsil commented 1 year ago

Ahhhhh! That makes a lot of sense. Thanks!