Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 3d3abccded
Fetching contributors…

Cannot retrieve contributors at this time

98 lines (84 sloc) 4.049 kb
import pdb
import numpy as np
import progressbar
phaseReMap = {'p' : 0, 's' : 1, 'Scs' : 2, 'Scss' : 3}
class decomposer:
def __init__(self):
def findMinimumMisfit(results, modelname, phaseName):
This Method extracts the minimum misfits for a given modelname and a
given phaseName.
:param results: dict containing numpy nd arrays containing misfits.
:param modelname: name of model to investigate
:param phaseName: name of phase to investigate
:param returns: list with 3d array with lowest misfit at each latitude
and longitude in a column undernath as the first and
an index array of the retrieved misfits'
numberOfLats, numberOfLons, numberOfDepths, numberOfPhases = results[modelname].shape
minMFArray = np.ndarray(shape=(numberOfLats, numberOfLons,1))
minMFIndexArray = np.ndarray(shape=(numberOfLats, numberOfLons,1))
print 'searching minimum misfits...'
ProBar = progressbar.ProgressBar(numberOfLats*numberOfLons).start()
iteration = 0
absminvalue = 1000
for latindx in range(0, numberOfLats):
for lonindx in range(0, numberOfLons):
# Minimum misfit for this lat/lon of all depths:
mindepthIndex = np.argmin(np.transpose(results[modelname]\
lowestMF = results[modelname][latindx][lonindx]\
minMFArray[latindx][lonindx] = lowestMF
if lowestMF<= absminvalue:
lowestMFPosition = [latindx, lonindx, mindepthIndex]
absminvalue = lowestMF
iteration += 1
return [minMFArray, lowestMFPosition]
def extractHorizontalLayer(results, modelname, phasename, depth, depths):
:param results: dict containing misfits for individual models
:param phasename: string with phasename of which a misfitlayer is to be extracted
:param depth: depth of the layer
:param depths: list with all depths. Length has to be equivalent to 3rd dimension
of the misfit array.
# Extract depth layer
indx = depths.index(depth)
zIndices = np.zeros(len(depths))
zIndices[indx] = 1
extractedLayer = results[modelname].compress(zIndices,2)
# Extract phase layer
pIndices = np.zeros(len(phaseReMap))
pIndices[phaseReMap[phasename]] = 1
extractedLayer = extractedLayer.compress(pIndices,3)
return extractedLayer
def getMinimumMisfitForLatindxLonindx(results, modelname, phasename, latindx, lonindx):
:param results: numpy nd results array
:param modelname: modelname as string
:param phasename: phasename as string
:param latindx: index of latitude dimension in results array
:param lonindx: index of longitude dimension in results arrays
:param returns: the minimum misfit of the given latitude index and
longitude index and the index of this value
depthSlice = results[modelname][latindx][lonindx]
# extract misfits of one phase:
phaseindx = np.zeros(4)
phaseindx[phaseReMap[phasename]] = 1
thisPhaseMisfits = depthSlice.compress(phaseindx, 1)
return min(thisPhaseMisfits), np.argmin(thisPhaseMisfits)
def getMisfitColumn(results, modelname, latindx, lonindx):
depthSlice = results[modelname][latindx][lonindx]
return depthSlice
Jump to Line
Something went wrong with that request. Please try again.