[edit] fixing bugs (in progress)

This commit is contained in:
Sebastian Wehling-Benatelli 2016-05-27 12:53:34 +02:00
parent 618dd10c23
commit 36b0aea86c
3 changed files with 78 additions and 75 deletions

View File

@ -203,7 +203,7 @@ class MainWindow(QMainWindow):
"Load location information on "
"the actual event.")
loadpilotevent = self.createAction(self, "Load PILOT &event ...",
self.load_pilot, "Ctrl+E",
self.load_pilotevent, "Ctrl+E",
loadpiloticon,
"Load PILOT event from information "
"Matlab binary collections.")
@ -397,17 +397,22 @@ class MainWindow(QMainWindow):
filt = "PILOT location files (*.mat)"
caption = "Select PILOT loaction file"
fn_loc = QFileDialog().getOpenFileName(self, caption=caption,
filter=filt)
filter=filt, dir=self.getRoot())
fn_loc = fn_loc[0]
loc_dir = os.path.split(fn_loc)[0]
filt = "PILOT phases files (*.mat)"
caption = "Select PILOT phases file"
fn_phases = QFileDialog().getOpenFileName(self, caption=caption,
filter=filt)
filter=filt, dir=loc_dir)
fn_phases = fn_phases[0]
type = QInputDialog().getItem(self, self.tr("Select phases type"),
self.tr("Type:"), [self.tr("manual"),
self.tr("automatic")])
if type.startswith('auto'):
if type[0].startswith('auto'):
type = 'auto'
else:
type = type[0]
fname_dict = dict(phasfn=fn_phases, locfn=fn_loc)
self.load_data(fname_dict, type=type)

View File

@ -68,8 +68,8 @@ def create_creation_info(agency_id=None, creation_time=None, author=None):
creation_time=creation_time)
def create_event(origintime, cinfo, originloc=None, etype=None, resID=None,
authority_id=None):
def create_event(origintime, cinfo, originloc=None, etype='earthquake',
resID=None, authority_id=None):
'''
create_event - funtion to create an ObsPy Event
@ -90,14 +90,12 @@ def create_event(origintime, cinfo, originloc=None, etype=None, resID=None,
:type authority_id: str
:return: An ObsPy :class: `~obspy.core.event.Event` object
'''
etype = ope.EventType(etype)
if originloc is not None:
o = create_origin(origintime, cinfo,
originloc[0], originloc[1], originloc[2])
else:
o = None
if etype is None:
etype = ope.EventType('earthquake') # defaults to 'earthquake'
if not resID:
resID = create_resourceID(origintime, etype, authority_id)
elif isinstance(resID, str):
@ -216,7 +214,7 @@ def create_resourceID(timetohash, restype, authority_id=None, hrstr=None):
if hrstr is None:
resID = ope.ResourceIdentifier(restype + '/' + hid[0:6])
else:
resID = ope.ResourceIdentifier(restype + '/' + hrstr + '_' + hid[0:6])
resID = ope.ResourceIdentifier(restype + '/' + hrstr)
if authority_id is not None:
resID.convertIDToQuakeMLURI(authority_id=authority_id)
return resID

View File

@ -54,8 +54,8 @@ def readPILOTEvent(phasfn=None, locfn=None, authority_id='RUB', **kwargs):
author=locauthor,
creation_time=locctime)
np = 0
try:
eventNum = loc['ID'][0]
#try:
eventNum = str(loc['ID'][0])
# retrieve eventID for the actual database
idsplit = eventNum.split('.')
@ -74,14 +74,14 @@ def readPILOTEvent(phasfn=None, locfn=None, authority_id='RUB', **kwargs):
stations = [stat for stat in phases['stat'][0:-1:3]]
event = create_event(eventDate, loccinfo, etype='earthquake',
resID=eventNum, authority_id=authority_id)
lat = float(loc['LAT'])
lon = float(loc['LON'])
dep = float(loc['DEP'])
origin = create_origin(eventDate, loccinfo, lat, lon, dep)
event = create_event(eventDate, loccinfo, originloc=(lat, lon, dep),
etype='earthquake', resID=eventNum,
authority_id=authority_id)
for n, pick in enumerate(phases['Ptime']):
if pick[0] > 0:
kwargs = {'year': int(pick[0]),
@ -119,21 +119,21 @@ def readPILOTEvent(phasfn=None, locfn=None, authority_id='RUB', **kwargs):
event.picks.append(pick)
pickID = pick.get('id')
arrival = create_arrival(pickID, pickcinfo, phase)
origin.arrivals.append(arrival)
if event.origins:
event.origins[0].arrivals.append(arrival)
event.picks.append(pick)
np += 1
if event.origins:
origin = event.origins[0]
magnitude = create_magnitude(origin.get('id'), loccinfo)
magnitude.mag = float(loc['Mnet'])
magnitude.magnitude_type = 'Ml'
event.origins.append(origin)
event.magnitudes.append(magnitude)
return event
except AttributeError as e:
raise AttributeError('{0} - Matlab LOC files {1} and {2} contains \
insufficient data!'.format(e, phasfn, locfn))
#except AttributeError as e:
# raise AttributeError('{0} - Matlab LOC files {1} and {2} contains \
# insufficient data!'.format(e, phasfn, locfn))
def picks_from_pilot(fn):