Esempio n. 1
0
def test_reflections():  # 3. reflections
    dat = DATAKERNEL['refl'][()]
    for key, val in dat.items():
        Rp, Rm = kernel.reflections(**val[0])
        assert_allclose(Rp, val[1])
        assert_allclose(Rm, val[2])
        val[0]['use_ne_eval'] = use_ne_eval
        Rp, Rm = kernel.reflections(**val[0])
        assert_allclose(Rp, val[1])
        assert_allclose(Rm, val[2])
Esempio n. 2
0
def test_fields():
    Gam = np.sqrt((etaH/etaV)[:, None, :, None] *
                  (lambd**2)[None, :, None, :] + (zeta**2)[:, None, :, None])

    for lay in [0, 1, 5]:  # Src/rec in first, second, and last layer

        inp1 = {'depth': depth[:-1], 'e_zH': etaH, 'Gam': Gam,
                'lrec': np.array(lay), 'lsrc': np.array(lay)}
        Rp1, Rm1 = kernel.reflections(**inp1)

        inp2 = {'depth': depth[:-1], 'Gam': Gam, 'Rp': Rp1, 'Rm': Rm1,
                'lrec': np.array(lay), 'lsrc': np.array(lay),
                'zsrc': depth[lay+1]-50}

        for TM in [True, False]:
            inp2['TM'] = TM

            # empymod-version
            out = kernel.fields(ab=11, **inp2)

            # empymod.scripts-version
            TMTE = tmtemod.fields(**inp2)

            # Check
            assert_allclose(out[0], TMTE[0] + TMTE[1])
            assert_allclose(out[1], TMTE[2] + TMTE[3])
Esempio n. 3
0
    def get_rp_rm(z_eta):
        r"""Return Rp, Rm."""

        # Get Rp/Rm for lambd=0
        Rp, Rm = reflections(depth, z_eta, Gam, lrec, lsrc)

        # Depending on model Rp/Rm have 3 or 4 dimensions. Last two are
        # wavenumbers and layers btw src and rec, which both are 1.
        if Rp.ndim == 4:
            Rp = np.squeeze(Rp, axis=3)
        if Rm.ndim == 4:
            Rm = np.squeeze(Rm, axis=3)
        Rp = np.squeeze(Rp, axis=2)
        Rm = np.squeeze(Rm, axis=2)

        # Calculate reverberation M and general factor npfct
        Ms = 1 - Rp * Rm * np.exp(-2 * iGam * ds)
        npfct = ang_fact * zetaH[:, lsrc] / (fact * off * lgam * Ms)

        return Rp, Rm, npfct
Esempio n. 4
0
def greenfct(zsrc, zrec, lsrc, lrec, depth, etaH, etaV, zetaH, zetaV, lambd):
    r"""Calculate Green's function for TM and TE.

    This is a modified version of empymod.kernel.greenfct(). See the original
    version for more information.

    """
    # GTM/GTE have shape (frequency, offset, lambda).
    # gamTM/gamTE have shape (frequency, offset, layer, lambda):

    for TM in [True, False]:

        # Define eta/zeta depending if TM or TE
        if TM:
            e_zH, e_zV, z_eH = etaH, etaV, zetaH  # TM: zetaV not used
        else:
            e_zH, e_zV, z_eH = zetaH, zetaV, etaH  # TE: etaV not used

        # Uppercase gamma
        Gam = np.sqrt((e_zH / e_zV)[:, None, :, None] *
                      (lambd * lambd)[None, :, None, :] +
                      (z_eH * e_zH)[:, None, :, None])

        # Gamma in receiver layer
        lrecGam = Gam[:, :, lrec, :]

        # Reflection (coming from below (Rp) and above (Rm) rec)
        Rp, Rm = reflections(depth, e_zH, Gam, lrec, lsrc)

        # Field propagators
        # (Up- (Wu) and downgoing (Wd), in rec layer); Eq 74
        if lrec != depth.size - 1:  # No upgoing field prop. if rec in last
            ddepth = depth[lrec + 1] - zrec
            Wu = np.exp(-lrecGam * ddepth)
        else:
            Wu = np.full_like(lrecGam, 0 + 0j)
        if lrec != 0:  # No downgoing field propagator if rec in first
            ddepth = zrec - depth[lrec]
            Wd = np.exp(-lrecGam * ddepth)
        else:
            Wd = np.full_like(lrecGam, 0 + 0j)

        # Field at rec level (coming from below (Pu) and above (Pd) rec)
        Puu, Pud, Pdu, Pdd = fields(depth, Rp, Rm, Gam, lrec, lsrc, zsrc, TM)

        # Store in corresponding variable PT* = [T*uu, T*ud, T*du, T*dd]
        df = np.exp(-lrecGam * abs(zsrc - zrec))  # direct field
        fTM = Gam[:, :, lrec, :] / etaH[:, None, lrec, None]
        fTE = zetaH[:, None, lsrc, None] / Gam[:, :, lsrc, :]
        if TM:
            PTM = [
                Puu * Wu * fTM, Pud * Wu * fTM, Pdu * Wd * fTM, Pdd * Wd * fTM,
                -df * fTM
            ]
        else:
            PTE = [
                Puu * Wu * fTE, Pud * Wu * fTE, Pdu * Wd * fTE, Pdd * Wd * fTE,
                df * fTE
            ]

    # Return Green's functions
    return PTM, PTE
Esempio n. 5
0
    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'],
        'lsrc': inp1['lsrc']}
Rp1, Rm1 = kernel.reflections(**inp5)

refl[0] = (inp5, Rp1, Rm1)
# Source and receiver in same layer, but not last
inp6 = {'depth': inp2['depth'],
        'e_zH': etaH,
        'Gam': Gam,
        'lrec': np.array(3),
        'lsrc': np.array(3)}
Rp2, Rm2 = kernel.reflections(**inp6)

refl[1] = (inp6, Rp2, Rm2)

# # E -- FIELDS # #
# Standard example
inp7 = {'depth': depth,