interim /= interimcount # Generate interior model without nans interim = np.nan_to_num(interim) # Create selection array selector = interimcount != 0 # Generate output grids X, Z = np.mgrid[0:nx, 0:nz] X = X * cellsize + outbox[0] Z = outbox[3] - Z * cellsize P = np.array([X.ravel(), Z.ravel()]).T #Generate initial grids x0 = X[selector] z0 = Z[selector] pos0 = np.array([x0.ravel(), z0.ravel()]).T val = interim[selector] printnow('Extrapolating') # Extrapolate using nearest neighbour outim = griddata(pos0, val, P, method='nearest').reshape((nx, nz)) printnow('Writing output') # Write FAST model outdims = (nx, 1, nz) writefast(outfile, outim.reshape(outdims))
# y-axis, normalized by the total number of rays in that x,z location avg2d = np.nan_to_num(((1. * hitcount * model3d) / hitcount3dsum).sum(axis=1)) # Create mask (value of 1 where there are no rays) selector = hitcount2dsum > 0 baseblank = 1 - selector if (options.extrap): nx, nz = avg2d.shape X, Z = np.mgrid[0:nx, 0:nz] P = np.array([X.ravel(), Z.ravel()]).T x0 = X[selector] z0 = Z[selector] pos0 = np.array([x0.ravel(), z0.ravel()]).T val = avg2d[selector] model2d = griddata(pos0, val, P, method='nearest').reshape((nx, nz)) else: # Create an empty (2D) model in which to store the result # Copy the 2D average model into the masked region model2d = avg2d.copy() + model2davg.copy() * baseblank if (options.direct2d): writefast(outfile, model2d.reshape(pseudodims)) else: newmodel3d = model3d.copy() newmodel3d[:] = model2d.reshape(pseudodims) writefast(outfile, newmodel3d)
# y-axis, normalized by the total number of rays in that x,z location avg2d = np.nan_to_num(((1. * hitcount * model3d) / hitcount3dsum).sum(axis=1)) # Create mask (value of 1 where there are no rays) selector = hitcount2dsum > 0 baseblank = 1 - selector if (options.extrap): nx, nz = avg2d.shape X, Z = np.mgrid[0:nx, 0:nz] P = np.array([X.ravel(),Z.ravel()]).T x0 = X[selector] z0 = Z[selector] pos0 = np.array([x0.ravel(),z0.ravel()]).T val = avg2d[selector] model2d = griddata(pos0, val, P, method='nearest').reshape((nx,nz)) else: # Create an empty (2D) model in which to store the result # Copy the 2D average model into the masked region model2d = avg2d.copy() + model2davg.copy() * baseblank if (options.direct2d): writefast(outfile, model2d.reshape(pseudodims)) else: newmodel3d = model3d.copy() newmodel3d[:] = model2d.reshape(pseudodims) writefast(outfile, newmodel3d)
interim /= interimcount # Generate interior model without nans interim = np.nan_to_num(interim) # Create selection array selector = interimcount != 0 # Generate output grids X, Z = np.mgrid[0:nx, 0:nz] X = X*cellsize + outbox[0] Z = outbox[3] - Z*cellsize P = np.array([X.ravel(),Z.ravel()]).T #Generate initial grids x0 = X[selector] z0 = Z[selector] pos0 = np.array([x0.ravel(),z0.ravel()]).T val = interim[selector] printnow('Extrapolating') # Extrapolate using nearest neighbour outim = griddata(pos0, val, P, method='nearest').reshape((nx,nz)) printnow('Writing output') # Write FAST model outdims = (nx, 1, nz) writefast(outfile, outim.reshape(outdims))