[idea] copy pick not event and add to blank event

This commit is contained in:
Marcel Paffrath 2017-08-14 13:44:38 +02:00
parent 3cd64d09de
commit fda9de5738

View File

@ -227,52 +227,57 @@ class Data(object):
# try exporting event via ObsPy # try exporting event via ObsPy
else: else:
print(self.get_evt_data()) print(self.get_evt_data())
evtdata_copy = self.get_evt_data().copy()
evtdata_org = self.get_evt_data() evtdata_org = self.get_evt_data()
eventpath = evtdata_org.path
picks = evtdata_org.picks
picks_copy = copy.deepcopy(picks)
evtdata_copy = Event(eventpath)
evtdata_copy.picks = picks_copy
# check for stations picked automatically as well as manually # check for stations picked automatically as well as manually
# Prefer manual picks! # Prefer manual picks!
for i in range(len(evtdata_org.picks)): for i in range(len(picks)):
if evtdata_org.picks[i].method_id == 'manual': if picks[i].method_id == 'manual':
mstation = evtdata_org.picks[i].waveform_id.station_code mstation = picks[i].waveform_id.station_code
mstation_ext = mstation + '_' mstation_ext = mstation + '_'
for k in range(len(evtdata_copy.picks)): for k in range(len(picks_copy)):
if ((evtdata_copy.picks[k].waveform_id.station_code == mstation) or \ if ((picks_copy[k].waveform_id.station_code == mstation) or \
(evtdata_copy.picks[k].waveform_id.station_code == mstation_ext)) and \ (picks_copy[k].waveform_id.station_code == mstation_ext)) and \
(evtdata_copy.picks[k].method_id == 'auto'): (picks_copy[k].method_id == 'auto'):
del evtdata_copy.picks[k] del picks_copy[k]
break break
lendiff = len(evtdata_org.picks) - len(evtdata_copy.picks) lendiff = len(picks) - len(picks_copy)
if lendiff is not 0: if lendiff is not 0:
print("Manual as well as automatic picks available. Prefered the {} manual ones!".format(lendiff)) print("Manual as well as automatic picks available. Prefered the {} manual ones!".format(lendiff))
if upperErrors: if upperErrors:
# check for pick uncertainties exceeding adjusted upper errors # check for pick uncertainties exceeding adjusted upper errors
# Picks with larger uncertainties will not be saved in output file! # Picks with larger uncertainties will not be saved in output file!
for j in range(len(evtdata_org.picks)): for j in range(len(picks)):
for i in range(len(evtdata_copy.picks)): for i in range(len(picks_copy)):
if evtdata_copy.picks[i].phase_hint[0] == 'P': if picks_copy[i].phase_hint[0] == 'P':
if (evtdata_copy.picks[i].time_errors['upper_uncertainty'] >= upperErrors[0]) or \ if (picks_copy[i].time_errors['upper_uncertainty'] >= upperErrors[0]) or \
(evtdata_copy.picks[i].time_errors['uncertainty'] == None): (picks_copy[i].time_errors['uncertainty'] == None):
print("Uncertainty exceeds or equal adjusted upper time error!") print("Uncertainty exceeds or equal adjusted upper time error!")
print("Adjusted uncertainty: {}".format(upperErrors[0])) print("Adjusted uncertainty: {}".format(upperErrors[0]))
print("Pick uncertainty: {}".format(evtdata_copy.picks[i].time_errors['uncertainty'])) print("Pick uncertainty: {}".format(picks_copy[i].time_errors['uncertainty']))
print("{1} P-Pick of station {0} will not be saved in outputfile".format( print("{1} P-Pick of station {0} will not be saved in outputfile".format(
evtdata_copy.picks[i].waveform_id.station_code, picks_copy[i].waveform_id.station_code,
evtdata_copy.picks[i].method_id)) picks_copy[i].method_id))
print("#") print("#")
del evtdata_copy.picks[i] del picks_copy[i]
break break
if evtdata_copy.picks[i].phase_hint[0] == 'S': if picks_copy[i].phase_hint[0] == 'S':
if (evtdata_copy.picks[i].time_errors['upper_uncertainty'] >= upperErrors[1]) or \ if (picks_copy[i].time_errors['upper_uncertainty'] >= upperErrors[1]) or \
(evtdata_copy.picks[i].time_errors['uncertainty'] == None): (picks_copy[i].time_errors['uncertainty'] == None):
print("Uncertainty exceeds or equal adjusted upper time error!") print("Uncertainty exceeds or equal adjusted upper time error!")
print("Adjusted uncertainty: {}".format(upperErrors[1])) print("Adjusted uncertainty: {}".format(upperErrors[1]))
print("Pick uncertainty: {}".format(evtdata_copy.picks[i].time_errors['uncertainty'])) print("Pick uncertainty: {}".format(picks_copy[i].time_errors['uncertainty']))
print("{1} S-Pick of station {0} will not be saved in outputfile".format( print("{1} S-Pick of station {0} will not be saved in outputfile".format(
evtdata_copy.picks[i].waveform_id.station_code, picks_copy[i].waveform_id.station_code,
evtdata_copy.picks[i].method_id)) picks_copy[i].method_id))
print("#") print("#")
del evtdata_copy.picks[i] del picks_copy[i]
break break
if fnext == '.obs': if fnext == '.obs':