make creating new event work
This commit is contained in:
parent
a86a2efb8a
commit
e321ad26b2
@ -35,7 +35,7 @@ from pylot.core.read import Data, FilterOptions
|
||||
from pylot.core.util import _getVersionString, FILTERDEFAULTS, fnConstructor, \
|
||||
checkurl, FormatError, FilterOptionsDialog, \
|
||||
NewEventDlg, createEvent, MPLWidget, PropertiesDlg, HelpForm, \
|
||||
DatastructureError, createAction, getLogin
|
||||
DatastructureError, createAction, getLogin, createCreationInfo
|
||||
from pylot.core.util.structure import DATASTRUCTURE
|
||||
|
||||
|
||||
@ -58,7 +58,8 @@ class MainWindow(QMainWindow):
|
||||
fulluser = QInputDialog.getText(self, "Enter Name:", "Full name")
|
||||
settings.setValue("user/FullName", fulluser)
|
||||
settings.setValue("user/Login", getLogin())
|
||||
settings.sync()
|
||||
if settings.value("agency_id", None) is None:
|
||||
agency = QInputDialog.getText(self, "Enter authority name (e.g. BUG):", "Authority")
|
||||
self.recentEvents = settings.value("data/recentEvents", [])
|
||||
self.fnames = None
|
||||
self.dataStructure = DATASTRUCTURE[
|
||||
@ -446,7 +447,8 @@ class MainWindow(QMainWindow):
|
||||
new = NewEventDlg()
|
||||
if new.exec_() != QDialog.Rejected:
|
||||
evtpar = new.getValues()
|
||||
|
||||
cinfo = createCreationInfo(agency_id=self.agency)
|
||||
event = createEvent(evtpar['origintime'])
|
||||
self.data = Data(self, evtdata=createEvent(**evtpar))
|
||||
self.dirty = True
|
||||
|
||||
|
@ -4,7 +4,7 @@ from pylot.core.util.errors import OptionsError, FormatError, DatastructureError
|
||||
from pylot.core.util.layouts import layoutStationButtons
|
||||
from pylot.core.util.utils import fnConstructor, createArrival, createEvent,\
|
||||
createPick, createAmplitude, createOrigin, createMagnitude, getOwner, \
|
||||
getHash, getLogin
|
||||
getHash, getLogin, createCreationInfo, createResourceID
|
||||
from pylot.core.util.widgets import PickDlg, HelpForm, FilterOptionsDialog,\
|
||||
PropertiesDlg, NewEventDlg, MPLWidget, createAction
|
||||
from pylot.core.util.version import get_git_version as _getVersionString
|
||||
|
@ -22,7 +22,6 @@ def fnConstructor(s):
|
||||
fn = '_' + fn
|
||||
return fn
|
||||
|
||||
|
||||
def getLogin():
|
||||
return pwd.getpwuid(os.getuid())[0]
|
||||
|
||||
@ -36,6 +35,13 @@ def getHash(time):
|
||||
hg.update(time.strftime('%Y-%m-%d %H:%M:%S.%f'))
|
||||
return hg.hexdigest()
|
||||
|
||||
def createCreationInfo(agency_id=None, creation_time=None, author=None):
|
||||
if author is None:
|
||||
author = getLogin()
|
||||
if creation_time is None:
|
||||
creation_time = UTCDateTime()
|
||||
return ope.CreationInfo(agency_id=agency_id, author=author,
|
||||
creation_time=creation_time)
|
||||
|
||||
def createResourceID(timetohash, restype, authority_id=None, hrstr=None):
|
||||
'''
|
||||
@ -58,7 +64,6 @@ def createResourceID(timetohash, restype, authority_id=None, hrstr=None):
|
||||
resID.convertIDToQuakeMLURI(authority_id=authority_id)
|
||||
return resID
|
||||
|
||||
|
||||
def createOrigin(origintime, cinfo, latitude, longitude, depth, resID=None,
|
||||
authority_id=None):
|
||||
'''
|
||||
@ -88,7 +93,6 @@ def createOrigin(origintime, cinfo, latitude, longitude, depth, resID=None,
|
||||
origin.depth = depth
|
||||
return origin
|
||||
|
||||
|
||||
def createEvent(origintime, cinfo, etype, resID=None, authority_id=None):
|
||||
'''
|
||||
createEvent - funtion to create an ObsPy Event
|
||||
@ -118,7 +122,6 @@ def createEvent(origintime, cinfo, etype, resID=None, authority_id=None):
|
||||
event.event_type = etype
|
||||
return event
|
||||
|
||||
|
||||
def createPick(origintime, picknum, picktime, eventnum, cinfo, phase, station,
|
||||
wfseedstr, authority_id):
|
||||
'''
|
||||
@ -153,7 +156,6 @@ def createPick(origintime, picknum, picktime, eventnum, cinfo, phase, station,
|
||||
pick.waveform_id = ope.ResourceIdentifier(id=wfseedstr, prefix='file:/')
|
||||
return pick
|
||||
|
||||
|
||||
def createArrival(origintime, pickresID, eventnum, cinfo, phase, station,
|
||||
authority_id, azimuth=None, dist=None):
|
||||
'''
|
||||
@ -191,7 +193,6 @@ def createArrival(origintime, pickresID, eventnum, cinfo, phase, station,
|
||||
arrival.distance = None
|
||||
return arrival
|
||||
|
||||
|
||||
def createMagnitude(originID, origintime, cinfo, authority_id=None):
|
||||
'''
|
||||
createMagnitude - function to create an ObsPy Magnitude object
|
||||
@ -208,7 +209,6 @@ def createMagnitude(originID, origintime, cinfo, authority_id=None):
|
||||
magnitude.origin_id = originID
|
||||
return magnitude
|
||||
|
||||
|
||||
def createAmplitude(pickID, amp, unit, category, origintime, cinfo,
|
||||
authority_id=None):
|
||||
amplresID = createResourceID(origintime, 'ampl', authority_id)
|
||||
@ -221,7 +221,6 @@ def createAmplitude(pickID, amp, unit, category, origintime, cinfo,
|
||||
amplitude.pick_id = pickID
|
||||
return amplitude
|
||||
|
||||
|
||||
def getOwner(fn):
|
||||
return pwd.getpwuid(os.stat(fn).st_uid).pw_name
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user