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