def geteref(e, mesh, option=None, tInd=0): """ geteref(e, mesh, option=None, tInd=0) Return a reference electric field of given option. Parameters ---------- e : array of electric field [nE x nSrc x ntime] or [nE x ntime] for a single source. mesh: SimPEG mesh object. option: "None" or "max" "None" requires tInd, and simply choose that time index "max" quarrry electric field at maximum. tInd: int, time index for the choice of the reference electric field """ # Single source if e.ndim == 2: ntime = e.shape[1] if option == "max": inds = np.argmax(abs(e), axis=1) inds_max = Utils.sub2ind( e.shape, np.c_[np.arange(mesh.nE), inds] ) eref = Utils.mkvc(e)[inds_max] else: eref = e[:, tInd] # Multi source elif e.ndim == 3: ntime = e.shape[2] nSrc = e.shape[1] eref = [] if option == "max": for iSrc in range (nSrc): inds = np.argmax(abs(e[:, iSrc, :]), axis=1) inds_max = Utils.sub2ind( e[:, iSrc, :].shape, np.c_[np.arange(mesh.nE), inds] ) eref.append(Utils.mkvc(e[:, iSrc, :])[inds_max]) eref = np.vstack(eref).T else: eref = e[:, :, tInd] else: raise Exception("Dimension of e should be either 1 or 2") return eref
def lineintegral(M, Tx, Rx): O, D = Tx, Rx - Tx I, J, V = [], [], [] for i in range(M.nCx): for j in range(M.nCy): x = M.vectorNx[[i, i+1]] y = M.vectorNy[[j, j+1]] v = lengthInCell(O, D, x, y) if v is not None: I += [i] J += [j] V += [v] inds = Utils.sub2ind(M.vnC, np.array([I, J]).T) return inds, V
def lineintegral(M, Tx, Rx): O, D = Tx, Rx - Tx I, J, V = [], [], [] for i in range(M.nCx): for j in range(M.nCy): x = M.vectorNx[[i, i + 1]] y = M.vectorNy[[j, j + 1]] v = lengthInCell(O, D, x, y) if v is not None: I += [i] J += [j] V += [v] inds = Utils.sub2ind(M.vnC, np.array([I, J]).T) return inds, V