def main_plates(sdat):
<EOL>ilast = sdat.rprof.index.levels[<NUM_LIT:0>][-<NUM_LIT:1>]<EOL>rlast = sdat.rprof.loc[ilast]<EOL>nprof = <NUM_LIT:0><EOL>uprof_averaged = rlast.loc[:, '<STR_LIT>'] * <NUM_LIT:0><EOL>for step in sdat.walk.filter(rprof=True):<EOL><INDENT>uprof_averaged += step.rprof['<STR_LIT>']<EOL>nprof += <NUM_LIT:1><EOL><DEDENT>uprof_averaged /= nprof<EOL>radius = rlast['<STR_LIT:r>'].values<EOL>if sdat.par['<STR_LIT>']['<STR_LIT>']:<EOL><INDENT>dsa = sdat.par['<STR_LIT>']['<STR_LIT>']<EOL>isurf = np.argmin(abs(radius - radius[-<NUM_LIT:1>] + dsa))<EOL>vrms_surface = uprof_averaged.iloc[isurf]<EOL>isurf = np.argmin(abs((<NUM_LIT:1> - dsa) - radius))<EOL>isurf -= <NUM_LIT:4>  <EOL><DEDENT>else:<EOL><INDENT>isurf = -<NUM_LIT:1><EOL>vrms_surface = uprof_averaged.iloc[isurf]<EOL><DEDENT>with misc.InchoateFiles(<NUM_LIT:8>, '<STR_LIT>') as fids:<EOL><INDENT>fids.fnames = ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']<EOL>fids[<NUM_LIT:0>].write('<STR_LIT>')<EOL>fids[<NUM_LIT:1>].write('<STR_LIT>'<EOL>'<STR_LIT>')<EOL>istart, iend = None, None<EOL>for step in sdat.walk.filter(fields=['<STR_LIT:T>']):<EOL><INDENT>timestep = step.isnap<EOL>istart = timestep if istart is None else istart<EOL>iend = timestep<EOL>print('<STR_LIT>', timestep)<EOL>rcmb = step.geom.rcmb<EOL>fname = sdat.filename('<STR_LIT>', timestep=timestep, suffix='<STR_LIT>')<EOL>topo = np.genfromtxt(str(fname))<EOL>if sdat.par['<STR_LIT>']['<STR_LIT>']:<EOL><INDENT>topo[:, <NUM_LIT:1>] = topo[:, <NUM_LIT:1>] / (<NUM_LIT:1.> - dsa)<EOL><DEDENT>time = step.geom.ti_ad * vrms_surface *conf.scaling.ttransit / conf.scaling.yearins / <NUM_LIT><EOL>trenches, ridges, agetrenches, _, _ =detect_plates(step, vrms_surface, fids, time)<EOL>plot_plates(step, time, vrms_surface, trenches, ridges,<EOL>agetrenches, topo, fids)<EOL>concfld = step.fields['<STR_LIT:c>'][<NUM_LIT:0>, :, :, <NUM_LIT:0>]<EOL>continentsfld = np.ma.masked_where(<EOL>concfld < <NUM_LIT:3>, concfld)  <EOL>continentsfld = continentsfld / continentsfld<EOL>temp = step.fields['<STR_LIT:T>'][<NUM_LIT:0>, :, :, <NUM_LIT:0>]<EOL>tgrad = (temp[:, isurf - <NUM_LIT:1>] - temp[:, isurf]) /(step.geom.r_coord[isurf] - step.geom.r_coord[isurf - <NUM_LIT:1>])<EOL>io_surface(timestep, time, fids[<NUM_LIT:2>], concfld[:-<NUM_LIT:1>, isurf])<EOL>io_surface(timestep, time, fids[<NUM_LIT:3>], tgrad)<EOL>io_surface(timestep, time, fids[<NUM_LIT:4>], topo[:, <NUM_LIT:1>])<EOL>if '<STR_LIT>' in conf.plates.plot:<EOL><INDENT>io_surface(timestep, time, fids[<NUM_LIT:5>],<EOL>step.fields['<STR_LIT>'][<NUM_LIT:0>, :, isurf, <NUM_LIT:0>])<EOL><DEDENT>etamin, _ = sdat.scale(<NUM_LIT>, '<STR_LIT>')<EOL>etamax, _ = sdat.scale(sdat.par['<STR_LIT>']['<STR_LIT>'], '<STR_LIT>')<EOL>fig, axis, _, _ = field.plot_scalar(step, '<STR_LIT>',<EOL>vmin=etamin, vmax=etamax)<EOL>field.plot_scalar(step, '<STR_LIT:c>', continentsfld, axis, False,<EOL>cmap='<STR_LIT>', vmin=<NUM_LIT:0>, vmax=<NUM_LIT:0>)<EOL>cmap2 = plt.cm.ocean<EOL>cmap2.set_over('<STR_LIT:m>')<EOL>field.plot_vec(axis, step, '<STR_LIT:v>')<EOL>axis.text(<NUM_LIT:1.>, <NUM_LIT>, str(round(time, <NUM_LIT:0>)) + '<STR_LIT>',<EOL>transform=axis.transAxes)<EOL>axis.text(<NUM_LIT:1.>, <NUM_LIT:0.1>, str(timestep),<EOL>transform=axis.transAxes)<EOL>plot_plate_limits_field(axis, rcmb, ridges, trenches)<EOL>misc.saveplot(fig, '<STR_LIT>', timestep, close=False)<EOL>if conf.plates.zoom is not None:<EOL><INDENT>if not <NUM_LIT:0> <= conf.plates.zoom <= <NUM_LIT>:<EOL><INDENT>raise error.InvalidZoomError(conf.plates.zoom)<EOL><DEDENT>if <NUM_LIT> < conf.plates.zoom <= <NUM_LIT>:<EOL><INDENT>ladd, radd, uadd, dadd = <NUM_LIT>, <NUM_LIT>, <NUM_LIT>, <NUM_LIT:0.1><EOL><DEDENT>elif <NUM_LIT> < conf.plates.zoom <= <NUM_LIT>:<EOL><INDENT>ladd, radd, uadd, dadd = <NUM_LIT>, <NUM_LIT:0.1>, <NUM_LIT>, <NUM_LIT><EOL><DEDENT>elif <NUM_LIT> < conf.plates.zoom <= <NUM_LIT>:<EOL><INDENT>ladd, radd, uadd, dadd = <NUM_LIT>, <NUM_LIT>, <NUM_LIT:0.1>, <NUM_LIT><EOL><DEDENT>else:  <EOL><INDENT>ladd, radd, uadd, dadd = <NUM_LIT:0.1>, <NUM_LIT>, <NUM_LIT>, <NUM_LIT><EOL><DEDENT>xzoom = (rcmb + <NUM_LIT:1>) * np.cos(np.radians(conf.plates.zoom))<EOL>yzoom = (rcmb + <NUM_LIT:1>) * np.sin(np.radians(conf.plates.zoom))<EOL>axis.set_xlim(xzoom - ladd, xzoom + radd)<EOL>axis.set_ylim(yzoom - dadd, yzoom + uadd)<EOL>misc.saveplot(fig, '<STR_LIT>', timestep, close=False)<EOL><DEDENT>plt.close(fig)<EOL>if '<STR_LIT:str>' in conf.plates.plot:<EOL><INDENT>fig, axis, _, _ = field.plot_scalar(step, '<STR_LIT>',<EOL>vmin=<NUM_LIT:0>, vmax=<NUM_LIT>)<EOL>axis.text(<NUM_LIT:1.>, <NUM_LIT>, str(round(time, <NUM_LIT:0>)) + '<STR_LIT>',<EOL>transform=axis.transAxes)<EOL>axis.text(<NUM_LIT:1.>, <NUM_LIT:0.1>, str(timestep),<EOL>transform=axis.transAxes)<EOL>plot_plate_limits_field(axis, rcmb, ridges, trenches)<EOL>misc.saveplot(fig, '<STR_LIT:s>', timestep, close=False)<EOL>if conf.plates.zoom is not None:<EOL><INDENT>axis.set_xlim(xzoom - ladd, xzoom + radd)<EOL>axis.set_ylim(yzoom - dadd, yzoom + uadd)<EOL>misc.saveplot(fig, '<STR_LIT>', timestep, close=False)<EOL><DEDENT>plt.close(fig)<EOL>lithospheric_stress(step, trenches, ridges, time)<EOL><DEDENT>if '<STR_LIT>' in conf.plates.plot:<EOL><INDENT>fig, axis, _, _ = field.plot_scalar(step, '<STR_LIT>',<EOL>alpha=<NUM_LIT:0.1>)<EOL>field.plot_scalar(step, '<STR_LIT:c>', continentsfld, axis, False,<EOL>cmap='<STR_LIT>', vmin=<NUM_LIT:0>, vmax=<NUM_LIT:0>)<EOL>cmap2 = plt.cm.ocean<EOL>cmap2.set_over('<STR_LIT:m>')<EOL>field.plot_vec(axis, step, '<STR_LIT>')<EOL>axis.text(<NUM_LIT:1.>, <NUM_LIT>, str(round(time, <NUM_LIT:0>)) + '<STR_LIT>',<EOL>transform=axis.transAxes)<EOL>axis.text(<NUM_LIT:1.>, <NUM_LIT:0.1>, str(timestep),<EOL>transform=axis.transAxes)<EOL>plot_plate_limits_field(axis, rcmb, ridges, trenches)<EOL>misc.saveplot(fig, '<STR_LIT>', timestep)<EOL><DEDENT><DEDENT>ptn = misc.out_name('<STR_LIT>')<EOL>stem = ptn.format(fids.fnames[<NUM_LIT:0>], istart, iend)<EOL>idx = <NUM_LIT:0><EOL>fmt = '<STR_LIT>'<EOL>while pathlib.Path(fmt.format(stem, idx)).is_file():<EOL><INDENT>fmt = '<STR_LIT>'<EOL>idx += <NUM_LIT:1><EOL><DEDENT>fids.fnames = [fmt.format(ptn.format(fname, istart, iend), idx)<EOL>for fname in fids.fnames]<EOL><DEDENT>
Plot several plates information.