Exemplo n.º 1
0
def band_averaged_psd_by_constit(tin, t, e, elor, coef, opt):
    # Band-averaged (ba) spectral densities at each constituent freq.
    constits = coef.aux.frq
    if opt.equi:
        e_ = e
        if len(tin) > len(t):
            e_ = complex_interp(tin, t, e)
        ba = band_psd(tin, e_, constits, equi=True)

    else:
        ba = band_psd(t, e, constits, equi=False, frqosamp=opt.lsfrqosmp)

    # power [ (e units)^2 ] from spectral density [ (e units)^2 / cph ]
    df = 1 / (elor * 24)  # inverse of record length in hours
    ba.Puu *= df
    Puu = np.zeros_like(constits)
    Pvv = Puv = None

    if opt.twodim:
        ba.Pvv *= df
        ba.Puv *= df
        Pvv = np.zeros_like(constits)
        Puv = np.zeros_like(constits)

    for i, (lo, hi) in enumerate(ba.fbnd):
        inside = (constits >= lo) & (constits <= hi)
        Puu[inside] = ba.Puu[i]
        if opt.twodim:
            Pvv[inside] = ba.Pvv[i]
            Puv[inside] = ba.Puv[i]
    return Puu, Pvv, Puv
Exemplo n.º 2
0
def band_averaged_psd_by_constit(tin, t, e, elor, coef, opt):
    # Band-averaged (ba) spectral densities at each constituent freq.
    constits = coef.aux.frq
    if opt.equi:
        e_ = e
        if len(tin) > len(t):
            e_ = complex_interp(tin, t, e)
        ba = band_psd(tin, e_, constits, equi=True)

    else:
        ba = band_psd(t, e, constits,
                      equi=False, frqosamp=opt.lsfrqosmp)

    # power [ (e units)^2 ] from spectral density [ (e units)^2 / cph ]
    df = 1 / (elor * 24)  # inverse of record length in hours
    ba.Puu *= df
    Puu = np.zeros_like(constits)
    Pvv = Puv = None

    if opt.twodim:
        ba.Pvv *= df
        ba.Puv *= df
        Pvv = np.zeros_like(constits)
        Puv = np.zeros_like(constits)

    for i, (lo, hi) in enumerate(ba.fbnd):
        inside = (constits >= lo) & (constits <= hi)
        Puu[inside] = ba.Puu[i]
        if opt.twodim:
            Pvv[inside] = ba.Pvv[i]
            Puv[inside] = ba.Puv[i]
    return Puu, Pvv, Puv