def test_greenfct(): # 2. greenfct dat = DATAKERNEL['green'][()] for key, val in dat.items(): for i in [3, 5, 7]: ab = val[0] msrc = val[1] mrec = val[2] out = kernel.greenfct(ab=ab, msrc=msrc, mrec=mrec, **val[i]) assert_allclose(out[0], val[i+1][0]) assert_allclose(out[1], val[i+1][1]) val[i]['use_ne_eval'] = use_ne_eval out = kernel.greenfct(ab=ab, msrc=msrc, mrec=mrec, **val[i]) assert_allclose(out[0], val[i+1][0]) assert_allclose(out[1], val[i+1][1])
def test_greenfct(): # 2. greenfct dat = DATAKERNEL['green'][()] for _, val in dat.items(): for i in [3, 5, 7]: ab = val[0] msrc = val[1] mrec = val[2] out = kernel.greenfct(ab=ab, msrc=msrc, mrec=mrec, **val[i]) assert_allclose(out[0], val[i+1][0]) assert_allclose(out[1], val[i+1][1]) if use_vml: # Check if numexpr yields same result val[i]['use_ne_eval'] = use_ne_eval out = kernel.greenfct(ab=ab, msrc=msrc, mrec=mrec, **val[i]) assert_allclose(out[0], val[i+1][0]) assert_allclose(out[1], val[i+1][1])
def test_greenfct(): for lay in [0, 1, 5]: # src/rec in first, second, and last layer inp = { 'depth': depth[:-1], 'lambd': lambd, 'etaH': etaH, 'etaV': etaV, 'zetaH': zeta, 'zetaV': zeta, 'lrec': np.array(lay), 'lsrc': np.array(lay), 'zsrc': depth[lay + 1] - 50, 'zrec': depth[lay + 1] - 10 } # empymod-version out1, out2 = kernel.greenfct(ab=11, xdirect=False, msrc=False, mrec=False, use_ne_eval=False, **inp) # empymod.scripts-version TM, TE = tmtemod.greenfct(**inp) TM = TM[0] + TM[1] + TM[2] + TM[3] + TM[4] TE = TE[0] + TE[1] + TE[2] + TE[3] + TE[4] # Check assert_allclose(out1, TM, atol=1e-100) assert_allclose(out2, TE)
# # C -- GREENFCT # # # Standard example inp2 = deepcopy(inp1) # Source and receiver in same layer (last) inp3 = deepcopy(inp1) inp3['zsrc'] = 610. inp3['lsrc'] = np.array(5) # Receiver in first layer inp4 = deepcopy(inp1) inp4['zrec'] = -30. inp4['lrec'] = np.array(0) green = {} for key, val in iab.items(): res1 = kernel.greenfct(ab=val[2], msrc=val[0], mrec=val[1], **inp2) res2 = kernel.greenfct(ab=val[2], msrc=val[0], mrec=val[1], **inp3) res3 = kernel.greenfct(ab=val[2], msrc=val[0], mrec=val[1], **inp4) green[key] = (val[2], val[0], val[1], inp2, res1, inp3, res2, inp4, res3) # # D -- REFLECTIONS # # refl = {} # Standard example Gam = np.sqrt((etaH/etaV)[:, None, :, None] * (lambd**2)[None, :, None, :] + (zetaH**2)[:, None, :, None]) inp5 = {'depth': depth, 'e_zH': etaH, 'Gam': Gam, 'lrec': inp1['lrec'],