def test_read_fas_model(self): """ """ fass = read_fas_model( os.path.join(DATA_DIR, 'ab06_bc.m7.50r0030.0_fs.col')) fas = fass[0] self.assertEqual(len(fass), 3) self.assertEqual(fas.frequencies[0], 1.000E-02) self.assertEqual(fas.frequencies[1], 1.207E-02) self.assertEqual(fas.frequencies[-2], 8.286E+01) self.assertEqual(fas.frequencies[-1], 1.000E+02) self.assertEqual(fas.amplitudes[0], 1.03981E+02) self.assertEqual(fas.amplitudes[1], 1.03546E+02) self.assertEqual(fas.amplitudes[-2], 9.67976E-07) self.assertEqual(fas.amplitudes[-1], 2.09392E-07) self.assertEqual(fas.unit, 'cm')
def test(self): """ """ tgt_fas = read_fas_model(os.path.join(DATA_DIR, 'ab06_bc.m7.50r0030.0_fs.col'))[0] frequencies = tgt_fas.frequencies mag = 7.5 sd = 250 * 10**5 ## magnitude independent stress drop (Pa) rp = 0.55 ## radiation patttern pf = 1 / np.sqrt(2) ## partition factor fsf = 2 ## free surface factor rho = 2800 ## density (kg/m3) vel = 3700 ## shear wave velocity (m/s) source_model = OmegaSquareSourceModel(mag, sd, rp, pf, fsf, rho, vel) source_model_fas = source_model.get_fas(frequencies) gs_segments = [ (1, -1.3), (70, 0.2), (140, -0.5) ] gs_model = GeometricalSpreadingModel(gs_segments) qr1 = 1000 ft1 = 0.2 fr1 = 0.02 s1 = 0.0 qr2 = 1272 ft2 = 1.4242 fr2 = 3.02 s2 = 0.32 q_model = QModel(fr1, qr1, s1, ft1, ft2, fr2, qr2, s2) c_q = 3.7 kappa = 0.02 ## fm is zero and kappa is magnitude independent att_model = AttenuationModel(q_model, c_q, kappa) distance = 30 se = np.array([ (0.0001, 1.000), (0.1014, 1.073), (0.2402, 1.145), (0.4468, 1.237), (0.7865, 1.394), (1.3840, 1.672), (1.9260, 1.884), (2.8530, 2.079), (4.0260, 2.202), (6.3410, 2.313), (12.540, 2.411), (21.230, 2.452), (33.390, 2.474), (82.000, 2.497), ]) site = Site(se) cal_fas = source_model_fas * gs_model(distance) * att_model(distance, frequencies) * site(frequencies) unit = 'm' self.assertListEqual( [round_to_significant(float(x), 2) for x in tgt_fas.get_amplitudes(unit=unit)], [round_to_significant(float(x), 2) for x in cal_fas.get_amplitudes(unit=unit)])