Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

io.nordic: Settings "Time_Residual_RMS" #1696

Merged
merged 1 commit into from Mar 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 5 additions & 13 deletions obspy/io/nordic/core.py
Expand Up @@ -32,7 +32,7 @@
from obspy import UTCDateTime, read
from obspy.geodetics import kilometers2degrees, degrees2kilometers
from obspy.core.event import Event, Origin, Magnitude, Comment, Catalog
from obspy.core.event import EventDescription, CreationInfo
from obspy.core.event import EventDescription, CreationInfo, OriginQuality
from obspy.core.event import Pick, WaveformStreamID, Arrival, Amplitude


Expand Down Expand Up @@ -287,12 +287,8 @@ def _readheader(f):
ksta = Comment(text='Number of stations=' + topline[49:51].strip())
new_event.origins[0].comments.append(ksta)
if _float_conv(topline[51:55]) is not None:
# raises "UserWarning: Setting attribute "Time_Residual_RMS" which is
# not a default attribute"
with warnings.catch_warnings():
warnings.simplefilter('ignore', UserWarning)
new_event.origins[0].time_errors['Time_Residual_RMS'] = \
_float_conv(topline[51:55])
new_event.origins[0].quality = OriginQuality(
standard_error=_float_conv(topline[51:55]))
# Read in magnitudes if they are there.
for index in [59, 67, 75]:
if not topline[index].isspace():
Expand Down Expand Up @@ -896,12 +892,8 @@ def _write_nordic(event, filename, userid='OBSP', evtype='L', outdir='.',
if len(agency) > 3:
agency = agency[0:3]
# Cope with differences in event uncertainty naming
if event.origins[0].time_errors:
try:
timerms = '{0:.1f}'.format(event.origins[0].
time_errors.Time_Residual_RMS)
except AttributeError:
timerms = '0.0'
if event.origins[0].quality and event.origins[0].quality['standard_error']:
timerms = '{0:.1f}'.format(event.origins[0].quality['standard_error'])
else:
timerms = '0.0'
conv_mags = []
Expand Down
26 changes: 5 additions & 21 deletions obspy/io/nordic/tests/test_nordic.py
Expand Up @@ -15,7 +15,7 @@

from obspy import read_events, Catalog, UTCDateTime, read
from obspy.core.event import Pick, WaveformStreamID, Arrival, Amplitude
from obspy.core.event import Event, Origin, Magnitude
from obspy.core.event import Event, Origin, Magnitude, OriginQuality
from obspy.core.event import EventDescription, CreationInfo
from obspy.core.util.base import NamedTemporaryFile
from obspy.io.nordic.core import _is_sfile, read_spectral_info, read_nordic
Expand Down Expand Up @@ -168,35 +168,23 @@ def test_fail_writing(self):
evtype='L', outdir='albatross',
wavefiles='test', explosion=True,
overwrite=True)
# raises "UserWarning: Setting attribute "Time_Residual_RMS" which is
# not a default attribute"
with warnings.catch_warnings():
warnings.simplefilter('ignore', UserWarning)
invalid_origin = test_ev.copy()
invalid_origin = test_ev.copy()

invalid_origin.origins = []
with self.assertRaises(NordicParsingError):
_write_nordic(invalid_origin, filename=None, userid='TEST',
evtype='L', outdir='.',
wavefiles='test', explosion=True,
overwrite=True)
# raises "UserWarning: Setting attribute "Time_Residual_RMS" which is
# not a default attribute"
with warnings.catch_warnings():
warnings.simplefilter('ignore', UserWarning)
invalid_origin = test_ev.copy()
invalid_origin = test_ev.copy()
invalid_origin.origins[0].time = None
with self.assertRaises(NordicParsingError):
_write_nordic(invalid_origin, filename=None, userid='TEST',
evtype='L', outdir='.',
wavefiles='test', explosion=True,
overwrite=True)
# Write a near empty origin
# raises "UserWarning: Setting attribute "Time_Residual_RMS" which is
# not a default attribute"
with warnings.catch_warnings():
warnings.simplefilter('ignore', UserWarning)
valid_origin = test_ev.copy()
valid_origin = test_ev.copy()
valid_origin.origins[0].latitude = None
valid_origin.origins[0].longitude = None
valid_origin.origins[0].depth = None
Expand Down Expand Up @@ -683,11 +671,7 @@ def full_test_event():
test_event.origins[0].longitude = 25.0
test_event.origins[0].depth = 15000
test_event.creation_info = CreationInfo(agency_id='TES')
# raises "UserWarning: Setting attribute "Time_Residual_RMS" which is not
# a default attribute"
with warnings.catch_warnings():
warnings.simplefilter('ignore', UserWarning)
test_event.origins[0].time_errors['Time_Residual_RMS'] = 0.01
test_event.origins[0].quality = OriginQuality(standard_error=0.01)
test_event.magnitudes.append(Magnitude())
test_event.magnitudes[0].mag = 0.1
test_event.magnitudes[0].magnitude_type = 'ML'
Expand Down