feature/port-to-py3 #11
4
PyLoT.py
4
PyLoT.py
@ -2895,12 +2895,8 @@ class MainWindow(QMainWindow):
|
|||||||
event.pylot_autopicks = {}
|
event.pylot_autopicks = {}
|
||||||
picksdict = picksdict_from_picks(evt=self.get_data().get_evt_data())
|
picksdict = picksdict_from_picks(evt=self.get_data().get_evt_data())
|
||||||
event.addPicks(picksdict['manual'])
|
event.addPicks(picksdict['manual'])
|
||||||
if picksdict['auto'] == {}:
|
|
||||||
event.addAutopicks(picksdict)
|
|
||||||
else:
|
|
||||||
event.addAutopicks(picksdict['auto'])
|
event.addAutopicks(picksdict['auto'])
|
||||||
|
|
||||||
|
|
||||||
def drawPicks(self, station=None, picktype=None, stime=None):
|
def drawPicks(self, station=None, picktype=None, stime=None):
|
||||||
# if picktype not specified, draw both
|
# if picktype not specified, draw both
|
||||||
if not stime:
|
if not stime:
|
||||||
|
@ -167,9 +167,8 @@ class Data(object):
|
|||||||
|
|
||||||
def checkEvent(self, event, fcheck, forceOverwrite=False):
|
def checkEvent(self, event, fcheck, forceOverwrite=False):
|
||||||
"""
|
"""
|
||||||
Check information in supplied event and own event and replace own
|
Check information in supplied event and own event and replace with own
|
||||||
information with supplied information if own information not exiisting
|
information if no other information are given or forced by forceOverwrite
|
||||||
or forced by forceOverwrite
|
|
||||||
:param event: Event that supplies information for comparison
|
:param event: Event that supplies information for comparison
|
||||||
:type event: pylot.core.util.event.Event
|
:type event: pylot.core.util.event.Event
|
||||||
:param fcheck: check and delete existing information
|
:param fcheck: check and delete existing information
|
||||||
@ -225,7 +224,7 @@ class Data(object):
|
|||||||
|
|
||||||
def replacePicks(self, event, picktype):
|
def replacePicks(self, event, picktype):
|
||||||
"""
|
"""
|
||||||
Replace own picks with the one in event
|
Replace picks in event with own picks
|
||||||
:param event: Event that supplies information for comparison
|
:param event: Event that supplies information for comparison
|
||||||
:type event: pylot.core.util.event.Event
|
:type event: pylot.core.util.event.Event
|
||||||
:param picktype: 'auto' or 'manual' picks
|
:param picktype: 'auto' or 'manual' picks
|
||||||
@ -233,19 +232,22 @@ class Data(object):
|
|||||||
:return:
|
:return:
|
||||||
:rtype: None
|
:rtype: None
|
||||||
"""
|
"""
|
||||||
checkflag = 0
|
checkflag = 1
|
||||||
picks = event.picks
|
picks = event.picks
|
||||||
# remove existing picks
|
# remove existing picks
|
||||||
for j, pick in reversed(list(enumerate(picks))):
|
for j, pick in reversed(list(enumerate(picks))):
|
||||||
try:
|
try:
|
||||||
if picktype in str(pick.method_id.id):
|
if picktype in str(pick.method_id.id):
|
||||||
picks.pop(j)
|
picks.pop(j)
|
||||||
checkflag = 1
|
checkflag = 2
|
||||||
except AttributeError as e:
|
except AttributeError as e:
|
||||||
msg = '{}'.format(e)
|
msg = '{}'.format(e)
|
||||||
print(e)
|
print(e)
|
||||||
checkflag = 0
|
checkflag = 0
|
||||||
if checkflag:
|
if checkflag > 0:
|
||||||
|
if checkflag == 1:
|
||||||
|
print("Write new %s picks to catalog." % picktype)
|
||||||
|
if checkflag == 2:
|
||||||
print("Found %s pick(s), remove them and append new picks to catalog." % picktype)
|
print("Found %s pick(s), remove them and append new picks to catalog." % picktype)
|
||||||
|
|
||||||
# append new picks
|
# append new picks
|
||||||
@ -274,8 +276,11 @@ class Data(object):
|
|||||||
raise FormatError(errmsg)
|
raise FormatError(errmsg)
|
||||||
|
|
||||||
if hasattr(self.get_evt_data(), 'notes'):
|
if hasattr(self.get_evt_data(), 'notes'):
|
||||||
|
try:
|
||||||
with open(os.path.join(os.path.dirname(fnout), 'notes.txt'), 'w') as notes_file:
|
with open(os.path.join(os.path.dirname(fnout), 'notes.txt'), 'w') as notes_file:
|
||||||
notes_file.write(self.get_evt_data().notes)
|
notes_file.write(self.get_evt_data().notes)
|
||||||
|
except Exception as e:
|
||||||
|
print('Warning: Could not save notes.txt: ', str(e))
|
||||||
|
|
||||||
# check for already existing xml-file
|
# check for already existing xml-file
|
||||||
if fnext == '.xml':
|
if fnext == '.xml':
|
||||||
@ -532,7 +537,7 @@ class Data(object):
|
|||||||
def setEvtData(self, event):
|
def setEvtData(self, event):
|
||||||
self.evtdata = event
|
self.evtdata = event
|
||||||
|
|
||||||
def applyEVTData(self, data, typ='pick', authority_id='rub'):
|
def applyEVTData(self, data, typ='pick'):
|
||||||
"""
|
"""
|
||||||
Either takes an `obspy.core.event.Event` object and applies all new
|
Either takes an `obspy.core.event.Event` object and applies all new
|
||||||
information on the event to the actual data if typ is 'event or
|
information on the event to the actual data if typ is 'event or
|
||||||
|
@ -244,13 +244,13 @@ def picksdict_from_picks(evt):
|
|||||||
else:
|
else:
|
||||||
filter_id = None
|
filter_id = None
|
||||||
try:
|
try:
|
||||||
picker = str(pick.method_id)
|
pick_method = str(pick.method_id)
|
||||||
if picker.startswith('smi:local/'):
|
if pick_method.startswith('smi:local/'):
|
||||||
picker = picker.split('smi:local/')[1]
|
pick_method = pick_method.split('smi:local/')[1]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
picker = 'manual' # MP MP TODO maybe improve statement
|
pick_method = 'manual' # MP MP TODO maybe improve statement
|
||||||
if picker == 'None':
|
if pick_method == 'None':
|
||||||
picker = 'manual'
|
pick_method = 'manual'
|
||||||
try:
|
try:
|
||||||
#onsets = picksdict[picker][station]
|
#onsets = picksdict[picker][station]
|
||||||
onsets = picksdict[station]
|
onsets = picksdict[station]
|
||||||
@ -289,7 +289,7 @@ def picksdict_from_picks(evt):
|
|||||||
phase['weight'] = weight
|
phase['weight'] = weight
|
||||||
phase['channel'] = channel
|
phase['channel'] = channel
|
||||||
phase['network'] = network
|
phase['network'] = network
|
||||||
phase['picker'] = picker
|
phase['picker'] = pick_method
|
||||||
try:
|
try:
|
||||||
if pick.polarity == 'positive':
|
if pick.polarity == 'positive':
|
||||||
phase['fm'] = 'U'
|
phase['fm'] = 'U'
|
||||||
@ -303,7 +303,7 @@ def picksdict_from_picks(evt):
|
|||||||
phase['filter_id'] = filter_id if filter_id is not None else ''
|
phase['filter_id'] = filter_id if filter_id is not None else ''
|
||||||
|
|
||||||
onsets[pick.phase_hint] = phase.copy()
|
onsets[pick.phase_hint] = phase.copy()
|
||||||
picksdict[station] = onsets.copy()
|
picksdict[pick_method][station] = onsets.copy()
|
||||||
return picksdict
|
return picksdict
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user