Exemplo n.º 1
0
 def __init__(self):
   # initiate cross section instance            
   self.xsection = XSection(f,
                            Nl = 20,
                            Nw = 20,clim=(0,0.1),
                            f_args=(self.farg1,self.farg2))
   # add cross sections                                              
   T = transform.identity()
   T += transform.point_stretch([2.0,2.0,1.0])
   T += transform.point_translation([-1.0,0.0,0.0])
   self.xsection.add_transform(T)
   T += transform.point_rotation_x(np.pi/2.0)
   self.xsection.add_transform(T)
   T += transform.point_rotation_x(np.pi/2.0)
   self.xsection.add_transform(T)
   T += transform.point_rotation_x(np.pi/2.0)
   self.xsection.add_transform(T)
   # run HasTraits initiation routine                                                               
   HasTraits.__init__(self)
Exemplo n.º 2
0
def slip_vec(x,coeff,strike,dip,seg):
  s1 = basis.slip(x,coeff[:,0],segment=seg)
  s2 = basis.slip(x,coeff[:,1],segment=seg)
  vec = np.array([s1,s2,0*s2]).transpose()
  argz = np.pi/2.0 - np.pi*strike/180
  argx = np.pi/180.0*dip
  T = trans.point_rotation_x(argx)
  T += trans.point_rotation_z(argz)
  vec = T(vec)
  return vec
Exemplo n.º 3
0
######################################################################
 
FAULT_N = sum(l*w for l,w in zip(FAULT_NLENGTH,FAULT_NWIDTH))
FLUIDITY_N = FLUIDITY_NLENGTH*FLUIDITY_NWIDTH*FLUIDITY_NTHICKNESS

FAULT_SEGMENTS = len(FAULT_ANCHOR)
FAULT_TRANSFORMS = []
FAULT_KNOTS = []

BASEMAP = pickle.load(open('basemap.pkl','r'))

# find knots for faults
for d in range(FAULT_SEGMENTS):
  xc,yc = BASEMAP(*FAULT_ANCHOR[d])   
  t = trans.point_stretch([FAULT_LENGTH[d],FAULT_WIDTH[d],1.0])
  t += trans.point_rotation_x(FAULT_DIP[d]*np.pi/180)
  t += trans.point_rotation_z(np.pi/2.0 - FAULT_STRIKE[d]*np.pi/180)
  t += trans.point_translation([xc,yc,0.0])

  # create knots defining B-splines for slip on a rectangle x = [0,1] 
  # and y = [-1,0]
  fault_knots_x = natural_knots(FAULT_NLENGTH[d],
                                FAULT_ORDER[d][0],side='both')
  fault_knots_y = natural_knots(FAULT_NWIDTH[d],
                                FAULT_ORDER[d][1],side='both') - 1.0
  FAULT_TRANSFORMS += [t]
  FAULT_KNOTS += [(fault_knots_x,fault_knots_y)]

# find knots for fluidity
xc,yc = BASEMAP(*FLUIDITY_ANCHOR)   
t = trans.point_stretch([FLUIDITY_LENGTH,FLUIDITY_WIDTH,FLUIDITY_THICKNESS])
Exemplo n.º 4
0
def view(state,param):
  param = {i:np.array(v) for i,v in param.iteritems()}

  #covert lat lon to xyz
  f = open('basemap.pkl','r')
  bm = pickle.load(f)
  f.close()
   
  fluidity_transforms = []
  x,y = bm(*basis.FLUIDITY_ANCHOR[:2])
  length = basis.FLUIDITY_LENGTH
  width = basis.FLUIDITY_WIDTH
  thickness = basis.FLUIDITY_THICKNESS

  t = trans.point_stretch([basis.FLUIDITY_LENGTH,
                            basis.FLUIDITY_THICKNESS,
                            1.0])
  t += trans.point_rotation_x(np.pi/2.0)
  t += trans.point_translation([0.0,-width/2.0,0.0])
  t += trans.point_rotation_z(np.pi/2.0 - basis.FLUIDITY_STRIKE*np.pi/180) 
  t += trans.point_translation([x,y,0.0])
  fluidity_transforms += [t]

  t = trans.point_stretch([basis.FLUIDITY_WIDTH,
                            basis.FLUIDITY_THICKNESS,
                            1.0])
  t += trans.point_rotation_x(np.pi/2.0)
  t += trans.point_rotation_z(-np.pi/2.0)
  t += trans.point_translation([basis.FLUIDITY_LENGTH/2.0,
                                0.0,
                                0.0])
  t += trans.point_rotation_z(np.pi/2.0 - basis.FLUIDITY_STRIKE*np.pi/180) 
  t += trans.point_translation([x,y,0.0])
  fluidity_transforms += [t]

  fault_transforms = basis.FAULT_TRANSFORMS

  xs1 = XSection(basis.fluidity,
                 f_args=(state['fluidity'][-1],),
                base_square_y=(-1,0),
                transforms = fluidity_transforms,
                 clim = param['fluidity_clim'])

  xs2 = XSection(basis.fluidity,
                f_args=(state['fluidity'][-1],),
                base_square_y=(-1,0),
                transforms = fault_transforms)

  class InteractiveSlip(HasTraits):
    #time_index = Range(0,len(state['slip']),0.5)
    #print(state)
    time = Range(round(min(state['time']),2),round(max(state['time']),2))
    scene = Instance(MlabSceneModel,())
    view = View(Item('scene',editor=SceneEditor(scene_class=MayaviScene),
                height=250,width=300,show_label=False),
                Group('time'),resizable=True)

    def __init__(self):
      #myplot.topo.draw_topography(bm,opacity=0.2)
      time_index = np.argmin(abs(state['time'][...] - self.time))
      slip = np.array(state[str(param['slip_type'])][time_index])
      self.xs = ()
      self.vxs = ()
      for i,t in enumerate(fault_transforms):
        self.xs += XSection(slip_mag,
                            f_args=(slip,i),
                            base_square_y=(-1,0),
                            transforms = [t],clim=param['slip_clim']),
        self.vxs += VectorXSection(slip_vec,
                                   f_args=(slip,basis.FAULT_STRIKE[i],basis.FAULT_DIP[i],i),
                                   base_square_y=(-1,0),
                                   transforms = [t]),
      HasTraits.__init__(self)

    @on_trait_change('time,scene.activated')
    def update_plot(self):
      time_index = np.argmin(abs(state['time'][...] - self.time))
      slip = np.array(state[str(param['slip_type'])][time_index])
      for i,t in enumerate(fault_transforms):
        self.xs[i].set_f_args((slip,i))
        self.vxs[i].set_f_args((slip,basis.FAULT_STRIKE[i],basis.FAULT_DIP[i],i))
        if self.xs[i]._plots is None:
          self.xs[i].draw()
        else:
          self.xs[i].redraw()   
        if self.vxs[i]._plots is None:
          self.vxs[i].draw()
        else:
          self.vxs[i].redraw()   

      #myplot.topo.draw_topography(bm,opacity=0.2) 

  mayavi.mlab.figure(1)
  xs1.draw()
  xs2.draw(color=(0.2,0.2,0.2),opacity=0.5)
  myplot.topo.draw_topography(bm,opacity=0.2)
  #mayavi.mlab.figure(2)
  xs2 = InteractiveSlip()
  xs2.configure_traits()