def get_vtus(fmts, folder='rstf', sync=False): files = [ glob('../stream/' + folder + '/' + fmt + '_????.vtu') for fmt in fmts ] inds = [ np.argsort(np.array([float(fn[-8:-4]) for fn in filel])) for filel in files ] if not sync: print('Returning files:') print([filel[int(ind[-1])] for ind, filel in zip(inds, files)]) vtus = [ fastvtulib.get_structured_vtu(filel[int(ind[-1])]) for ind, filel in zip(inds, files) ] maxtime = None return vtus, maxtime else: def get_times(fmt): times = [] out_file = '../stream/' + folder + '/' + fmt + '.result' with open(out_file) as fout: for line in fout: if line[:4] == 'Time': times.append(float(line.rstrip('\n').split()[-1])) times = np.array(times) return np.unique(times - times[0]) n_jobs = len(fmts) timess = Parallel(n_jobs=n_jobs)(delayed(get_times)(fmt) for fmt in fmts) maxtime = np.min([np.max(times) for times in timess]) inds_times = [ int(np.where(times == maxtime)[0][0]) for times in timess ] vtus = [ fastvtulib.get_structured_vtu(filel[int(ind[ind_t])]) for ind, ind_t, filel in zip(inds, inds_times, files) ] for vtu in vtus: vtu.rawdata_dict['vel'] = np.sqrt( vtu.rawdata_dict['aiflow'][:, 0]**2. + vtu.rawdata_dict['aiflow'][:, 1]**2.) return vtus, maxtime
def vtu_to_φ_and_ε(fn, x, y_pts, obs_angles, E_transmit=np.array([1.0e3, 0]), scatter_aniso=1.0e-1, freq=300.0e6): vtu = fastvtulib.get_structured_vtu(fn) y = np.linspace(np.min(vtu.coords[:, 1]), np.max(vtu.coords[:, 1]), y_pts) x = np.ones((y_pts, )) * x test_p = vtu.get_pts_2d(['fabric 1'], x, y) y_valid = y[~np.isnan(test_p['fabric 1'])] y = np.linspace(np.min(y_valid), np.max(y_valid), y_pts)[::-1] depths = y[0] - y pts = vtu.get_pts_2d( ['fabric 1', 'fabric 2', 'fabric 3', 'fabric 4', 'fabric 5', 'temp'], x, y) A_xy = np.zeros((len(y), 2, 2), dtype=np.complex128) A_xy[:, 0, 0] = pts['fabric 1'] A_xy[:, 1, 1] = 1.0 - pts['fabric 1'] - pts['fabric 2'] A_xy[:, 1, 0] = pts['fabric 5'] A_xy[:, 0, 1] = pts['fabric 5'] φ, ε = fujita_model.φ_and_ε(A_xy, T=pts['temp']) if fn == '../stream/rstf/s_ftw_rc2.0e-3_oop0.0_bm0.0_0001.vtu': with open('deforming_fabric.csv', 'w') as fout: fout.write('depth[m] epsilon_x epsilon_y\n') for i in range(len(depths)): fout.write('{:f} {:f} {:f}\n'.format(depths[i], np.real(ε[i, 0]), np.real(ε[i, 1]))) # Anisotropic scattering S_aniso = np.zeros((y.shape[0], 2, 2)) S_aniso[:, 0, 0] = 1.0e0 S_aniso[:, 1, 1] = scatter_aniso S_aniso = S_aniso * 1.0e-4 return y, fujita_model.fujita_model_εS(E_transmit, depths, obs_angles, ε, S_aniso, φ, freq)
def idealized_init(): # We want to find the filename for the highest index where we have all 3 files = glob('../stream/rstf/deform2e-3_????.vtu') inds = np.argsort(np.array([float(fn[-8:-4]) for fn in files])) files = [files[i] for i in inds] out_file = '../stream/relaxed_stream_tall_fabric/deform_diffuse.result' vtu = fastvtulib.get_structured_vtu(files[-1]) vtu.rawdata_dict['vel'] = np.sqrt(vtu.rawdata_dict['aiflow'][:, 0]**2. + vtu.rawdata_dict['aiflow'][:, 1]**2.) tri = Triangulation( np.array([rc[0] + 100000. for rc in vtu.raw_coords[:, 0]]) / 1000., np.array([rc[1] for rc in vtu.raw_coords[:, 0]]), vtu.simptt) gs = gridspec.GridSpec(2, 3, width_ratios=(1., 1., 1.), height_ratios=(1, 0.1), hspace=0.55, wspace=0.1, left=0.1, bottom=0.2, top=0.9, right=0.98) fig = plt.figure(figsize=(7.5, 3.0)) axes = [fig.add_subplot(gs[0, i]) for i in range(3)] cbr_axes = [fig.add_subplot(gs[1, i]) for i in range(3)] cm1 = axes[0].tricontourf(tri, vtu.rawdata_dict['aiflow'][:, 0], cmap='Reds', levels=np.linspace(0.0, 10., 101), extend='max') levels = [1000, 5000, 10000, 50000, 100000] CS = axes[0].tricontour(tri, vtu.rawdata_dict['age'], colors='k', levels=levels, linewidths=0.5) fmt = {level: '{:d} kyr'.format(level // 1000) for level in levels} axes[0].clabel(CS, CS.levels, inline=True, fmt=fmt, fontsize=8) for c in cm1.collections: c.set_edgecolor("face") # axes[0].set_title('Speed', fontsize=bfs) # axes[1].set_title('Vertical fabric', fontsize=bfs) # axes[2].set_title('Woodcock Parameter', fontsize=bfs) axes[0].set_xlim(0, 175) axes[0].set_xticks([0., 50., 100., 150.]) cm2 = axes[1].tricontourf(tri, vtu.rawdata_dict['fabric 2'], cmap='BrBG', norm=anisolib.fab_norm, levels=np.linspace(0, 1, 101), extend='neither') for c in cm2.collections: c.set_edgecolor("face") axes[1].set_xlim(0, 175) axes[1].set_xticks([0., 50., 100., 150.]) k = woodcock(vtu.rawdata_dict) cm3 = axes[2].tricontourf(tri, k, cmap='PuOr', levels=np.linspace(0, 2, 201), extend='max') for c in cm3.collections: c.set_edgecolor("face") axes[2].set_xlim(0, 175) axes[2].set_xticks([0., 50., 100., 150.]) cbr = plt.colorbar(cm1, cax=cbr_axes[0], orientation='horizontal', ticks=(0, 5., 10.)) cbr.set_label(label=r'$v_x$ (m a$^{-1})$', size=fs) cbr.ax.tick_params(axis='both', which='major', labelsize=fs) cbr = plt.colorbar(cm2, cax=cbr_axes[1], orientation='horizontal', ticks=(0, 1. / 3., 2. / 3., 1.0)) cbr.set_label(label=r'$a^{(2)}_{zz}$', size=fs) cbr.ax.set_xticklabels(['0', r'$\frac{1}{3}$', r'$\frac{2}{3}$', '1']) cbr.ax.tick_params(axis='both', which='major', labelsize=fs) cbr = plt.colorbar(cm3, cax=cbr_axes[2], orientation='horizontal', ticks=(0, 1, 2)) cbr.set_label(label=r'Woodcock $k$', size=fs) cbr.ax.set_xticklabels(['0', '1', '2']) cbr.ax.tick_params(axis='both', which='major', labelsize=fs) axes[0].set_ylabel('Height (m)', fontsize=fs) for ax in axes[1:]: ax.set_yticklabels(['' for tick in ax.get_yticklabels()]) axes[1].set_xlabel('Distance (km)', fontsize=fs) for letter, ax in zip('abc', axes): ax.text(0.05, 0.85, letter, transform=ax.transAxes, fontsize=bfs) ax.tick_params(axis='both', which='major', labelsize=fs) ax.set_ylim(0, 2250) fig.savefig('../plots/idealized_init.png', dpi=300) fig.savefig('../plots/poster_idealized_init.png', dpi=300, transparent=True)
def idealized_init_zoom(): # We want to find the filename for the highest index where we have all 3 files = glob('../stream/rstf/deform2e-5_????.vtu') inds = np.argsort(np.array([float(fn[-8:-4]) for fn in files])) files = [files[i] for i in inds] vtu = fastvtulib.get_structured_vtu(files[-1]) vtu.rawdata_dict['vel'] = np.sqrt(vtu.rawdata_dict['aiflow'][:, 0]**2. + vtu.rawdata_dict['aiflow'][:, 1]**2.) tri = Triangulation( np.array([rc[0] + 100000. for rc in vtu.raw_coords[:, 0]]) / 1000., np.array([rc[1] for rc in vtu.raw_coords[:, 0]]), vtu.simptt) gs = gridspec.GridSpec(2, 3, width_ratios=(1., 1., 1.), height_ratios=(1, 0.1), hspace=0.55, wspace=0.1, left=0.1, bottom=0.2, top=0.9, right=0.98) fig = plt.figure(figsize=(7.5, 3.0)) axes = [fig.add_subplot(gs[0, i]) for i in range(3)] cbr_axes = [fig.add_subplot(gs[1, i]) for i in range(3)] cm1 = axes[0].tricontourf(tri, vtu.rawdata_dict['strainrate 4'], cmap='bwr', levels=np.linspace(-2.5e-4, 2.5e-4, 101), extend='both') levels = [1000, 5000, 10000, 50000, 100000] axes[0].set_xlim(0, 20) axes[0].set_ylim(0, 2250) CS = axes[0].tricontour(tri, vtu.rawdata_dict['age'], colors='k', levels=levels, linewidths=0.5) fmt = {level: '{:d} kyr'.format(level // 1000) for level in levels} axes[0].set_xlim(0, 20) axes[0].set_ylim(0, 2250) axes[0].clabel(CS, CS.levels, inline=True, fmt=fmt, fontsize=8) for c in cm1.collections: c.set_edgecolor("face") axes[0].set_title(r'$\dot\varepsilon_{xz}$') axes[1].set_title('Vertical fabric') axes[2].set_title('Angle') axes[0].set_xlim(0, 20) axes[0].set_xticks([0., 10., 20.]) cm2 = axes[1].tricontourf(tri, vtu.rawdata_dict['fabric 2'], cmap='BrBG', norm=anisolib.fab_norm, levels=np.linspace(0, 1, 101), extend='neither') for c in cm2.collections: c.set_edgecolor("face") axes[1].set_xlim(0, 20) axes[1].set_xticks([0., 10., 20.]) cm3 = axes[2].tricontourf(tri, vtu.rawdata_dict['eigenv 4'], cmap='PuOr', levels=np.linspace(-5, 5, 201), extend='both') for c in cm3.collections: c.set_edgecolor("face") axes[2].set_xlim(0, 20) axes[2].set_xticks([0., 10., 20.]) cbr = plt.colorbar(cm1, cax=cbr_axes[0], orientation='horizontal', label=r'$\dot\varepsilon_{xz}$', ticks=(-2.5e-4, 0, 2.5e-4)) cbr.ax.set_xticklabels(['-2.5e-4', '0', '2.5e-4']) cbr = plt.colorbar(cm2, cax=cbr_axes[1], orientation='horizontal', ticks=(0, 1. / 3., 2. / 3., 1.0), label=r'$a^{(2)}_{zz}$') cbr.ax.set_xticklabels(['0', r'$\frac{1}{3}$', r'$\frac{2}{3}$', '1']) cbr = plt.colorbar(cm3, cax=cbr_axes[2], orientation='horizontal', ticks=(-5, 0, 5), label=r'Angle ($^o$)') axes[0].set_ylabel('Height (m)') for ax in axes[1:]: ax.set_yticklabels(['' for tick in ax.get_yticklabels()]) axes[1].set_xlabel('Distance (km)') for letter, ax in zip('abc', axes): ax.text(0.05, 0.85, letter, transform=ax.transAxes, fontsize=bfs) ax.set_ylim(0, 2250) fig.savefig('../plots/idealized_init_zoom.png', dpi=300)
def idealized_with_cartoon(): # We want to find the filename for the highest index where we have all 3 files = glob('../stream/rstf/deform2e-3_????.vtu') inds = np.argsort(np.array([float(fn[-8:-4]) for fn in files])) files = [files[i] for i in inds] vtu = fastvtulib.get_structured_vtu(files[-1]) vtu.rawdata_dict['vel'] = np.sqrt(vtu.rawdata_dict['aiflow'][:, 0]**2. + vtu.rawdata_dict['aiflow'][:, 1]**2.) tri = Triangulation( np.array([rc[0] + 100000. for rc in vtu.raw_coords[:, 0]]) / 1000., np.array([rc[1] for rc in vtu.raw_coords[:, 0]]), vtu.simptt) gs = gridspec.GridSpec(7, 4, width_ratios=(1., 1., 0.5, 0.035), height_ratios=(0.4, 0.05, 0.4, 0.05, 0.2, 0.05, 0.15), hspace=0.00, wspace=0.1, left=0.07, bottom=0.07, top=0.93, right=0.92) fig = plt.figure(figsize=(7.9, 3.1)) axes = [fig.add_subplot(gs[0:4, i]) for i in range(2)] cbr_axes = [fig.add_subplot(gs[5, i]) for i in range(2)] ball_cbr_axis = fig.add_subplot(gs[0:5, 3]) cartoon_axes = [ fig.add_subplot(gs[0, 2], projection=fabricplotlib.PRJ), fig.add_subplot(gs[2, 2], projection=fabricplotlib.PRJ), fig.add_subplot(gs[4:, 2], projection=fabricplotlib.PRJ) ] cm1 = axes[0].tricontourf(tri, vtu.rawdata_dict['aiflow'][:, 0], cmap='Reds', levels=np.linspace(0.0, 10., 101), extend='max') levels = [1000, 5000, 10000, 50000, 100000] CS = axes[0].tricontour(tri, vtu.rawdata_dict['age'], colors='k', levels=levels, linewidths=0.5) fmt = {level: '{:d} kyr'.format(level // 1000) for level in levels} axes[0].clabel(CS, CS.levels, inline=True, fmt=fmt, fontsize=8) for c in cm1.collections: c.set_edgecolor("face") # axes[0].set_title('Speed', fontsize=bfs) # axes[1].set_title('Vertical fabric', fontsize=bfs) # axes[2].set_title('Woodcock Parameter', fontsize=bfs) axes[0].set_xlim(0, 175) axes[0].set_xticks([0., 50., 100., 150.]) # k = woodcock(vtu.rawdata_dict) vtu.rawdata_dict['eigenv 3'][np.isnan(vtu.rawdata_dict['eigenv 3'])] = 1.0 vtu.rawdata_dict['eigenv 3'][np.isinf(vtu.rawdata_dict['eigenv 3'])] = 1.0 cm3 = axes[1].tricontourf(tri, vtu.rawdata_dict['eigenv 3'], cmap='summer', extend='neither', levels=np.linspace(0.33333, 1, 101)) for c in cm3.collections: c.set_edgecolor("face") axes[1].set_xlim(0, 175) axes[1].set_xticks([0., 50., 100., 150.]) fabricplotlib.quiver(axes[1], vtu, scale=15, width=0.005) axes[1].scatter(-1000, -1000, marker=r'$\uparrow$', label='Single max. in x-z', color='k') axes[1].legend(loc='lower left', bbox_to_anchor=(0.15, 0.85), fontsize=fs, framealpha=1.0) cbr = plt.colorbar(cm1, cax=cbr_axes[0], orientation='horizontal', ticks=(0, 5., 10.)) cbr.set_label(label=r'$v_x$ (m a$^{-1})$', size=fs) cbr.ax.tick_params(axis='both', which='major', labelsize=fs) cbr = plt.colorbar(cm3, cax=cbr_axes[1], orientation='horizontal', ticks=(1. / 3., 2. / 3., 1)) cbr.set_label(label=r'$a_1^{(2)}$', size=fs) cbr.ax.set_xticklabels([r'$\frac{1}{3}$', r'$\frac{2}{3}$', '1']) cbr.ax.tick_params(axis='both', which='major', labelsize=fs) axes[0].set_ylabel('Height (m)', fontsize=fs) for ax in axes[1:]: ax.set_yticklabels(['' for tick in ax.get_yticklabels()]) axes[0].set_xlabel('Distance (km)', fontsize=fs) axes[1].set_xlabel('Distance (km)', fontsize=fs) for letter, ax in zip('abc', axes): ax.text(0.05, 0.85, letter, transform=ax.transAxes, fontsize=bfs) ax.tick_params(axis='both', which='major', labelsize=fs) ax.set_ylim(0, 2250) for letter, ax in zip('cde', cartoon_axes): ax.text(0.00, 0.9, letter, transform=ax.transAxes, fontsize=bfs) x, y = np.array([70000, 70000, 70000]), np.array([1900, 1200, 200]) axes[1].text(x[0] / 1000. + 100, y[0], 'c', fontsize=fs, ha='center', va='center', bbox=dict(boxstyle='square,pad=0.1', facecolor='white', alpha=0.75)) axes[1].text(x[1] / 1000. + 100, y[1], 'd', fontsize=fs, ha='center', va='center', bbox=dict(boxstyle='square,pad=0.1', facecolor='white', alpha=0.75)) axes[1].text(x[2] / 1000. + 100, y[2], 'e', fontsize=fs, ha='center', va='center', bbox=dict(boxstyle='square,pad=0.1', facecolor='white', alpha=0.75)) fab_at_pts = vtu.get_pts_2d(anisolib.fabs, x, y) a2 = anisolib.fabric_dict_to_a2(fab_at_pts) for i in range(3): cm = fabricplotlib.a2plot(a2[:, :, i], ax=cartoon_axes[i], cbr=False, show=False, levels=13) cbr = plt.colorbar(cm, cax=ball_cbr_axis, orientation='vertical') cbr.set_label(label=r'ODF($\theta,\phi$)', size=fs) # cbr.ax.set_xticklabels(['0', '1', '2']) cbr.ax.tick_params(axis='both', which='major', labelsize=fs) fig.savefig('../plots/idealized_init_cartoon.png', dpi=300) fig.savefig('../plots/poster_idealized_init_cartoon.png', dpi=300, transparent=True)
def single_plot(fl_n=1, fps=2, fn='slide', panel2='fabric 4', countby=1, folder='rstf'): files = glob('../stream/' + folder + '/' + fn + '????.vtu') if fn[0] == 'd': maxn = 2502 else: maxn = 1002 if len(files) > maxn + 1: files = files[1:maxn] else: files = files[1:] inds = np.argsort(np.array([float(fn[-8:-4]) for fn in files])) fns = [files[ind] for ind in inds] FFMpegWriter = manimation.writers['ffmpeg'] title = '{:s}'.format(fn.title()) metadata = dict(title=title, artist='Matplotlib', comment='Elmer/Ice Model Results') writer = FFMpegWriter(fps=fps, metadata=metadata, extra_args=['-vcodec', 'rawvideo']) times = np.arange(0.0, 10.0 * len(files), 10.0) lens = [len(fn) for fn in fns if len(fn) > 0] if len(lens) == 0: return steps = min(lens) vtus = [ fastvtulib.get_structured_vtu(tf) if tf is not None else None for tf in fns[1::countby] ] tris = [ Triangulation( np.array([rc[0] for rc in vtu.raw_coords[:, 0]]) / 1000. + 100, np.array([rc[1] for rc in vtu.raw_coords[:, 0]]), vtu.simptt) if vtu is not None else None for vtu in vtus ] fig, ((ax1), (ax2)) = plt.subplots(nrows=2, ncols=1, figsize=(8, 6), sharex=True, sharey=True) ax1.set_title(r't={:5.1f}'.format(0.0)) gs = gridspec.GridSpec(7, 4, width_ratios=(1., 1., 0.5, 0.035), height_ratios=(0.4, 0.05, 0.4, 0.05, 0.2, 0.05, 0.15), hspace=0.00, wspace=0.1, left=0.07, bottom=0.07, top=0.90, right=0.92) fig = plt.figure(figsize=(7.9, 3.1)) axes = [None, fig.add_subplot(gs[0:4, 0:2])] cbr_axes = [None, fig.add_subplot(gs[5, 0])] ball_cbr_axis = fig.add_subplot(gs[0:5, 3]) cartoon_axes = [ fig.add_subplot(gs[0, 2], projection=fabricplotlib.PRJ), fig.add_subplot(gs[2, 2], projection=fabricplotlib.PRJ), fig.add_subplot(gs[4:, 2], projection=fabricplotlib.PRJ) ] # k = woodcock(vtu.rawdata_dict) vtus[0].rawdata_dict['eigenv 3'][np.isnan( vtus[0].rawdata_dict['eigenv 3'])] = 1.0 vtus[0].rawdata_dict['eigenv 3'][np.isinf( vtus[0].rawdata_dict['eigenv 3'])] = 1.0 cm3 = axes[1].tricontourf(tris[0], vtus[0].rawdata_dict['eigenv 3'], cmap='summer', extend='neither', levels=np.linspace(0.33333, 1, 101)) for c in cm3.collections: c.set_edgecolor("face") axes[1].set_xlim(0, 175) axes[1].set_xticks([0., 50., 100., 150.]) quiv = fabricplotlib.quiver(axes[1], vtus[0], scale=25, width=0.002) axes[1].scatter(-1000, -1000, marker=r'$\uparrow$', label='Single max. in x-z', color='k') axes[1].legend(loc='lower left', bbox_to_anchor=(0.15, 0.85), fontsize=fs, framealpha=1.0) cbr = plt.colorbar(cm3, cax=cbr_axes[1], orientation='horizontal', ticks=(1. / 3., 2. / 3., 1)) cbr.set_label(label=r'$a_1^{(2)}$', size=fs) cbr.ax.set_xticklabels([r'$\frac{1}{3}$', r'$\frac{2}{3}$', '1']) cbr.ax.tick_params(axis='both', which='major', labelsize=fs) axes[1].set_xlabel('Distance (km)', fontsize=fs) axes[1].set_ylabel('Height (m)', fontsize=fs) axes[1].text(0.05, 0.85, 'a', transform=axes[1].transAxes, fontsize=bfs) axes[1].tick_params(axis='both', which='major', labelsize=fs) axes[1].set_ylim(0, 2250) t = axes[1].text(-5, 2400, 'Time={:d}'.format(0)) for letter, ax in zip('bcde', cartoon_axes): ax.text(0.00, 0.9, letter, transform=ax.transAxes, fontsize=bfs) x, y = np.array([70000, 70000, 70000]), np.array([1900, 1200, 200]) axes[1].text(x[0] / 1000. + 100, y[0], 'b', fontsize=fs, ha='center', va='center', bbox=dict(boxstyle='square,pad=0.1', facecolor='white', alpha=0.75)) axes[1].text(x[1] / 1000. + 100, y[1], 'c', fontsize=fs, ha='center', va='center', bbox=dict(boxstyle='square,pad=0.1', facecolor='white', alpha=0.75)) axes[1].text(x[2] / 1000. + 100, y[2], 'd', fontsize=fs, ha='center', va='center', bbox=dict(boxstyle='square,pad=0.1', facecolor='white', alpha=0.75)) fab_at_pts = vtus[0].get_pts_2d(anisolib.fabs, x, y) a2 = anisolib.fabric_dict_to_a2(fab_at_pts) cms = [None for i in range(3)] for i in range(3): cms[i] = fabricplotlib.a2plot(a2[:, :, i], ax=cartoon_axes[i], cbr=False, show=False, levels=13) cbr = plt.colorbar(cms[0], cax=ball_cbr_axis, orientation='vertical') cbr.set_label(label=r'ODF($\theta,\phi$)', size=fs) # cbr.ax.set_xticklabels(['0', '1', '2']) cbr.ax.tick_params(axis='both', which='major', labelsize=fs) if folder == 'rstf': pref = '' else: pref = 'oop' with writer.saving(fig, '{:s}_fabric_evolution.avi'.format(pref + fn), 150): for i, (svtu, tri, time) in enumerate(zip(vtus, tris, times[0::countby])): ax1.set_title(r't={:5.1f}'.format(time)) if svtu is not None: # Note that this is not fully accurate since fabric 2 only approximates the maximum eigenvalue for j in range(3): for c in cms[j].collections: c.remove() for c in cm3.collections: c.remove() for p in quiv: try: p.remove() except: try: for c in p.collections: c.remove() except AttributeError: # I think this is the dots for OOP for c in p: c.remove() t.set_text('Time={:d}'.format(int(time))) cm3 = axes[1].tricontourf(tri, svtu.rawdata_dict['eigenv 3'], cmap='summer', extend='neither', levels=np.linspace(0.33333, 1, 101)) quiv = fabricplotlib.quiver(axes[1], svtu, scale=25, width=0.002) fab_at_pts = svtu.get_pts_2d(anisolib.fabs, x, y) a2 = anisolib.fabric_dict_to_a2(fab_at_pts) for j in range(3): cms[j] = fabricplotlib.a2plot(a2[:, :, j], ax=cartoon_axes[j], cbr=False, show=False, levels=13) writer.grab_frame()
maxtime = np.min([np.max(times) for times in timess[:-3]]) maxtime_oop = np.min([np.max(times) for times in timess]) try: inds_times = [ int(np.where(times == maxtime)[0][0]) for times in timess[:-3] ] inds_times_oop = [ int(np.where(timess[-1] == maxtime_oop)[0][0]) for times in timess ] except: inds_times = [301 for i in timess[:-3]] inds_times_oop = [301 for i in timess] vtus = { fmt: fastvtulib.get_structured_vtu(filel[int(ind[ind_t])]) for fmt, ind, ind_t, filel in zip(fmts[:-3], inds, inds_times, files) } vtus_oop = { fmt: fastvtulib.get_structured_vtu(filel[int(ind[ind_t])]) for fmt, ind, ind_t, filel in zip(fmts, inds, inds_times_oop, files) } print('With OOP:', maxtime_oop) print('Without OOP:', maxtime) deform_files = glob('../stream/rstf/deform_diffuse????.vtu') deform_inds = np.argsort(np.array([float(fn[-8:-4]) for fn in deform_files])) deform_vtu = fastvtulib.get_structured_vtu(deform_files[deform_inds[-1]]) colors = ['C0', 'C1', 'C2']