Merge branch 'feature/magnitude4QtPyLoT'
Conflicts: pylot/core/analysis/magnitude.py
This commit is contained in:
commit
a215ba35b1
@ -54,6 +54,7 @@ from pylot.core.util.defaults import FILTERDEFAULTS, COMPNAME_MAP, \
|
||||
from pylot.core.util.errors import FormatError, DatastructureError, \
|
||||
OverwriteError
|
||||
from pylot.core.util.connection import checkurl
|
||||
from pylot.core.util.dataprocessing import read_metadata
|
||||
from pylot.core.util.utils import fnConstructor, getLogin, \
|
||||
full_range
|
||||
from pylot.core.io.location import create_creation_info, create_event
|
||||
@ -1004,6 +1005,7 @@ class MainWindow(QMainWindow):
|
||||
if ans == QMessageBox.Yes:
|
||||
settings.setValue("inventoryFile", fninv)
|
||||
settings.sync()
|
||||
metadata = read_metadata(fninv)
|
||||
for a in o.arrivals:
|
||||
if a.phase in 'sS':
|
||||
continue
|
||||
@ -1014,12 +1016,13 @@ class MainWindow(QMainWindow):
|
||||
continue
|
||||
onset = pick.time
|
||||
dist = degrees2kilometers(a.distance)
|
||||
w0, fc = calcsourcespec(wf, onset, fninv, self.inputs.get('vp'), dist,
|
||||
w0, fc = calcsourcespec(wf, onset, metadata, self.inputs.get('vp'), dist,
|
||||
a.azimuth, a.takeoff_angle,
|
||||
self.inputs.get('Qp'), 0)
|
||||
if w0 is None or fc is None:
|
||||
continue
|
||||
station_mag = calcMoMw(wf, w0, 2700., 3000., dist, fninv)
|
||||
station_mag = calcMoMw(wf, w0, self.inputs.get('rho'),
|
||||
self.inputs.get('vp'), dist)
|
||||
mags[station] = station_mag
|
||||
mag = np.median([M[1] for M in mags.values()])
|
||||
# give some information on the processing
|
||||
|
@ -141,8 +141,8 @@ class Magnitude(object):
|
||||
def setinvdir(self, invdir):
|
||||
self.invdir = invdir
|
||||
|
||||
def getinvdir(self):
|
||||
return self.invdir
|
||||
def get_metadata(self):
|
||||
return read_metadata(self.invdir)
|
||||
|
||||
def getpicdic(self):
|
||||
return self.picdic
|
||||
@ -243,7 +243,7 @@ class M0Mw(Magnitude):
|
||||
# call subfunction to estimate source spectrum
|
||||
# and to derive w0 and fc
|
||||
[w0, fc] = calcsourcespec(selwf, picks[key]['P']['mpp'], \
|
||||
self.getinvdir(), self.getvp(), delta, az, \
|
||||
self.get_metadata(), self.getvp(), delta, az, \
|
||||
inc, self.getQp(), self.getiplot())
|
||||
|
||||
if w0 is not None:
|
||||
@ -251,8 +251,8 @@ class M0Mw(Magnitude):
|
||||
zdat = selwf.select(component="Z")
|
||||
if len(zdat) == 0: # check for other components
|
||||
zdat = selwf.select(component="3")
|
||||
[Mo, Mw] = calcMoMw(zdat, w0, self.getrho(), self.getvp(), \
|
||||
delta, self.getinvdir())
|
||||
[Mo, Mw] = calcMoMw(zdat, w0, self.getrho(), self.getvp(),
|
||||
delta)
|
||||
else:
|
||||
Mo = None
|
||||
Mw = None
|
||||
@ -265,7 +265,7 @@ class M0Mw(Magnitude):
|
||||
self.picdic = picks
|
||||
|
||||
|
||||
def calcMoMw(wfstream, w0, rho, vp, delta, inv):
|
||||
def calcMoMw(wfstream, w0, rho, vp, delta):
|
||||
'''
|
||||
Subfunction of run_calcMoMw to calculate individual
|
||||
seismic moments and corresponding moment magnitudes.
|
||||
@ -306,7 +306,7 @@ def calcMoMw(wfstream, w0, rho, vp, delta, inv):
|
||||
return Mo, Mw
|
||||
|
||||
|
||||
def calcsourcespec(wfstream, onset, invdir, vp, delta, azimuth, incidence,
|
||||
def calcsourcespec(wfstream, onset, metadata, vp, delta, azimuth, incidence,
|
||||
qp, iplot):
|
||||
'''
|
||||
Subfunction to calculate the source spectrum and to derive from that the plateau
|
||||
@ -321,8 +321,9 @@ def calcsourcespec(wfstream, onset, invdir, vp, delta, azimuth, incidence,
|
||||
:param: onset, P-phase onset time
|
||||
:type: float
|
||||
|
||||
:param: invdir, path to inventory or dataless-SEED file
|
||||
:type: string
|
||||
:param: metadata, tuple or list containing type of inventory and either
|
||||
list of files or inventory object
|
||||
:type: tuple or list
|
||||
|
||||
:param: vp, Vp-wave velocity
|
||||
:type: float
|
||||
@ -354,7 +355,7 @@ def calcsourcespec(wfstream, onset, invdir, vp, delta, azimuth, incidence,
|
||||
data = Data()
|
||||
wf_copy = wfstream.copy()
|
||||
|
||||
invtype, inventory = read_metadata(invdir)
|
||||
invtype, inventory = metadata
|
||||
|
||||
[cordat, restflag] = restitute_data(wf_copy, invtype, inventory)
|
||||
if restflag is True:
|
||||
|
Loading…
Reference in New Issue
Block a user