Added output for hypoDD.
This commit is contained in:
parent
1f6a44eeef
commit
df6a6c1c71
4
PyLoT.py
4
PyLoT.py
@ -200,7 +200,7 @@ class MainWindow(QMainWindow):
|
|||||||
settings.setValue('useGuiFilter', False)
|
settings.setValue('useGuiFilter', False)
|
||||||
if settings.value('output/Format', None) is None:
|
if settings.value('output/Format', None) is None:
|
||||||
outformat = QInputDialog.getText(self,
|
outformat = QInputDialog.getText(self,
|
||||||
"Enter output format (*.xml, *.cnv, *.obs, *.focmec):",
|
"Enter output format (*.xml, *.cnv, *.obs, *.focmec, *.pha):",
|
||||||
"Format")
|
"Format")
|
||||||
settings.setValue("output/Format", outformat)
|
settings.setValue("output/Format", outformat)
|
||||||
if settings.value('autoFilter', None) is None:
|
if settings.value('autoFilter', None) is None:
|
||||||
@ -1481,7 +1481,7 @@ class MainWindow(QMainWindow):
|
|||||||
self.set_fname(self.get_data().getEventFileName(), type)
|
self.set_fname(self.get_data().getEventFileName(), type)
|
||||||
return self.get_fnames(type)
|
return self.get_fnames(type)
|
||||||
|
|
||||||
def saveData(self, event=None, directory=None, outformats=['.xml', '.cnv', '.obs', '.focmec']):
|
def saveData(self, event=None, directory=None, outformats=['.xml', '.cnv', '.obs', '.focmec', '.pha']):
|
||||||
'''
|
'''
|
||||||
Save event data to directory with specified output formats.
|
Save event data to directory with specified output formats.
|
||||||
:param event: PyLoT Event, if not set current event will be used
|
:param event: PyLoT Event, if not set current event will be used
|
||||||
|
@ -12,6 +12,7 @@ from PySide.QtGui import QMessageBox
|
|||||||
|
|
||||||
import pylot.core.loc.velest as velest
|
import pylot.core.loc.velest as velest
|
||||||
import pylot.core.loc.focmec as focmec
|
import pylot.core.loc.focmec as focmec
|
||||||
|
import pylot.core.loc.hypodd as hypodd
|
||||||
from pylot.core.io.phases import readPILOTEvent, picks_from_picksdict, \
|
from pylot.core.io.phases import readPILOTEvent, picks_from_picksdict, \
|
||||||
picksdict_from_pilot, merge_picks, PylotParameter
|
picksdict_from_pilot, merge_picks, PylotParameter
|
||||||
from pylot.core.util.errors import FormatError, OverwriteError
|
from pylot.core.util.errors import FormatError, OverwriteError
|
||||||
@ -232,9 +233,14 @@ class Data(object):
|
|||||||
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:
|
||||||
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 = 1
|
||||||
|
except AttributeError as e:
|
||||||
|
msg = '{}'.format(e)
|
||||||
|
print(e)
|
||||||
|
checkflag = 0
|
||||||
if checkflag:
|
if checkflag:
|
||||||
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)
|
||||||
|
|
||||||
@ -247,7 +253,7 @@ class Data(object):
|
|||||||
"""
|
"""
|
||||||
Export event to file
|
Export event to file
|
||||||
:param fnout: basename of file
|
:param fnout: basename of file
|
||||||
:param fnext: file extension, xml, cnv, obs, focmec
|
:param fnext: file extensions xml, cnv, obs, focmec, or/and pha
|
||||||
:param fcheck: check and delete existing information
|
:param fcheck: check and delete existing information
|
||||||
can be a str or a list of strings of ['manual', 'auto', 'origin', 'magnitude']
|
can be a str or a list of strings of ['manual', 'auto', 'origin', 'magnitude']
|
||||||
"""
|
"""
|
||||||
@ -369,6 +375,15 @@ class Data(object):
|
|||||||
except KeyError as e:
|
except KeyError as e:
|
||||||
raise KeyError('''{0} export format
|
raise KeyError('''{0} export format
|
||||||
not implemented: {1}'''.format(evtformat, e))
|
not implemented: {1}'''.format(evtformat, e))
|
||||||
|
if fnext == '.pha':
|
||||||
|
try:
|
||||||
|
infile = os.path.join(os.path.expanduser('~'), '.pylot', 'pylot.in')
|
||||||
|
print('Using default input file {}'.format(infile))
|
||||||
|
parameter = PylotParameter(infile)
|
||||||
|
hypodd.export(picks_copy, fnout + fnext, parameter, eventinfo=self.get_evt_data())
|
||||||
|
except KeyError as e:
|
||||||
|
raise KeyError('''{0} export format
|
||||||
|
not implemented: {1}'''.format(evtformat, e))
|
||||||
|
|
||||||
def getComp(self):
|
def getComp(self):
|
||||||
"""
|
"""
|
||||||
|
@ -291,7 +291,6 @@ 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[picker][station] = onsets.copy()
|
|
||||||
picksdict[station] = onsets.copy()
|
picksdict[station] = onsets.copy()
|
||||||
return picksdict
|
return picksdict
|
||||||
|
|
||||||
@ -757,7 +756,7 @@ def writephases(arrivals, fformat, filename, parameter=None, eventinfo=None):
|
|||||||
fid.write('%-4sS%d%6.2f\n' % (stat, Sweight, Srt))
|
fid.write('%-4sS%d%6.2f\n' % (stat, Sweight, Srt))
|
||||||
fid.close()
|
fid.close()
|
||||||
|
|
||||||
elif fformat == 'hypoDD':
|
elif fformat == 'HYPODD':
|
||||||
print("Writing phases to %s for hypoDD" % filename)
|
print("Writing phases to %s for hypoDD" % filename)
|
||||||
fid = open("%s" % filename, 'w')
|
fid = open("%s" % filename, 'w')
|
||||||
# get event information needed for hypoDD-phase file
|
# get event information needed for hypoDD-phase file
|
||||||
@ -770,6 +769,12 @@ def writephases(arrivals, fformat, filename, parameter=None, eventinfo=None):
|
|||||||
stime.year, stime.month, stime.day, stime.hour, stime.minute, stime.second,
|
stime.year, stime.month, stime.day, stime.hour, stime.minute, stime.second,
|
||||||
eventsource['latitude'], eventsource['longitude'], eventsource['depth'] / 1000,
|
eventsource['latitude'], eventsource['longitude'], eventsource['depth'] / 1000,
|
||||||
eventinfo.magnitudes[0]['mag'], eventsource['quality']['standard_error'], hddID))
|
eventinfo.magnitudes[0]['mag'], eventsource['quality']['standard_error'], hddID))
|
||||||
|
# check whether arrivals are dictionaries (autoPyLoT) or pick object (PyLoT)
|
||||||
|
if isinstance(arrivals, dict) == False:
|
||||||
|
# convert pick object (PyLoT) into dictionary
|
||||||
|
evt = ope.Event(resource_id=eventinfo['resource_id'])
|
||||||
|
evt.picks = arrivals
|
||||||
|
arrivals = picksdict_from_picks(evt)
|
||||||
for key in arrivals:
|
for key in arrivals:
|
||||||
if arrivals[key].has_key('P'):
|
if arrivals[key].has_key('P'):
|
||||||
# P onsets
|
# P onsets
|
||||||
|
@ -25,4 +25,4 @@ def export(picks, fnout, parameter, eventinfo):
|
|||||||
:type eventinfo: list object
|
:type eventinfo: list object
|
||||||
'''
|
'''
|
||||||
# write phases to hypoDD-phase file
|
# write phases to hypoDD-phase file
|
||||||
writephases(picks, 'hypoDD', fnout, parameter, eventinfo)
|
writephases(picks, 'HYPODD', fnout, parameter, eventinfo)
|
||||||
|
@ -37,6 +37,7 @@ TIMEERROR_DEFAULTS = os.path.join(os.path.expanduser('~'),
|
|||||||
OUTPUTFORMATS = {'.xml': 'QUAKEML',
|
OUTPUTFORMATS = {'.xml': 'QUAKEML',
|
||||||
'.cnv': 'CNV',
|
'.cnv': 'CNV',
|
||||||
'.obs': 'NLLOC_OBS',
|
'.obs': 'NLLOC_OBS',
|
||||||
'.focmec': 'FOCMEC'}
|
'.focmec': 'FOCMEC',
|
||||||
|
'.pha': 'HYPODD'}
|
||||||
|
|
||||||
LOCTOOLS = dict(nll=nll, hyposat=hyposat, velest=velest, hypo71=hypo71, hypodd=hypodd)
|
LOCTOOLS = dict(nll=nll, hyposat=hyposat, velest=velest, hypo71=hypo71, hypodd=hypodd)
|
||||||
|
Loading…
Reference in New Issue
Block a user