def plot_plates(step, time, vrms_surface, trench, ridge, agetrench,<EOL>topo, fids):
vphi = step.fields['<STR_LIT>'][<NUM_LIT:0>, :, :, <NUM_LIT:0>]<EOL>tempfld = step.fields['<STR_LIT:T>'][<NUM_LIT:0>, :, :, <NUM_LIT:0>]<EOL>concfld = step.fields['<STR_LIT:c>'][<NUM_LIT:0>, :, :, <NUM_LIT:0>]<EOL>timestep = step.isnap<EOL>if step.sdat.par['<STR_LIT>']['<STR_LIT>']:<EOL><INDENT>dsa = step.sdat.par['<STR_LIT>']['<STR_LIT>']<EOL>indsurf = np.argmin(abs((<NUM_LIT:1> - dsa) - step.geom.r_coord)) - <NUM_LIT:4><EOL>indcont = np.argmin(abs((<NUM_LIT:1> - dsa) - np.array(step.geom.r_coord))) - <NUM_LIT:10><EOL><DEDENT>else:<EOL><INDENT>indsurf = -<NUM_LIT:1><EOL>indcont = -<NUM_LIT:1>  <EOL><DEDENT>if step.sdat.par['<STR_LIT>']['<STR_LIT>'] andnot step.sdat.par['<STR_LIT>']['<STR_LIT>']:<EOL><INDENT>continents = np.ma.masked_where(<EOL>np.logical_or(concfld[:-<NUM_LIT:1>, indcont] < <NUM_LIT:3>,<EOL>concfld[:-<NUM_LIT:1>, indcont] > <NUM_LIT:4>),<EOL>concfld[:-<NUM_LIT:1>, indcont])<EOL><DEDENT>elif (step.sdat.par['<STR_LIT>']['<STR_LIT>'] and<EOL>step.sdat.par['<STR_LIT>']['<STR_LIT>']):<EOL><INDENT>continents = np.ma.masked_where(<EOL>np.logical_or(concfld[:-<NUM_LIT:1>, indcont] < <NUM_LIT:3>,<EOL>concfld[:-<NUM_LIT:1>, indcont] > <NUM_LIT:5>),<EOL>concfld[:-<NUM_LIT:1>, indcont])<EOL><DEDENT>elif step.sdat.par['<STR_LIT>']['<STR_LIT>']:<EOL><INDENT>continents = np.ma.masked_where(<EOL>concfld[:-<NUM_LIT:1>, indcont] < <NUM_LIT:3>, concfld[:-<NUM_LIT:1>, indcont])<EOL><DEDENT>else:<EOL><INDENT>continents = np.ma.masked_where(<EOL>concfld[:-<NUM_LIT:1>, indcont] < <NUM_LIT:2>, concfld[:-<NUM_LIT:1>, indcont])<EOL><DEDENT>continentsall = continents / continents<EOL>ph_coord = step.geom.p_coord<EOL>vph2 = <NUM_LIT:0.5> * (vphi + np.roll(vphi, <NUM_LIT:1>, <NUM_LIT:0>))  <EOL>dvph2 = (np.diff(vph2[:, indsurf]) / (ph_coord[<NUM_LIT:0>] * <NUM_LIT>))<EOL>fig0, (ax1, ax2, ax3) = plt.subplots(<NUM_LIT:3>, <NUM_LIT:1>, sharex=True, figsize=(<NUM_LIT:12>, <NUM_LIT:8>))<EOL>ax1.plot(ph_coord[:-<NUM_LIT:1>], concfld[:-<NUM_LIT:1>, indsurf], color='<STR_LIT:g>', label='<STR_LIT>')<EOL>ax2.plot(ph_coord[:-<NUM_LIT:1>], tempfld[:-<NUM_LIT:1>, indsurf], color='<STR_LIT:k>', label='<STR_LIT>')<EOL>ax3.plot(ph_coord[:-<NUM_LIT:1>], vph2[:-<NUM_LIT:1>, indsurf], label='<STR_LIT>')<EOL>ax1.fill_between(<EOL>ph_coord[:-<NUM_LIT:1>], continents, <NUM_LIT:1.>, facecolor='<STR_LIT>', alpha=<NUM_LIT>)<EOL>ax2.fill_between(<EOL>ph_coord[:-<NUM_LIT:1>], continentsall, <NUM_LIT:0.>, facecolor='<STR_LIT>', alpha=<NUM_LIT>)<EOL>tempmin = step.sdat.par['<STR_LIT>']['<STR_LIT>'] * <NUM_LIT>if step.sdat.par['<STR_LIT>']['<STR_LIT>'] == '<STR_LIT>' else <NUM_LIT:0.0><EOL>tempmax = step.sdat.par['<STR_LIT>']['<STR_LIT>'] * <NUM_LIT>if step.sdat.par['<STR_LIT>']['<STR_LIT>'] == '<STR_LIT>' else <NUM_LIT><EOL>ax2.set_ylim(tempmin, tempmax)<EOL>ax3.fill_between(<EOL>ph_coord[:-<NUM_LIT:1>], continentsall * round(<NUM_LIT> * np.amax(dvph2), <NUM_LIT:1>),<EOL>round(np.amin(dvph2) * <NUM_LIT>, <NUM_LIT:1>), facecolor='<STR_LIT>', alpha=<NUM_LIT>)<EOL>ax3.set_ylim(conf.plates.vmin, conf.plates.vmax)<EOL>ax1.set_ylabel("<STR_LIT>")<EOL>ax2.set_ylabel("<STR_LIT>")<EOL>ax3.set_ylabel("<STR_LIT>")<EOL>ax1.set_title(timestep)<EOL>ax1.text(<NUM_LIT>, <NUM_LIT>, str(round(time, <NUM_LIT:0>)) + '<STR_LIT>',<EOL>transform=ax1.transAxes)<EOL>ax1.text(<NUM_LIT>, <NUM_LIT>, str(round(step.geom.ti_ad, <NUM_LIT:8>)),<EOL>transform=ax1.transAxes)<EOL>plot_plate_limits(ax3, ridge, trench, conf.plates.vmin,<EOL>conf.plates.vmax)<EOL>misc.saveplot(fig0, '<STR_LIT>', timestep)<EOL>fig0, (ax1, ax2) = plt.subplots(<NUM_LIT:2>, <NUM_LIT:1>, sharex=True, figsize=(<NUM_LIT:12>, <NUM_LIT:8>))<EOL>ax1.plot(ph_coord[:-<NUM_LIT:1>], vph2[:-<NUM_LIT:1>, indsurf], label='<STR_LIT>')<EOL>ax1.axhline(y=<NUM_LIT:0>, xmin=<NUM_LIT:0>, xmax=<NUM_LIT:2> * np.pi,<EOL>color='<STR_LIT>', ls='<STR_LIT>', alpha=<NUM_LIT>)<EOL>ax1.set_ylabel("<STR_LIT>")<EOL>ax1.text(<NUM_LIT>, <NUM_LIT>, str(round(time, <NUM_LIT:0>)) + '<STR_LIT>',<EOL>transform=ax1.transAxes)<EOL>ax1.text(<NUM_LIT>, <NUM_LIT>, str(round(step.geom.ti_ad, <NUM_LIT:8>)),<EOL>transform=ax1.transAxes)<EOL>ax2.plot(ph_coord[:-<NUM_LIT:1>] + ph_coord[<NUM_LIT:0>], dvph2, color='<STR_LIT:k>', label='<STR_LIT>')<EOL>ax2.set_ylabel("<STR_LIT>")<EOL>plot_plate_limits(ax1, ridge, trench, conf.plates.vmin,<EOL>conf.plates.vmax)<EOL>plot_plate_limits(ax2, ridge, trench, conf.plates.dvmin,<EOL>conf.plates.dvmax)<EOL>ax1.set_xlim(<NUM_LIT:0>, <NUM_LIT:2> * np.pi)<EOL>ax1.set_title(timestep)<EOL>ax1.fill_between(<EOL>ph_coord[:-<NUM_LIT:1>], continentsall * conf.plates.vmin, conf.plates.vmax,<EOL>facecolor='<STR_LIT>', alpha=<NUM_LIT>)<EOL>ax1.set_ylim(conf.plates.vmin, conf.plates.vmax)<EOL>ax2.fill_between(<EOL>ph_coord[:-<NUM_LIT:1>], continentsall * conf.plates.dvmin,<EOL>conf.plates.dvmax, facecolor='<STR_LIT>', alpha=<NUM_LIT>)<EOL>ax2.set_ylim(conf.plates.dvmin, conf.plates.dvmax)<EOL>misc.saveplot(fig0, '<STR_LIT>', timestep)<EOL>if '<STR_LIT:str>' in conf.plates.plot:<EOL><INDENT>stressfld = step.fields['<STR_LIT>'][<NUM_LIT:0>, :, :, <NUM_LIT:0>]<EOL>fig0, (ax1, ax2) = plt.subplots(<NUM_LIT:2>, <NUM_LIT:1>, sharex=True, figsize=(<NUM_LIT:12>, <NUM_LIT:8>))<EOL>ax1.plot(ph_coord[:-<NUM_LIT:1>], vph2[:-<NUM_LIT:1>, indsurf], label='<STR_LIT>')<EOL>ax1.axhline(y=<NUM_LIT:0>, xmin=<NUM_LIT:0>, xmax=<NUM_LIT:2> * np.pi,<EOL>color='<STR_LIT>', ls='<STR_LIT>', alpha=<NUM_LIT>)<EOL>ax1.set_ylabel("<STR_LIT>")<EOL>ax1.text(<NUM_LIT>, <NUM_LIT>, str(round(time, <NUM_LIT:0>)) + '<STR_LIT>',<EOL>transform=ax1.transAxes)<EOL>ax1.text(<NUM_LIT>, <NUM_LIT>, str(round(step.geom.ti_ad, <NUM_LIT:8>)),<EOL>transform=ax1.transAxes)<EOL>ax2.plot(ph_coord[:-<NUM_LIT:1>],<EOL>stressfld[:-<NUM_LIT:1>, indsurf] * step.sdat.scales.stress / <NUM_LIT>,<EOL>color='<STR_LIT:k>', label='<STR_LIT>')<EOL>ax2.set_ylim(conf.plates.stressmin, conf.plates.stressmax)<EOL>ax2.set_ylabel("<STR_LIT>")<EOL>plot_plate_limits(ax1, ridge, trench,<EOL>conf.plates.vmin, conf.plates.vmax)<EOL>plot_plate_limits(ax2, ridge, trench,<EOL>conf.plates.stressmin, conf.plates.stressmax)<EOL>ax1.set_xlim(<NUM_LIT:0>, <NUM_LIT:2> * np.pi)<EOL>ax1.set_title(timestep)<EOL>ax1.fill_between(<EOL>ph_coord[:-<NUM_LIT:1>], continentsall * conf.plates.vmin,<EOL>conf.plates.vmax, facecolor='<STR_LIT>', alpha=<NUM_LIT>)<EOL>ax1.set_ylim(conf.plates.vmin, conf.plates.vmax)<EOL>ax2.fill_between(<EOL>ph_coord[:-<NUM_LIT:1>], continentsall * conf.plates.dvmin,<EOL>conf.plates.dvmax,<EOL>facecolor='<STR_LIT>', alpha=<NUM_LIT>)<EOL>misc.saveplot(fig0, '<STR_LIT>', timestep)<EOL><DEDENT>fig1, (ax1, ax2) = plt.subplots(<NUM_LIT:2>, <NUM_LIT:1>, sharex=True, figsize=(<NUM_LIT:12>, <NUM_LIT:8>))<EOL>ax1.plot(ph_coord[:-<NUM_LIT:1>], vph2[:-<NUM_LIT:1>, indsurf], label='<STR_LIT>')<EOL>ax1.axhline(y=<NUM_LIT:0>, xmin=<NUM_LIT:0>, xmax=<NUM_LIT:2> * np.pi,<EOL>color='<STR_LIT>', ls='<STR_LIT>', alpha=<NUM_LIT>)<EOL>ax1.set_ylim(conf.plates.vmin, conf.plates.vmax)<EOL>ax1.set_ylabel("<STR_LIT>")<EOL>ax1.text(<NUM_LIT>, <NUM_LIT>, str(round(time, <NUM_LIT:0>)) + '<STR_LIT>',<EOL>transform=ax1.transAxes)<EOL>plot_plate_limits(ax1, ridge, trench, conf.plates.vmin,<EOL>conf.plates.vmax)<EOL>if '<STR_LIT>' in conf.plates.plot:<EOL><INDENT>agefld = step.fields['<STR_LIT>'][<NUM_LIT:0>, :, :, <NUM_LIT:0>]<EOL>age_surface = np.ma.masked_where(<EOL>agefld[:, indsurf] < <NUM_LIT>, agefld[:, indsurf])<EOL>age_surface_dim = (age_surface * vrms_surface * conf.scaling.ttransit /<EOL>conf.scaling.yearins / <NUM_LIT>)<EOL>fig2, (ax3, ax4) = plt.subplots(<NUM_LIT:2>, <NUM_LIT:1>, sharex=True, figsize=(<NUM_LIT:12>, <NUM_LIT:8>))<EOL>ax3.plot(ph_coord[:-<NUM_LIT:1>], vph2[:-<NUM_LIT:1>, indsurf], label='<STR_LIT>')<EOL>ax3.axhline(<EOL>y=<NUM_LIT:0>, xmin=<NUM_LIT:0>, xmax=<NUM_LIT:2> * np.pi,<EOL>color='<STR_LIT>', ls='<STR_LIT>', alpha=<NUM_LIT>)<EOL>ax3.set_ylim(conf.plates.vmin, conf.plates.vmax)<EOL>ax3.set_ylabel("<STR_LIT>")<EOL>ax3.text(<NUM_LIT>, <NUM_LIT>, str(round(time, <NUM_LIT:0>)) + '<STR_LIT>',<EOL>transform=ax3.transAxes)<EOL>ax3.fill_between(<EOL>ph_coord[:-<NUM_LIT:1>], continentsall * conf.plates.vmax,<EOL>conf.plates.vmin, facecolor='<STR_LIT>', alpha=<NUM_LIT>)<EOL>plot_plate_limits(ax3, ridge, trench,<EOL>conf.plates.vmin, conf.plates.vmax)<EOL><DEDENT>times_subd = []<EOL>age_subd = []<EOL>distance_subd = []<EOL>ph_trench_subd = []<EOL>ph_cont_subd = []<EOL>if step.sdat.par['<STR_LIT>']['<STR_LIT>']:<EOL><INDENT>for i, trench_i in enumerate(trench):<EOL><INDENT>ph_coord_noend = ph_coord[:-<NUM_LIT:1>]<EOL>angdistance1 = abs(ph_coord_noend[continentsall == <NUM_LIT:1>] - trench_i)<EOL>angdistance2 = <NUM_LIT> * np.pi - angdistance1<EOL>angdistance = np.minimum(angdistance1, angdistance2)<EOL>distancecont = min(angdistance)<EOL>argdistancecont = np.argmin(angdistance)<EOL>continentpos = ph_coord_noend[continentsall == <NUM_LIT:1>][argdistancecont]<EOL>ph_trench_subd.append(trench_i)<EOL>age_subd.append(agetrench[i])<EOL>ph_cont_subd.append(continentpos)<EOL>distance_subd.append(distancecont)<EOL>times_subd.append(step.geom.ti_ad)<EOL>if angdistance1[argdistancecont] < angdistance2[argdistancecont]:<EOL><INDENT>if continentpos - trench_i < <NUM_LIT:0>:  <EOL><INDENT>distancecont = - distancecont<EOL><DEDENT>ax1.annotate('<STR_LIT>', xy=(trench_i + distancecont, <NUM_LIT>),<EOL>xycoords='<STR_LIT:data>', xytext=(trench_i, <NUM_LIT>),<EOL>textcoords='<STR_LIT:data>',<EOL>arrowprops=dict(arrowstyle="<STR_LIT>", lw="<STR_LIT:2>",<EOL>shrinkA=<NUM_LIT:0>, shrinkB=<NUM_LIT:0>))<EOL><DEDENT>else:  <EOL><INDENT>xy_anot, xy_text = <NUM_LIT:0>, <NUM_LIT:2> * np.pi<EOL>if continentpos - trench_i < <NUM_LIT:0>:<EOL><INDENT>xy_anot, xy_text = xy_text, xy_anot<EOL><DEDENT>ax1.annotate('<STR_LIT>', xy=(xy_anot, <NUM_LIT>),<EOL>xycoords='<STR_LIT:data>', xytext=(trench_i, <NUM_LIT>),<EOL>textcoords='<STR_LIT:data>',<EOL>arrowprops=dict(arrowstyle="<STR_LIT:->", lw="<STR_LIT:2>",<EOL>shrinkA=<NUM_LIT:0>, shrinkB=<NUM_LIT:0>))<EOL>ax1.annotate('<STR_LIT>', xy=(continentpos, <NUM_LIT>),<EOL>xycoords='<STR_LIT:data>', xytext=(xy_text, <NUM_LIT>),<EOL>textcoords='<STR_LIT:data>',<EOL>arrowprops=dict(arrowstyle="<STR_LIT>", lw="<STR_LIT:2>",<EOL>shrinkA=<NUM_LIT:0>, shrinkB=<NUM_LIT:0>))<EOL><DEDENT><DEDENT><DEDENT>ax1.fill_between(<EOL>ph_coord[:-<NUM_LIT:1>], continentsall * conf.plates.vmin,<EOL>conf.plates.vmax, facecolor='<STR_LIT>', alpha=<NUM_LIT>)<EOL>ax2.set_ylabel("<STR_LIT>")<EOL>ax2.axhline(y=<NUM_LIT:0>, xmin=<NUM_LIT:0>, xmax=<NUM_LIT:2> * np.pi,<EOL>color='<STR_LIT>', ls='<STR_LIT>', alpha=<NUM_LIT>)<EOL>ax2.plot(topo[:, <NUM_LIT:0>],<EOL>topo[:, <NUM_LIT:1>] * step.sdat.scales.length / <NUM_LIT>,<EOL>color='<STR_LIT>')<EOL>ax2.set_xlim(<NUM_LIT:0>, <NUM_LIT:2> * np.pi)<EOL>ax2.set_ylim(conf.plates.topomin, conf.plates.topomax)<EOL>ax2.fill_between(<EOL>ph_coord[:-<NUM_LIT:1>], continentsall * conf.plates.topomax,<EOL>conf.plates.topomin, facecolor='<STR_LIT>', alpha=<NUM_LIT>)<EOL>plot_plate_limits(ax2, ridge, trench, conf.plates.topomin,<EOL>conf.plates.topomax)<EOL>ax1.set_title(timestep)<EOL>misc.saveplot(fig1, '<STR_LIT>', timestep)<EOL>if '<STR_LIT>' in conf.plates.plot:<EOL><INDENT>ax4.set_ylabel("<STR_LIT>")<EOL>ax4.plot(ph_coord[:-<NUM_LIT:1>], age_surface_dim[:-<NUM_LIT:1>], color='<STR_LIT>')<EOL>ax4.set_xlim(<NUM_LIT:0>, <NUM_LIT:2> * np.pi)<EOL>ax4.fill_between(<EOL>ph_coord[:-<NUM_LIT:1>], continentsall * conf.plates.agemax,<EOL>conf.plates.agemin, facecolor='<STR_LIT>', alpha=<NUM_LIT>)<EOL>ax4.set_ylim(conf.plates.agemin, conf.plates.agemax)<EOL>plot_plate_limits(ax4, ridge, trench, conf.plates.agemin,<EOL>conf.plates.agemax)<EOL>ax3.set_title(timestep)<EOL>misc.saveplot(fig2, '<STR_LIT>', timestep)<EOL><DEDENT>for isubd in np.arange(len(distance_subd)):<EOL><INDENT>fids[<NUM_LIT:1>].write("<STR_LIT>" % (<EOL>timestep,<EOL>times_subd[isubd],<EOL>time,<EOL>distance_subd[isubd],<EOL>ph_trench_subd[isubd],<EOL>ph_cont_subd[isubd],<EOL>age_subd[isubd],<EOL>))<EOL><DEDENT>
handle ploting stuff