krischer / instaseis

Instant high-frequency seismograms from an AxiSEM database
http://instaseis.net
Other
52 stars 23 forks source link

more informative error in case source is to deep for remote db #41

Closed martinvandriel closed 8 years ago

martinvandriel commented 8 years ago

This is the error I get using get_seismograms on a remote database when queried with a source deeper then the DB allows:

Traceback (most recent call last):
  File "recsec.py", line 41, in <module>
    tr = db.get_seismograms(source=src, receiver=rec, components=[component])[0]
  File "/home/ex/local/src/instaseis/instaseis/base_instaseis_db.py", line 247, in get_seismograms
    components=components)
  File "/home/ex/local/src/instaseis/instaseis/remote_instaseis_db.py", line 121, in _get_seismograms
    st = obspy.read(fh)
  File "<decorator-gen-42>", line 2, in read
  File "/home/ex/anaconda/lib/python2.7/site-packages/obspy/core/util/decorator.py", line 289, in _map_example_filename
    return func(*args, **kwargs)
  File "/home/ex/anaconda/lib/python2.7/site-packages/obspy/core/stream.py", line 217, in read
    st.extend(_read(fh.name, format, headonly, **kwargs).traces)
  File "<decorator-gen-43>", line 2, in _read
  File "/home/ex/anaconda/lib/python2.7/site-packages/obspy/core/util/decorator.py", line 199, in uncompress_file
    result = func(filename, *args, **kwargs)
  File "/home/ex/anaconda/lib/python2.7/site-packages/obspy/core/stream.py", line 272, in _read
    headonly=headonly, **kwargs)
  File "/home/ex/anaconda/lib/python2.7/site-packages/obspy/core/util/base.py", line 439, in _read_from_plugin
    raise TypeError('Unknown format for file %s' % filename)
TypeError: Unknown format for file /tmp/obspy-mWBROR.tmp

This should be catched and have a more informative message.

krischer commented 8 years ago

Fixed in master. Error message is now like this:

Source too deep. Source would be located at a radius of 5471000.0
meters. The database supports source radii from 6000000.0 to
6371000.0 meters.