Exemple #1
0
def spectra(M, Rrup, Rhyp, eventType, Z, Faba, Vs30, periods):
    periods = np.array(periods)
    idx = np.nonzero(periods <= 0.01)[0]
    periods[idx] = 0.01 # Periods less than eq to 0.01 are essentially pga. Setting this allows us to avoid errors while interpolating in log-log scale.
    augmentedPeriods = augmentPeriods(periods)

    # compute R based on event type
    R = [rrup if ev == 0 else rhyp for rrup, rhyp, ev in itertools.izip(Rrup, Rhyp, eventType)]

    nRow = len(M)
    nCol = len(augmentedPeriods)

    M = np.array([M] * nCol).transpose()
    R = np.array([R] * nCol).transpose()
    eventType = np.array([eventType] * nCol).transpose()
    Z = np.array([Z] * nCol).transpose()
    Faba = np.array([Faba] * nCol).transpose()
    Vs30 = np.array([Vs30] * nCol).transpose()
    augmentedPeriods = np.array([augmentedPeriods] * nRow)

    augmentedSpectra = np.array([[model.computeSpectra(mag, r, evt, z, faba, vs, per) for mag, r, evt, z, faba, vs, per in itertools.izip(mags, rs, evts, zs, fabas, vss, pers)] for mags, rs, evts, zs, fabas, vss, pers in itertools.izip(M, R, eventType, Z, Faba, Vs30, augmentedPeriods)])

    fixedSpectra = fixPeriods(augmentedSpectra, periods, augmentedPeriods[0])

    intraEventSigma = np.ones(fixedSpectra.shape) * model.intraEventSigma()
    interEventSigma = np.ones(fixedSpectra.shape) * model.interEventSigma()

    return (np.exp(fixedSpectra)).tolist(), intraEventSigma.tolist(), interEventSigma.tolist()
Exemple #2
0
def spectra(M, Rrup, Faba, Vs30, cascadia, epistemic, periods):
    periods = np.array(periods)
    idx = np.nonzero(periods <= 0.01)[0]
    periods[
        idx
    ] = (
        0.01
    )  # Periods less than eq to 0.01 are essentially pga. Setting this allows us to avoid errors while interpolating in log-log scale.
    augmentedPeriods = augmentPeriods(periods)

    R = Rrup
    nRow = len(M)
    nCol = len(augmentedPeriods)

    M = np.array([M] * nCol).transpose()
    R = np.array([R] * nCol).transpose()
    Faba = np.array([Faba] * nCol).transpose()
    Vs30 = np.array([Vs30] * nCol).transpose()
    cascadia = np.array([cascadia] * nCol).transpose()

    augmentedPeriods = np.array([augmentedPeriods] * nRow)

    augmentedSpectra = np.array(
        [
            [
                model.computeSpectra(mag, r, faba, vs, cas, epistemic, per)
                for mag, r, faba, vs, cas, per in itertools.izip(mags, rs, fabas, vss, cass, pers)
            ]
            for mags, rs, fabas, vss, cass, pers in itertools.izip(M, R, Faba, Vs30, cascadia, augmentedPeriods)
        ]
    )

    fixedSpectra = fixPeriods(augmentedSpectra, periods, augmentedPeriods[0])

    # convert to cm/s/s
    fixedSpectra = 10 ** fixedSpectra

    intraEventSigma = model.intraEventSigma(periods) * nRow
    interEventSigma = model.interEventSigma(periods) * nRow

    return fixedSpectra.tolist(), intraEventSigma, interEventSigma
Exemple #3
0
def spectra(M, Rrup, Rhyp, eventType, Z, Faba, Vs30, periods):
    periods = np.array(periods)
    idx = np.nonzero(periods <= 0.01)[0]
    periods[
        idx] = 0.01  # Periods less than eq to 0.01 are essentially pga. Setting this allows us to avoid errors while interpolating in log-log scale.
    augmentedPeriods = augmentPeriods(periods)

    # compute R based on event type
    R = [
        rrup if ev == 0 else rhyp
        for rrup, rhyp, ev in itertools.izip(Rrup, Rhyp, eventType)
    ]

    nRow = len(M)
    nCol = len(augmentedPeriods)

    M = np.array([M] * nCol).transpose()
    R = np.array([R] * nCol).transpose()
    eventType = np.array([eventType] * nCol).transpose()
    Z = np.array([Z] * nCol).transpose()
    Faba = np.array([Faba] * nCol).transpose()
    Vs30 = np.array([Vs30] * nCol).transpose()
    augmentedPeriods = np.array([augmentedPeriods] * nRow)

    augmentedSpectra = np.array([[
        model.computeSpectra(mag, r, evt, z, faba, vs, per)
        for mag, r, evt, z, faba, vs, per in itertools.izip(
            mags, rs, evts, zs, fabas, vss, pers)
    ] for mags, rs, evts, zs, fabas, vss, pers in itertools.izip(
        M, R, eventType, Z, Faba, Vs30, augmentedPeriods)])

    fixedSpectra = fixPeriods(augmentedSpectra, periods, augmentedPeriods[0])

    intraEventSigma = np.ones(fixedSpectra.shape) * model.intraEventSigma()
    interEventSigma = np.ones(fixedSpectra.shape) * model.interEventSigma()

    return (np.exp(fixedSpectra)
            ).tolist(), intraEventSigma.tolist(), interEventSigma.tolist()