[fix] fixing obvious problems in advance

This commit is contained in:
Sebastian Wehling-Benatelli 2016-05-03 09:35:31 +02:00
parent ecb3670aeb
commit a82c1d39c6
4 changed files with 15 additions and 19 deletions

View File

@ -411,19 +411,18 @@ class Data(object):
:raise OverwriteError: raises an OverwriteError if the picks list is :raise OverwriteError: raises an OverwriteError if the picks list is
not empty. The GUI will then ask for a decision. not empty. The GUI will then ask for a decision.
""" """
firstonset = None
#firstonset = find_firstonset(picks)
if self.getEvtData().picks: if self.getEvtData().picks:
raise OverwriteError('Actual picks would be overwritten!') raise OverwriteError('Actual picks would be overwritten!')
picks, firstonset = picks_from_dict(picks) picks = picks_from_dict(picks)
self.getEvtData().picks = picks self.getEvtData().picks = picks
# if 'smi:local' in self.getID() and firstonset:
# fonset_str = firstonset.strftime('%Y_%m_%d_%H_%M_%S')
# ID = ResourceIdentifier('event/' + fonset_str)
# ID.convertIDToQuakeMLURI(authority_id=authority_id)
# self.getEvtData().resource_id = ID
if 'smi:local' in self.getID() and firstonset:
fonset_str = firstonset.strftime('%Y_%m_%d_%H_%M_%S')
ID = ResourceIdentifier('event/' + fonset_str)
ID.convertIDToQuakeMLURI(authority_id=authority_id)
self.getEvtData().resource_id = ID
else:
print('No picks to apply!')
def applyArrivals(arrivals): def applyArrivals(arrivals):
""" """

View File

@ -230,7 +230,7 @@ def picks_to_dict(evt):
return picks return picks
def picks_from_dict(picks): def picks_from_dict(picks):
firstonset = None picks_list = list()
for station, onsets in picks.items(): for station, onsets in picks.items():
print('Reading picks on station %s' % station) print('Reading picks on station %s' % station)
for label, phase in onsets.items(): for label, phase in onsets.items():
@ -262,9 +262,9 @@ def picks_from_dict(picks):
else: else:
pick.polarity = 'undecidable' pick.polarity = 'undecidable'
except KeyError as e: except KeyError as e:
print('No polarity information found for %s' % phase) print(e.message, 'No polarity information found for %s' % phase)
if firstonset is None or firstonset > onset: picks_list.append(pick)
firstonset = onset return picks_list
def reassess_pilot_event(root_dir, event_id): def reassess_pilot_event(root_dir, event_id):
@ -303,7 +303,9 @@ def reassess_pilot_event(root_dir, event_id):
evt = ope.Event(resource_id=event_id) evt = ope.Event(resource_id=event_id)
evt.picks = picks_from_dict(picks_dict) evt.picks = picks_from_dict(picks_dict)
# write phase information to file # write phase information to file
evt.write('{0}.xml'.format(event_id), format='QUAKEML') fnout_prefix = os.path.join(root_dir, event_id, '{0}.'.format(event_id))
evt.write(fnout_prefix + 'xml', format='QUAKEML')
evt.write(fnout_prefix + 'cnv', format='VELEST')
def writephases(arrivals, fformat, filename): def writephases(arrivals, fformat, filename):

View File

@ -938,10 +938,6 @@ def checkZ4S(X, pick, zfac, checkwin, iplot):
return returnflag return returnflag
def reassess_pilot_event():
pass
if __name__ == '__main__': if __name__ == '__main__':
import doctest import doctest

View File

@ -3,7 +3,6 @@
import argparse import argparse
from pylot.core.pick.utils import reassess_pilot_event
from pylot.core.util.version import get_git_version as _getVersionString from pylot.core.util.version import get_git_version as _getVersionString
from pylot.core.io.phases import reassess_pilot_event from pylot.core.io.phases import reassess_pilot_event