Exemplo n.º 1
0
def slip(x,coeff,segment=None,diff=None):
  '''
  takes positions, x, and slip coefficients, coeff, and returns the
  vaues for slip. The segment key word is specified to only use
  coefficients corresponding to the specified fault segment.  if no
  segment is specified then all coefficients will be used
  '''
  minN = 0
  s = segment
  out = np.zeros(len(x))
  assert len(coeff) == FAULT_N, (
    'coefficient list must have length %s' % FAULT_N)

  if s is None:
    for d in range(FAULT_SEGMENTS):
      t = FAULT_TRANSFORMS[d].inverse()
      fx = t(x)[:,[0,1]]
      shape = FAULT_NLENGTH[d],FAULT_NWIDTH[d]
      order = FAULT_ORDER[d]
      maxN = minN + np.prod(shape)
      for n in range(minN,maxN):
        idx = linear_to_array_index(n-minN,shape)
        out += coeff[n]*bspline_nd(fx,FAULT_KNOTS[d],idx,order,diff=diff)

      minN += np.prod(shape)

  else:
    for d in range(s):
      shape = FAULT_NLENGTH[d],FAULT_NWIDTH[d]
      maxN = minN + np.prod(shape)
      minN += np.prod(shape)

    shape = FAULT_NLENGTH[s],FAULT_NWIDTH[s]
    maxN = minN + np.prod(shape)
    t = FAULT_TRANSFORMS[s].inverse()
    fx = t(x)[:,[0,1]]
    order = FAULT_ORDER[s]
    for n in range(minN,maxN):
      idx = linear_to_array_index(n-minN,shape)
      out += coeff[n]*bspline_nd(fx,FAULT_KNOTS[s],idx,order,diff=diff)

    minN += np.prod(shape)

  return out
Exemplo n.º 2
0
def fluidity(x,coeff,diff=None):
  out = np.zeros(len(x))
  t = FLUIDITY_TRANSFORM.inverse()
  fx = t(x)
  shape = FLUIDITY_NLENGTH,FLUIDITY_NWIDTH,FLUIDITY_NTHICKNESS
  order = FLUIDITY_ORDER
  for n in range(FLUIDITY_N):
    idx = linear_to_array_index(n,shape)
    out += coeff[n]*bspline_nd(fx,FLUIDITY_KNOTS,idx,order,diff=diff)

  return out