frame = int(sys.argv[1]) fl = flac.Flac() x, z = fl.read_mesh(frame) itrench = find_trench_index(z) xtrench = x[itrench, 0] # get interpolated phase either from previous run or from original data phasefile = 'intp3-phase.%d' % frame if not os.path.exists(phasefile): xx, zz, ph = interpolate_phase(frame, xtrench) f = open(phasefile, 'w') f.write('%d %d\n' % xx.shape) flac.printing(xx, zz, ph, stream=f) f.close() else: f = open(phasefile) nx, nz = np.fromfile(f, sep=' ', count=2) tmp = np.fromfile(f, sep=' ') tmp.shape = (nx, nz, 3) xx = tmp[:, :, 0] zz = tmp[:, :, 1] ph = tmp[:, :, 2] f.close() # get interpolated strain_rate either from previous run or from original data strain_ratefile = 'intp3-srII.%d' % frame if not os.path.exists(strain_ratefile): srx, srz, sr = interpolate_srII(frame, xtrench)
rigth2 = left2 + 200 fl = flac.Flac() x, z = fl.read_mesh(frame) itrench = find_trench_index(z) xtrench = x[itrench, 0] print('trench =', itrench) print('trench location =', xtrench) # get interpolated phase either from previous run or from original data phasefile = 'intp3-phase.%d' % frame if not os.path.exists(phasefile): xx, zz, ph = interpolate_phase(frame, xtrench, 1) f = open(phasefile, 'w') f.write('%d %d\n' % xx.shape) flac.printing(xx, zz, ph, stream=f) f.close() else: f = open(phasefile) nx, nz = np.fromfile(f, sep=' ', count=2) nx = int(nx) nz = int(nz) tmp = np.fromfile(f, sep=' ') tmp.shape = (nx, nz, 3) xx = tmp[:, :, 0] zz = tmp[:, :, 1] ph = tmp[:, :, 2] f.close() # get interpolated T either from previous run or from original data tfile = 'intp3-T.%d' % frame
frame = int(sys.argv[1]) fl = flac.Flac() x, z = fl.read_mesh(frame) itrench = find_trench_index(z) xtrench = x[itrench, 0] # get interpolated strain_rate either from previous run or from original data strain_ratefile = 'intp3-srII.%d' % frame if not os.path.exists(strain_ratefile): xx, zz, ph = interpolate_srII(frame, xtrench) f = open(strain_ratefile, 'w') f.write('%d %d\n' % xx.shape) flac.printing(xx, zz, ph, stream=f) f.close() else: f = open(strain_ratefile) nx, nz = np.fromfile(f, sep=' ', count=2) strr = np.fromfile(f, sep=' ') strr.shape = (nx, nz, 3) xx = strr[:, :, 0] zz = strr[:, :, 1] ph = strr[:, :, 2] f.close() # get interpolated T either from previous run or from original data tfile = 'intp3-T.%d' % frame if not os.path.exists(tfile): T = fl.read_temperature(frame)
zmin - padding, zmax + padding) f = flac.bilinear_interpolation2d(cx, cz, cf, x, z) elif field in ('velo'): # read vector field on nodes cf = getattr(fl, 'read_' + field)(frame) cfx = cf[0] cx, cz, cfx = excluding(x, z, cfx, xmin - padding, xmax + padding, zmin - padding, zmax + padding) fx = flac.bilinear_interpolation2d(cx, cz, cfx, x, z) cfz = cf[1] cx, cz, cfz = excluding(x, z, cfz, xmin - padding, xmax + padding, zmin - padding, zmax + padding) fz = flac.bilinear_interpolation2d(cx, cz, cfz, x, z) else: raise RuntimeError('unknown field %s' % field) f = clip_topo(x, z, f, xx, zz) return x, z, f if __name__ == '__main__': if len(sys.argv) < 3: print __doc__ exit(1) frame = int(sys.argv[1]) field = sys.argv[2].lower() xx, zz, f = interpolate(frame, field) flac.printing(xx, zz, f)
topomod = topo.copy() # erode forearc height to sea level topomod[topo > 0] = 0 # fill basin for ii in range(len(peaks)-1): fill_height = min((basin_depth, topo[peaks[ii]], topo[peaks[ii+1]])) for i in range(peaks[ii], peaks[ii+1]): if topo[i] < fill_height: topomod[i] = fill_height return topomod def compute_gravity2(frame): '''Similar to compute_gravity(), but also return modified topo''' px, topo, grav = compute_gravity(frame) topomod = modify_topo(topo) return px, topo, topomod, grav if __name__ == '__main__': frame = int(sys.argv[1]) px, topo, topomod, gravity = compute_gravity2(frame) flac.printing(px, topo, topomod, gravity)
## phase # read marker location, age and phase mx, mz, mage, mphase = fl.read_markers(frame) mx, mz, mphase = excluding(mx, mz, mphase, xmin-dx, xmax+dx, zmin-dz, zmax+dz) ph = flac.nearest_neighbor_interpolation2d(mx, mz, mphase, x, z) f = ph.astype(np.float32) elif field in ('temperature', 'aps', 'density', 'eII', 'sII', 'sxx', 'szz', 'sxz', 'srII', 'pres', 'diss', 'visc'): # read field cf = getattr(fl, 'read_'+field)(frame) cx, cz = flac.elem_coord(xx, zz) cx, cz, cf = excluding(cx, cz, cf, xmin-dx, xmax+dx, zmin-dz, zmax+dz) f = flac.gaussian_interpolation2d(cx, cz, cf, x, z) else: raise RuntimeError('unknown field %s' % field) f = clip_topo(x, z, f, xx, zz) return x, z, f if __name__ == '__main__': if len(sys.argv) < 3: print __doc__ exit(1) frame = int(sys.argv[1]) field = sys.argv[2].lower() xx, zz, f = interpolate(frame, field) flac.printing(xx, zz, f)