Merge branch 'feature/magnitude4QtPyLoT'

Conflicts:
	pylot/core/analysis/magnitude.py
This commit is contained in:
Sebastian Wehling-Benatelli 2016-09-21 10:41:23 +02:00
commit a215ba35b1
2 changed files with 16 additions and 12 deletions

View File

@ -54,6 +54,7 @@ from pylot.core.util.defaults import FILTERDEFAULTS, COMPNAME_MAP, \
from pylot.core.util.errors import FormatError, DatastructureError, \ from pylot.core.util.errors import FormatError, DatastructureError, \
OverwriteError OverwriteError
from pylot.core.util.connection import checkurl from pylot.core.util.connection import checkurl
from pylot.core.util.dataprocessing import read_metadata
from pylot.core.util.utils import fnConstructor, getLogin, \ from pylot.core.util.utils import fnConstructor, getLogin, \
full_range full_range
from pylot.core.io.location import create_creation_info, create_event from pylot.core.io.location import create_creation_info, create_event
@ -1004,6 +1005,7 @@ class MainWindow(QMainWindow):
if ans == QMessageBox.Yes: if ans == QMessageBox.Yes:
settings.setValue("inventoryFile", fninv) settings.setValue("inventoryFile", fninv)
settings.sync() settings.sync()
metadata = read_metadata(fninv)
for a in o.arrivals: for a in o.arrivals:
if a.phase in 'sS': if a.phase in 'sS':
continue continue
@ -1014,12 +1016,13 @@ class MainWindow(QMainWindow):
continue continue
onset = pick.time onset = pick.time
dist = degrees2kilometers(a.distance) 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, a.azimuth, a.takeoff_angle,
self.inputs.get('Qp'), 0) self.inputs.get('Qp'), 0)
if w0 is None or fc is None: if w0 is None or fc is None:
continue 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 mags[station] = station_mag
mag = np.median([M[1] for M in mags.values()]) mag = np.median([M[1] for M in mags.values()])
# give some information on the processing # give some information on the processing

View File

@ -141,8 +141,8 @@ class Magnitude(object):
def setinvdir(self, invdir): def setinvdir(self, invdir):
self.invdir = invdir self.invdir = invdir
def getinvdir(self): def get_metadata(self):
return self.invdir return read_metadata(self.invdir)
def getpicdic(self): def getpicdic(self):
return self.picdic return self.picdic
@ -243,7 +243,7 @@ class M0Mw(Magnitude):
# call subfunction to estimate source spectrum # call subfunction to estimate source spectrum
# and to derive w0 and fc # and to derive w0 and fc
[w0, fc] = calcsourcespec(selwf, picks[key]['P']['mpp'], \ [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()) inc, self.getQp(), self.getiplot())
if w0 is not None: if w0 is not None:
@ -251,8 +251,8 @@ class M0Mw(Magnitude):
zdat = selwf.select(component="Z") zdat = selwf.select(component="Z")
if len(zdat) == 0: # check for other components if len(zdat) == 0: # check for other components
zdat = selwf.select(component="3") zdat = selwf.select(component="3")
[Mo, Mw] = calcMoMw(zdat, w0, self.getrho(), self.getvp(), \ [Mo, Mw] = calcMoMw(zdat, w0, self.getrho(), self.getvp(),
delta, self.getinvdir()) delta)
else: else:
Mo = None Mo = None
Mw = None Mw = None
@ -265,7 +265,7 @@ class M0Mw(Magnitude):
self.picdic = picks 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 Subfunction of run_calcMoMw to calculate individual
seismic moments and corresponding moment magnitudes. seismic moments and corresponding moment magnitudes.
@ -306,7 +306,7 @@ def calcMoMw(wfstream, w0, rho, vp, delta, inv):
return Mo, Mw return Mo, Mw
def calcsourcespec(wfstream, onset, invdir, vp, delta, azimuth, incidence, def calcsourcespec(wfstream, onset, metadata, vp, delta, azimuth, incidence,
qp, iplot): qp, iplot):
''' '''
Subfunction to calculate the source spectrum and to derive from that the plateau 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 :param: onset, P-phase onset time
:type: float :type: float
:param: invdir, path to inventory or dataless-SEED file :param: metadata, tuple or list containing type of inventory and either
:type: string list of files or inventory object
:type: tuple or list
:param: vp, Vp-wave velocity :param: vp, Vp-wave velocity
:type: float :type: float
@ -354,7 +355,7 @@ def calcsourcespec(wfstream, onset, invdir, vp, delta, azimuth, incidence,
data = Data() data = Data()
wf_copy = wfstream.copy() wf_copy = wfstream.copy()
invtype, inventory = read_metadata(invdir) invtype, inventory = metadata
[cordat, restflag] = restitute_data(wf_copy, invtype, inventory) [cordat, restflag] = restitute_data(wf_copy, invtype, inventory)
if restflag is True: if restflag is True: