Example #1
0
def test(mfault):

    from clawpack.clawutil.data import ClawData

    length_scale = 1.e-3 # m to km
    probdata = ClawData()
    probdata.read('setprob.data',force=True)

    fault = dtopotools.Fault()
    fault.read('fault.data')

    mapping = Mapping(fault)

    domain_depth = probdata.domain_depth
    domain_width = probdata.domain_width

    # num of cells here determined in a similar fashion to that in setrun.py
    dx = mapping.fault_width/mfault
    num_cells_above = numpy.rint(mapping.fault_depth/dx)
    dy = mapping.fault_depth/num_cells_above
    mx = int(numpy.ceil(domain_width/dx)) # mx
    my = int(numpy.ceil(domain_depth/dy)) # my
    mr = mx - mfault

    x = linspace(mapping.xcenter-0.5*mapping.fault_width - numpy.floor(mr/2.0)*dx, mapping.xcenter+0.5*mapping.fault_width + numpy.ceil(mr/2.0)*dx, mx+1)
    y = linspace(-my*dy, 0.0, my+1)
    xc,yc = meshgrid(x,y)
    xp,yp = mapping.mapc2p(xc,yc)
    figure()
    plot(xp*length_scale,yp*length_scale,'k-')
    plot(xp.T*length_scale,yp.T*length_scale,'k-')
    plot((mapping.xp1*length_scale,mapping.xp2*length_scale),
            (mapping.yp1*length_scale,mapping.yp2*length_scale),'-g',linewidth=3)
    axis('scaled')
def setplot(plotdata):
    #--------------------------
    """
    Specify what is to be plotted at each frame.
    Input:  plotdata, an instance of clawpack.visclaw.data.ClawPlotData.
    Output: a modified version of plotdata.

    """
    slice_number = 3
    tmpdir = os.path.abspath(os.curdir)
    os.chdir(plotdata.outdir)
    for filename in os.listdir('.'):
        if (filename.startswith('slice_%d' % slice_number)):
            shutil.copyfile(
                filename, filename.replace('slice_%d' % slice_number, 'fort',
                                           1))

    fault = dtopotools.Fault()
    fault.read('fault.data')

    os.chdir(tmpdir)

    mapping = Mapping(fault)

    xp1 = mapping.xp1 * length_scale
    xp2 = mapping.xp2 * length_scale
    zp1 = mapping.zp1 * length_scale
    zp2 = mapping.zp2 * length_scale
    xcenter = mapping.xcenter
    ycenter = mapping.ycenter

    def mapc2p(xc, yc):
        xp, yp = mapping.mapc2p_xz(xc, yc)
        return xp * length_scale, yp * length_scale

    def plot_fault(current_data):
        from pylab import linspace, plot, xlabel, ylabel, tick_params
        xl = linspace(xp1, xp2, 100)
        zl = linspace(zp1, zp2, 100)
        plot(xl, zl, 'g', linewidth=3)
        tick_params(labelsize=25)
        xlabel('kilometers', fontsize=25)
        ylabel('kilometers', fontsize=25)

    from clawpack.visclaw import colormaps

    plotdata.clearfigures()  # clear any old figures,axes,items data

    #plotdata.format = 'binary'

    def sigmatr(current_data):
        # return -trace(sigma)
        q = current_data.q
        return -(q[0, :, :] + q[1, :, :] + q[2, :, :])

    # Figure for trace(sigma)
    plotfigure = plotdata.new_plotfigure(name='fault', figno=1)
    plotfigure.kwargs = {'figsize': (11, 6)}

    # Set up for axes in this figure:
    plotaxes = plotfigure.new_plotaxes()
    plotaxes.xlimits = xlimits
    plotaxes.ylimits = zlimits
    plotaxes.title_with_t = False
    plotaxes.title = ''
    plotaxes.scaled = True
    plotaxes.afteraxes = plot_fault

    # Set up for item on these axes:
    plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor')
    plotitem.plot_var = sigmatr
    plotitem.pcolor_cmap = colormaps.blue_white_red
    plotitem.pcolor_cmin = -1e6
    plotitem.pcolor_cmax = 1e6
    plotitem.add_colorbar = False
    plotitem.amr_celledges_show = [0]
    plotitem.amr_patchedges_show = [0]
    plotitem.MappedGrid = True
    plotitem.mapc2p = mapc2p

    # Parameters used only when creating html and/or latex hardcopy
    # e.g., via clawpack.visclaw.frametools.printframes:

    plotdata.printfigs = True  # print figures
    plotdata.print_format = 'png'  # file format
    plotdata.print_framenos = 'all'  # list of frames to print
    plotdata.print_fignos = 'all'  # list of figures to print
    plotdata.html = True  # create html files of plots?
    plotdata.html_homelink = '../README.html'  # pointer for top of index
    plotdata.latex = True  # create latex file of plots?
    plotdata.latex_figsperline = 2  # layout of plots
    plotdata.latex_framesperline = 1  # layout of plots
    plotdata.latex_makepdf = False  # also run pdflatex?
    #    plotdata.parallel = True

    return plotdata
def setrun(claw_pkg='amrclaw'):
    #------------------------------
    """
    Define the parameters used for running Clawpack.

    INPUT:
        claw_pkg expected to be "amrclaw" for this setrun.

    OUTPUT:
        rundata - object of class ClawRunData

    """

    from clawpack.clawutil import data

    assert claw_pkg.lower() == 'amrclaw', "Expected claw_pkg = 'amrclaw'"

    num_dim = 2
    rundata = data.ClawRunData(claw_pkg, num_dim)

    #------------------------------------------------------------------
    # Problem-specific parameters to be written to setprob.data:
    #------------------------------------------------------------------
    probdata = rundata.new_UserData(name='probdata', fname='setprob.data')
    probdata.add_param('domain_depth', 300e3, 'depth of domain')
    probdata.add_param('domain_width', 600e3, 'width of domain')

    #------------------------------------------------------------------
    # Read in fault information
    #------------------------------------------------------------------
    fault = dtopotools.Fault()
    fault.read('fault.data')

    mapping = Mapping(fault)
    fault_width = mapping.fault_width
    fault_depth = mapping.fault_depth
    fault_center = mapping.xcenter

    rupture_rise_time = 0.0
    for subfault in fault.subfaults:
        rupture_rise_time = max(rupture_rise_time,
                                subfault.rupture_time + subfault.rise_time)
    #------------------------------------------------------------------
    # Standard Clawpack parameters to be written to claw.data:
    #------------------------------------------------------------------

    clawdata = rundata.clawdata  # initialized when rundata instantiated

    # ---------------
    # Spatial domain:
    # ---------------

    # Number of space dimensions:
    clawdata.num_dim = num_dim

    # Number of grid cells:
    num_cells_fault = 4
    dx = fault_width / num_cells_fault

    # determine cell number and set computational boundaries
    target_num_cells = np.rint(probdata.domain_width / dx)  # x direction
    num_cells_below = np.rint((target_num_cells - num_cells_fault) / 2.0)
    num_cells_above = target_num_cells - num_cells_below - num_cells_fault
    clawdata.lower[0] = fault_center - 0.5 * fault_width - num_cells_below * dx
    clawdata.upper[0] = fault_center + 0.5 * fault_width + num_cells_above * dx
    clawdata.num_cells[0] = int(num_cells_below + num_cells_fault +
                                num_cells_above)

    num_cells_above = np.rint(fault_depth / dx)  # y direction
    dy = fault_depth / num_cells_above
    target_num_cells = np.rint(probdata.domain_depth / dy)
    num_cells_below = target_num_cells - num_cells_above
    clawdata.lower[1] = -fault_depth - num_cells_below * dy
    clawdata.upper[1] = 0.0
    clawdata.num_cells[1] = int(num_cells_below + num_cells_above)

    # adjust probdata
    probdata.domain_width = clawdata.upper[0] - clawdata.lower[0]
    probdata.domain_depth = clawdata.upper[1] - clawdata.lower[1]

    # ---------------
    # Size of system:
    # ---------------

    # Number of equations in the system:
    clawdata.num_eqn = 5

    # Number of auxiliary variables in the aux array (initialized in setaux)
    clawdata.num_aux = 13

    # Index of aux array corresponding to capacity function, if there is one:
    clawdata.capa_index = 12

    # -------------
    # Initial time:
    # -------------

    clawdata.t0 = 0.000000

    # Restart from checkpoint file of a previous run?
    # Note: If restarting, you must also change the Makefile to set:
    #    RESTART = True
    # If restarting, t0 above should be from original run, and the
    # restart_file 'fort.qNNNN' specified below should be in
    # the OUTDIR indicated in Makefile.

    clawdata.restart = False  # True to restart from prior results
    clawdata.restart_file = 'fort.q0006'  # File to use for restart data

    # -------------
    # Output times:
    #--------------

    # Specify at what times the results should be written to fort.q files.
    # Note that the time integration stops after the final output time.

    clawdata.output_style = 2

    if clawdata.output_style == 1:
        # Output ntimes frames at equally spaced times up to tfinal:
        # Can specify num_output_times = 0 for no output
        clawdata.num_output_times = 50
        clawdata.tfinal = 100.0
        clawdata.output_t0 = True  # output at initial (or restart) time?

    elif clawdata.output_style == 2:
        # Specify a list or numpy array of output times:
        # Include t0 if you want output at the initial time.
        clawdata.output_times = [90.0]

    elif clawdata.output_style == 3:
        # Output every step_interval timesteps over total_steps timesteps:
        clawdata.output_step_interval = 1
        clawdata.total_steps = 40
        clawdata.output_t0 = True  # output at initial (or restart) time?

    clawdata.output_format = 'binary'  # 'ascii', 'binary', 'netcdf'

    clawdata.output_q_components = 'all'  # could be list such as [True,True]
    clawdata.output_aux_components = 'none'  # could be list
    clawdata.output_aux_onlyonce = True  # output aux arrays only at t0

    # ---------------------------------------------------
    # Verbosity of messages to screen during integration:
    # ---------------------------------------------------

    # The current t, dt, and cfl will be printed every time step
    # at AMR levels <= verbosity.  Set verbosity = 0 for no printing.
    #   (E.g. verbosity == 2 means print only on levels 1 and 2.)
    clawdata.verbosity = 0

    # --------------
    # Time stepping:
    # --------------

    # if dt_variable==True:  variable time steps used based on cfl_desired,
    # if dt_variable==False: fixed time steps dt = dt_initial always used.
    clawdata.dt_variable = True

    # Initial time step for variable dt.
    # (If dt_variable==0 then dt=dt_initial for all steps)
    clawdata.dt_initial = 0.25

    # Max time step to be allowed if variable dt used:
    clawdata.dt_max = 1.000000e+99

    # Desired Courant number if variable dt used
    clawdata.cfl_desired = 0.900000
    # max Courant number to allow without retaking step with a smaller dt:
    clawdata.cfl_max = 1.000000

    # Maximum number of time steps to allow between output times:
    clawdata.steps_max = 1000

    # ------------------
    # Method to be used:
    # ------------------

    # Order of accuracy:  1 => Godunov,  2 => Lax-Wendroff plus limiters
    clawdata.order = 2

    # Use dimensional splitting? (not yet available for AMR)
    clawdata.dimensional_split = 'unsplit'

    # For unsplit method, transverse_waves can be
    #  0 or 'none'      ==> donor cell (only normal solver used)
    #  1 or 'increment' ==> corner transport of waves
    #  2 or 'all'       ==> corner transport of 2nd order corrections too
    clawdata.transverse_waves = 2

    # Number of waves in the Riemann solution:
    clawdata.num_waves = 4

    # List of limiters to use for each wave family:
    # Required:  len(limiter) == num_waves
    # Some options:
    #   0 or 'none'     ==> no limiter (Lax-Wendroff)
    #   1 or 'minmod'   ==> minmod
    #   2 or 'superbee' ==> superbee
    #   3 or 'vanleer'  ==> van Leer
    #   4 or 'mc'       ==> MC limiter
    clawdata.limiter = ['mc', 'mc', 'mc', 'mc']

    clawdata.use_fwaves = False  # True ==> use f-wave version of algorithms

    # Source terms splitting:
    #   src_split == 0 or 'none'    ==> no source term (src routine never called)
    #   src_split == 1 or 'godunov' ==> Godunov (1st order) splitting used,
    #   src_split == 2 or 'strang'  ==> Strang (2nd order) splitting used,  not recommended.
    clawdata.source_split = 0

    # --------------------
    # Boundary conditions:
    # --------------------

    # Number of ghost cells (usually 2)
    clawdata.num_ghost = 2

    # Choice of BCs at xlower and xupper:
    #   0 or 'user'     => user specified (must modify bcNamr.f to use this option)
    #   1 or 'extrap'   => extrapolation (non-reflecting outflow)
    #   2 or 'periodic' => periodic (must specify this at both boundaries)
    #   3 or 'wall'     => solid wall for systems where q(2) is normal velocity

    clawdata.bc_lower[0] = 'extrap'  # at xlower
    clawdata.bc_upper[0] = 'extrap'  # at xupper

    clawdata.bc_lower[1] = 'extrap'  # at ylower
    clawdata.bc_upper[1] = 'user'  # at yupper

    # ---------------
    # Gauges:
    # ---------------
    gauges = rundata.gaugedata.gauges
    # for gauges append lines of the form  [gaugeno, x, y, t1, t2]
    # top edge:
    xgauges = np.linspace(-150e3, 200e3, 350)
    for gaugeno, x in enumerate(xgauges):
        gauges.append([gaugeno, x, clawdata.upper[1] - 1, 0, 1e10])

    # --------------
    # Checkpointing:
    # --------------

    # Specify when checkpoint files should be created that can be
    # used to restart a computation.

    clawdata.checkpt_style = 2

    if clawdata.checkpt_style == 0:
        # Do not checkpoint at all
        pass

    elif clawdata.checkpt_style == 1:
        # Checkpoint only at tfinal.
        pass

    elif clawdata.checkpt_style == 2:
        # Specify a list of checkpoint times.
        clawdata.checkpt_times = [rupture_rise_time]

    elif clawdata.checkpt_style == 3:
        # Checkpoint every checkpt_interval timesteps (on Level 1)
        # and at the final time.
        clawdata.checkpt_interval = 5

    # ---------------
    # AMR parameters:
    # ---------------
    amrdata = rundata.amrdata

    # max number of refinement levels:
    amrdata.amr_levels_max = 6

    # List of refinement ratios at each level (length at least
    # amr_level_max-1)
    amrdata.refinement_ratios_x = [2, 2, 2, 2, 2, 2]
    amrdata.refinement_ratios_y = [2, 2, 2, 2, 2, 2]
    amrdata.refinement_ratios_t = [2, 2, 2, 2, 2, 2]

    # Specify type of each aux variable in amrdata.auxtype.
    # This must be a list of length num_aux, each element of which is one
    # of:
    #   'center',  'capacity', 'xleft', or 'yleft'  (see documentation).
    amrdata.aux_type = ['center', 'center', 'center', 'center', 'center', \
        'center', 'center', 'center', 'center', 'center', 'center', \
        'capacity','yleft']

    # Flag for refinement based on Richardson error estimater:
    amrdata.flag_richardson = False  # use Richardson?
    amrdata.flag_richardson_tol = 1.  # Richardson tolerance

    # Flag for refinement using routine flag2refine:
    amrdata.flag2refine = True  # use this?
    amrdata.flag2refine_tol = 0.0001  # tolerance used in this routine
    # User can modify flag2refine to change the criterion for flagging.
    # Default: check maximum absolute difference of first component of q
    # between a cell and each of its neighbors.

    # steps to take on each level L between regriddings of level L+1:
    amrdata.regrid_interval = 2

    # width of buffer zone around flagged points:
    # (typically the same as regrid_interval so waves don't escape):
    amrdata.regrid_buffer_width = 2

    # clustering alg. cutoff for (# flagged pts) / (total # of cells
    # refined)
    # (closer to 1.0 => more small grids may be needed to cover flagged
    # cells)
    amrdata.clustering_cutoff = 0.7

    # print info about each regridding up to this level:
    amrdata.verbosity_regrid = 0

    # ---------------
    # Regions:
    # ---------------
    regions = rundata.regiondata.regions
    # to specify regions of refinement append lines of the form
    #  [minlevel,maxlevel,t1,t2,x1,x2,y1,y2]
    ybuffer = dy

    # high-resolution region to surround the fault during slip
    regions.append([
        amrdata.amr_levels_max, amrdata.amr_levels_max, 0, rupture_rise_time,
        fault_center - 0.5 * fault_width, fault_center + 0.5 * fault_width,
        -fault_depth - dx, -fault_depth + dx
    ])

    for j in range(amrdata.amr_levels_max - 1):
        regions.append([
            1, amrdata.amr_levels_max - j, 0, 1e9, -1e9, 1e9,
            -2.0 * fault_depth - j * ybuffer, 0.0
        ])

    regions.append([1, 1, 0, 1e9, -1.e9, 1.e9, -1.e9, 0.0])
    #  ----- For developers -----
    # Toggle debugging print statements:
    amrdata.dprint = False  # print domain flags
    amrdata.eprint = False  # print err est flags
    amrdata.edebug = False  # even more err est flags
    amrdata.gprint = False  # grid bisection/clustering
    amrdata.nprint = False  # proper nesting output
    amrdata.pprint = False  # proj. of tagged points
    amrdata.rprint = False  # print regridding summary
    amrdata.sprint = False  # space/memory output
    amrdata.tprint = False  # time step reporting each level
    amrdata.uprint = False  # update/upbnd reporting

    return rundata
Example #4
0
def setplot(plotdata):
    #--------------------------
    """
    Specify what is to be plotted at each frame.
    Input:  plotdata, an instance of clawpack.visclaw.data.ClawPlotData.
    Output: a modified version of plotdata.

    """
    slice_number = 1  # set to surface slice number
    tmpdir = os.path.abspath(os.curdir)
    os.chdir(plotdata.outdir)
    for filename in os.listdir('.'):
        if (filename.startswith('slice_%d' % slice_number)):
            shutil.copyfile(
                filename, filename.replace('slice_%d' % slice_number, 'fort',
                                           1))

    fault = dtopotools.Fault()
    fault.read('fault.data')

    os.chdir(tmpdir)

    from clawpack.visclaw import colormaps

    xc = np.linspace(-150e3, 200e3, 350)
    yc = np.linspace(-87.5e3, 87.5e3, 175)
    fault.create_dtopography(xc / LAT2METER, yc / LAT2METER, [1.0])
    Xc, Yc = np.meshgrid(xc * length_scale, yc * length_scale)

    okada_max = np.max(fault.dtopo.dZ[0, :, :])
    clevels = np.linspace(-okada_max, okada_max, 10)

    plotdata.clearfigures()  # clear any old figures,axes,items data

    #plotdata.format = 'binary'

    def mapc2p(xc, yc):
        return xc * length_scale, yc * length_scale

    def plot_okada_contour(current_data):
        from pylab import contour, ylabel, tick_params

        contour(Xc,
                Yc,
                fault.dtopo.dZ[0, :, :],
                levels=clevels,
                colors='r',
                linewidths=2)
        tick_params(labelsize=25)
        ylabel('kilometers', fontsize=25)

    # Figure for vertical displacement
    plotfigure = plotdata.new_plotfigure(name='surface', figno=1)
    plotfigure.kwargs = {'figsize': (11, 6)}

    # Set axes for numerical solution:
    plotaxes = plotfigure.new_plotaxes()
    plotaxes.xlimits = xlimits
    plotaxes.ylimits = ylimits
    plotaxes.title = ''
    plotaxes.title_with_t = False
    plotaxes.scaled = True
    plotaxes.afteraxes = plot_okada_contour

    # Set up for item on these axes:
    plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor')
    plotitem.plot_var = 9
    plotitem.pcolor_cmap = 'BrBG'
    plotitem.pcolor_cmin = clevels[0]
    plotitem.pcolor_cmax = clevels[-1]
    plotitem.add_colorbar = False
    plotitem.amr_celledges_show = [0]
    plotitem.amr_patchedges_show = [0]
    plotitem.MappedGrid = True
    plotitem.mapc2p = mapc2p

    # Set up for item on these axes:
    plotitem = plotaxes.new_plotitem(plot_type='2d_contour')
    plotitem.plot_var = 9
    plotitem.contour_colors = 'k'
    plotitem.contour_levels = clevels
    plotitem.kwargs = {'linewidths': 3}
    plotitem.amr_contour_show = [0, 0, 0, 1]
    plotitem.amr_celledges_show = [0]
    plotitem.amr_patchedges_show = [0]
    plotitem.MappedGrid = True
    plotitem.mapc2p = mapc2p

    # Parameters used only when creating html and/or latex hardcopy
    # e.g., via clawpack.visclaw.frametools.printframes:

    plotdata.printfigs = True  # print figures
    plotdata.print_format = 'png'  # file format
    plotdata.print_framenos = 'all'  # list of frames to print
    plotdata.print_fignos = 'all'  # list of figures to print
    plotdata.html = True  # create html files of plots?
    plotdata.html_homelink = '../README.html'  # pointer for top of index
    plotdata.latex = True  # create latex file of plots?
    plotdata.latex_figsperline = 2  # layout of plots
    plotdata.latex_framesperline = 1  # layout of plots
    plotdata.latex_makepdf = False  # also run pdflatex?
    #    plotdata.parallel = True

    return plotdata
import dtopotools_horiz_okada_and_1d as dtopotools
from numpy import arange,cos,sin,pi
reload(dtopotools)
from clawpack.geoclaw.data import LAT2METER

fault = dtopotools.Fault(coordinate_specification='top center')
fault.subfaults = []

width = 50000.0
length = 25000.0
theta = 0.2

fault_centroid = [25e3,0.0,-20e3]
fault_top_center = [fault_centroid[0] - cos(theta)*0.5*width,
                    0.0,
                    fault_centroid[2] + sin(theta)*0.5*width]

slip = 1.0
mu = 3e10
rupture_time = 0.0
rise_time = 1.0
nsubfaults_dip = 1
nsubfaults_strike = 1

longitude0 = fault_top_center[0]/LAT2METER
latitude0 = fault_top_center[1]/LAT2METER
dlongitude = width*cos(theta)/LAT2METER / nsubfaults_dip
dlatitude = length/LAT2METER / nsubfaults_strike
ddepth = width*sin(theta) / nsubfaults_dip
subfault_width = width/nsubfaults_dip
subfault_length = length/nsubfaults_strike
Example #6
0
def setplot(plotdata):
#--------------------------

    """
    Specify what is to be plotted at each frame.
    Input:  plotdata, an instance of clawpack.visclaw.data.ClawPlotData.
    Output: a modified version of plotdata.

    """

    fault = dtopotools.Fault()
    fault.read(plotdata.outdir + '/fault.data')

    mapping = Mapping(fault)

    xp1 = mapping.xp1*length_scale
    xp2 = mapping.xp2*length_scale
    yp1 = mapping.yp1*length_scale
    yp2 = mapping.yp2*length_scale

    gaugedata = ClawData()
    gaugedata.read(plotdata.outdir + '/gauges.data', force=True)
    ngauges = gaugedata.ngauges
    xc = np.zeros(ngauges)
    for j in range(ngauges):
        g = plotdata.getgauge(j)
        xc[j] = g.location[0]
    fault.create_dtopography(xc/LAT2METER,np.array([0.]),[1.0],y_disp=True)


    from clawpack.visclaw import colormaps

    plotdata.clearfigures()  # clear any old figures,axes,items data
    plotdata.format = 'binary'

    def mapc2p(xc,yc):
        xp,yp = mapping.mapc2p(xc,yc)
        return xp*length_scale,yp*length_scale

    def plot_fault(current_data):
        from pylab import linspace, plot, xlabel, ylabel, tick_params
        xl = linspace(xp1,xp2,100)
        yl = linspace(yp1,yp2,100)
        plot(xl,yl,'k',linewidth=3)
        tick_params(labelsize=25)
        xlabel('kilometers',fontsize=25)
        ylabel('kilometers',fontsize=25)

    def sigmatr(current_data):
        # return -trace(sigma)
        q = current_data.q
        return -(q[0,:,:] + q[1,:,:])

    def plot_vertical_displacement(current_data):
        from pylab import plot,zeros,ylabel,tick_params
        t = current_data.t

        ys = zeros(ngauges)
        for gaugeno in range(ngauges):
            g = plotdata.getgauge(gaugeno)
            for k in range(1,len(g.t)):
                if g.t[k] > t:
                    break
                dt = g.t[k] - g.t[k-1]
                v = 0.5*(g.q[4,k]+g.q[4,k-1])
                ys[gaugeno] += dt*v
        plot(xc[:ngauges]*length_scale,ys,linewidth=3)
        plot(xc*length_scale,fault.dtopo.dZ[0,0,:],linestyle='--',color='r',linewidth=3)
        tick_params(labelsize=25)
        ylabel('meters',fontsize=25)

    # Figure for surface
    plotfigure = plotdata.new_plotfigure(name='surface', figno=1)
    plotfigure.kwargs = {'figsize':(11,4)}

    # Set up for axes in this figure:
    plotaxes = plotfigure.new_plotaxes()
    plotaxes.xlimits = xlimits
    plotaxes.ylimits = ylimits_surface
    plotaxes.title_with_t = False
    plotaxes.title = ''
    plotaxes.scaled = False
    plotaxes.afteraxes = plot_vertical_displacement

    # Figure for fault
    plotfigure = plotdata.new_plotfigure(name='fault', figno=2)
    plotfigure.kwargs = {'figsize':(11,6)}

    # Set up for axes in this figure:
    plotaxes = plotfigure.new_plotaxes()
    plotaxes.xlimits = xlimits
    plotaxes.ylimits = ylimits_fault
    plotaxes.title = ''
    plotaxes.title_with_t = False
    plotaxes.scaled = True
    plotaxes.afteraxes = plot_fault

    # Set up for item on these axes:
    plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor')
    plotitem.plot_var = sigmatr
    plotitem.pcolor_cmap = colormaps.blue_white_red
    plotitem.pcolor_cmin = -1e6
    plotitem.pcolor_cmax = 1e6
    plotitem.add_colorbar = False
    plotitem.amr_celledges_show = [0]
    plotitem.amr_patchedges_show = [0]
    plotitem.MappedGrid = True
    plotitem.mapc2p = mapc2p

    # Parameters used only when creating html and/or latex hardcopy
    # e.g., via clawpack.visclaw.frametools.printframes:

    plotdata.printfigs = True                # print figures
    plotdata.print_format = 'png'            # file format
    plotdata.print_framenos = 'all'          # list of frames to print
    plotdata.print_fignos = 'all'            # list of figures to print
    plotdata.html = True                     # create html files of plots?
    plotdata.html_homelink = '../README.html'   # pointer for top of index
    plotdata.latex = True                    # create latex file of plots?
    plotdata.latex_figsperline = 2           # layout of plots
    plotdata.latex_framesperline = 1         # layout of plots
    plotdata.latex_makepdf = False           # also run pdflatex?
    plotdata.parallel = True

    return plotdata
def setplot(plotdata):
    #--------------------------
    """
    Specify what is to be plotted at each frame.
    Input:  plotdata, an instance of clawpack.visclaw.data.ClawPlotData.
    Output: a modified version of plotdata.

    """

    fault = dtopotools.Fault()
    fault.read(plotdata.outdir + '/fault.data')
    gdata = ClawData()
    gdata.read(plotdata.outdir + '/gauges.data', force=True)
    ngauges = gdata.ngauges
    xc = np.zeros(ngauges)
    for j in range(ngauges):
        g = plotdata.getgauge(j)
        xc[j] = g.location[0]

    fault.create_dtopography(xc / LAT2METER,
                             np.array([0.]), [1.0],
                             y_disp=True)

    from clawpack.visclaw import colormaps

    plotdata.clearfigures()  # clear any old figures,axes,items data
    plotdata.format = 'binary'

    def plot_vertical_displacement(current_data):
        from pylab import plot, zeros, xlabel, ylabel, tick_params
        t = current_data.t

        ys = zeros(ngauges)
        for gaugeno in range(ngauges):
            g = plotdata.getgauge(gaugeno)
            for k in range(1, len(g.t)):
                if g.t[k] > t:
                    break
                dt = g.t[k] - g.t[k - 1]
                v = 0.5 * (g.q[4, k] + g.q[4, k - 1])
                ys[gaugeno] += dt * v
        plot(xc[:ngauges] * length_scale, ys, linewidth=3)
        plot(xc * length_scale,
             fault.dtopo.dZ[0, 0, :],
             linestyle='--',
             color='r',
             linewidth=3)
        tick_params(labelsize=25)
        xlabel('kilometers', fontsize=25)
        ylabel('meters', fontsize=25)

    def plot_horizontal_displacement(current_data):
        from pylab import plot, zeros, xlabel, ylabel, tick_params
        t = current_data.t

        xs = zeros(ngauges)
        for gaugeno in range(ngauges):
            g = plotdata.getgauge(gaugeno)
            for k in range(1, len(g.t)):
                if g.t[k] > t:
                    break
                dt = g.t[k] - g.t[k - 1]
                u = 0.5 * (g.q[3, k] + g.q[3, k - 1])
                xs[gaugeno] += dt * u

        plot(xc[:ngauges] * length_scale, xs, linewidth=3)
        plot(xc * length_scale,
             fault.dtopo.dY[0, 0, :],
             linestyle='--',
             color='r',
             linewidth=3)
        tick_params(labelsize=25)
        xlabel('kilometers', fontsize=25)
        ylabel('meters', fontsize=25)

    # Figure for vertical displacement
    plotfigure = plotdata.new_plotfigure(name='vertical', figno=1)
    plotfigure.kwargs = {'figsize': (11, 8)}

    # Set up for axes in this figure:
    plotaxes = plotfigure.new_plotaxes()
    plotaxes.xlimits = xlimits
    plotaxes.ylimits = ylimits
    plotaxes.title_with_t = False
    plotaxes.title = ''
    plotaxes.scaled = False
    plotaxes.afteraxes = plot_vertical_displacement

    # Figure for horizontal displacement
    plotfigure = plotdata.new_plotfigure(name='horizontal', figno=2)
    plotfigure.kwargs = {'figsize': (11, 8)}

    # Set up for axes in this figure:
    plotaxes = plotfigure.new_plotaxes()
    plotaxes.xlimits = xlimits
    plotaxes.ylimits = ylimits
    plotaxes.title_with_t = False
    plotaxes.title = ''
    plotaxes.scaled = False
    plotaxes.afteraxes = plot_horizontal_displacement

    # Parameters used only when creating html and/or latex hardcopy
    # e.g., via clawpack.visclaw.frametools.printframes:

    plotdata.printfigs = True  # print figures
    plotdata.print_format = 'png'  # file format
    plotdata.print_framenos = 'all'  # list of frames to print
    plotdata.print_fignos = 'all'  # list of figures to print
    plotdata.html = True  # create html files of plots?
    plotdata.html_homelink = '../README.html'  # pointer for top of index
    plotdata.latex = True  # create latex file of plots?
    plotdata.latex_figsperline = 2  # layout of plots
    plotdata.latex_framesperline = 1  # layout of plots
    plotdata.latex_makepdf = False  # also run pdflatex?
    plotdata.parallel = True

    return plotdata