[edit] further restructuring and bugfixing
This commit is contained in:
parent
a82c1d39c6
commit
41991c5d81
@ -43,7 +43,7 @@ from obspy import UTCDateTime
|
||||
from pylot.core.io.data import Data
|
||||
from pylot.core.io.inputs import FilterOptions, AutoPickParameter
|
||||
from pylot.core.pick.autopick import autopickevent
|
||||
from pylot.core.io.phases import picks_to_dict
|
||||
from pylot.core.io.phases import picksdict_from_picks
|
||||
from pylot.core.loc.nll import locate as locateNll
|
||||
from pylot.core.util.defaults import FILTERDEFAULTS, COMPNAME_MAP,\
|
||||
AUTOMATIC_DEFAULTS
|
||||
@ -735,7 +735,7 @@ class MainWindow(QMainWindow):
|
||||
return rval
|
||||
|
||||
def updatePicks(self, type='manual'):
|
||||
picks = picks_to_dict(evt=self.getData().getEvtData())
|
||||
picks = picksdict_from_picks(evt=self.getData().getEvtData())
|
||||
if type == 'manual':
|
||||
self.picks.update(picks)
|
||||
elif type == 'auto':
|
||||
|
@ -9,7 +9,7 @@ from obspy.core import read, Stream, UTCDateTime
|
||||
from obspy import read_events, read_inventory
|
||||
from obspy.core.event import Event, ResourceIdentifier, Pick, WaveformStreamID
|
||||
|
||||
from pylot.core.io.phases import readPILOTEvent, picks_from_dict
|
||||
from pylot.core.io.phases import readPILOTEvent, picks_from_picksdict
|
||||
from pylot.core.util.utils import fnConstructor, getGlobalTimes
|
||||
from pylot.core.util.errors import FormatError, OverwriteError
|
||||
|
||||
@ -415,7 +415,7 @@ class Data(object):
|
||||
#firstonset = find_firstonset(picks)
|
||||
if self.getEvtData().picks:
|
||||
raise OverwriteError('Actual picks would be overwritten!')
|
||||
picks = picks_from_dict(picks)
|
||||
picks = picks_from_picksdict(picks)
|
||||
self.getEvtData().picks = picks
|
||||
# if 'smi:local' in self.getID() and firstonset:
|
||||
# fonset_str = firstonset.strftime('%Y_%m_%d_%H_%M_%S')
|
||||
|
@ -8,9 +8,10 @@ import scipy.io as sio
|
||||
import obspy.core.event as ope
|
||||
from obspy.core import UTCDateTime
|
||||
|
||||
from pylot.core.pick.utils import select_for_phase
|
||||
from pylot.core.util.utils import getOwner, createPick, createArrival, \
|
||||
createEvent, createOrigin, createMagnitude
|
||||
|
||||
from pylot.core.util.defaults import AUTOMATIC_DEFAULTS
|
||||
|
||||
def readPILOTEvent(phasfn=None, locfn=None, authority_id=None, **kwargs):
|
||||
"""
|
||||
@ -192,7 +193,7 @@ def picksdict_from_obs(fn):
|
||||
return picks
|
||||
|
||||
|
||||
def picks_to_dict(evt):
|
||||
def picksdict_from_picks(evt):
|
||||
'''
|
||||
Takes an Event object and return the pick dictionary commonly used within
|
||||
PyLoT
|
||||
@ -229,7 +230,7 @@ def picks_to_dict(evt):
|
||||
picks[station] = onsets.copy()
|
||||
return picks
|
||||
|
||||
def picks_from_dict(picks):
|
||||
def picks_from_picksdict(picks):
|
||||
picks_list = list()
|
||||
for station, onsets in picks.items():
|
||||
print('Reading picks on station %s' % station)
|
||||
@ -267,17 +268,19 @@ def picks_from_dict(picks):
|
||||
return picks_list
|
||||
|
||||
|
||||
def reassess_pilot_event(root_dir, event_id):
|
||||
def reassess_pilot_event(root_dir, event_id, fn_param=AUTOMATIC_DEFAULTS):
|
||||
from obspy import read
|
||||
from pylot.core.util.defaults import AUTOMATIC_DEFAULTS
|
||||
|
||||
from pylot.core.io.inputs import AutoPickParameter
|
||||
from pylot.core.pick.utils import earllatepicker
|
||||
|
||||
default = AutoPickParameter(AUTOMATIC_DEFAULTS)
|
||||
default = AutoPickParameter(fn_param)
|
||||
|
||||
search_base = os.path.join(root_dir, event_id)
|
||||
phases_file = glob.glob(os.path.join(search_base, 'PHASES.mat'))
|
||||
picks_dict = picks_from_pilot(phases_file)
|
||||
if not phases_file:
|
||||
return
|
||||
picks_dict = picks_from_pilot(phases_file[0])
|
||||
for station in picks_dict.keys():
|
||||
fn_pattern = os.path.join(search_base, '{0}*'.format(station))
|
||||
try:
|
||||
@ -293,19 +296,20 @@ def reassess_pilot_event(root_dir, event_id):
|
||||
except KeyError as e:
|
||||
print(e.message, station)
|
||||
continue
|
||||
epp, lpp, spe = earllatepicker(st,
|
||||
sel_st = select_for_phase(st, phase)
|
||||
epp, lpp, spe = earllatepicker(sel_st,
|
||||
default.get('nfac{0}'.format(phase)),
|
||||
default.get('tsnrz' if phase == 'P' else 'tsnrh'),
|
||||
mpp
|
||||
mpp, None, True
|
||||
)
|
||||
picks_dict[station][phase] = dict(epp=epp, mpp=mpp, lpp=lpp, spe=spe)
|
||||
# create Event object for export
|
||||
evt = ope.Event(resource_id=event_id)
|
||||
evt.picks = picks_from_dict(picks_dict)
|
||||
evt.picks = picks_from_picksdict(picks_dict)
|
||||
# write phase information to file
|
||||
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')
|
||||
#evt.write(fnout_prefix + 'cnv', format='VELEST')
|
||||
|
||||
|
||||
def writephases(arrivals, fformat, filename):
|
||||
|
@ -9,7 +9,7 @@ import matplotlib.pyplot as plt
|
||||
|
||||
from obspy import read_events
|
||||
|
||||
from pylot.core.io.phases import picks_to_dict
|
||||
from pylot.core.io.phases import picksdict_from_picks
|
||||
from pylot.core.util.pdf import ProbabilityDensityFunction
|
||||
from pylot.core.util.version import get_git_version as _getVersionString
|
||||
|
||||
@ -227,7 +227,7 @@ class PDFDictionary(object):
|
||||
if len(cat) > 1:
|
||||
raise NotImplementedError('reading more than one event at the same '
|
||||
'time is not implemented yet! Sorry!')
|
||||
return PDFDictionary(picks_to_dict(cat[0]))
|
||||
return PDFDictionary(picksdict_from_picks(cat[0]))
|
||||
|
||||
def pdf_data(self, type='exp'):
|
||||
"""
|
||||
|
@ -464,6 +464,37 @@ def getResolutionWindow(snr):
|
||||
return time_resolution / 2
|
||||
|
||||
|
||||
def select_for_phase(st, phase):
|
||||
'''
|
||||
takes a STream object and a phase name and returns that particular component
|
||||
which presumably shows the chosen PHASE best
|
||||
|
||||
:param st: stream object containing one or more component[s]
|
||||
:type st: `~obspy.core.stream.Stream`
|
||||
:param phase: label of the phase for which the stream selection is carried
|
||||
out; 'P' or 'S'
|
||||
:type phase: str
|
||||
:return:
|
||||
'''
|
||||
from pylot.core.util.defaults import COMPNAME_MAP
|
||||
|
||||
sel_st = Stream()
|
||||
if phase.upper() is 'P':
|
||||
comp = 'Z'
|
||||
alter_comp = COMPNAME_MAP[comp]
|
||||
sel_st += st.select(component=comp)
|
||||
sel_st += st.select(component=alter_comp)
|
||||
elif phase.upper() is 'S':
|
||||
comps = 'NE'
|
||||
for comp in comps:
|
||||
alter_comp = COMPNAME_MAP[comp]
|
||||
sel_st += st.select(component=comp)
|
||||
sel_st += st.select(component=alter_comp)
|
||||
else:
|
||||
raise TypeError('Unknown phase label: {0}'.format(phase))
|
||||
return sel_st
|
||||
|
||||
|
||||
def wadaticheck(pickdic, dttolerance, iplot):
|
||||
'''
|
||||
Function to calculate Wadati-diagram from given P and S onsets in order
|
||||
|
Loading…
Reference in New Issue
Block a user