示例#1
0
    def test_get_response_spectrum_1(self):
        """
        """
        tgt_rdis_rs, tgt_rvel_rs, tgt_aacc_rs, tgt_pvel_rs = read_spc(
            os.path.join(DATA_DIR, '004676xa.spc'))[2]
        periods = tgt_rdis_rs.periods
        cal_rdis_rs = self.acc.get_response_spectrum(
            periods, damping=0.05, gmt='dis')
        cal_rvel_rs = self.acc.get_response_spectrum(
            periods, damping=0.05, gmt='vel')
        cal_aacc_rs = self.acc.get_response_spectrum(
            periods, damping=0.05, gmt='acc')
        cal_pvel_rs = ResponseSpectrum(periods,
            cal_rdis_rs.responses * 2*np.pi/periods, unit='m/s', damping=0.05)

        labels, colors, widths = ['tgt', 'cal'], ['r', 'b'], [3, 1]

        fs1 = os.path.join(OUTPUT_DIR,
            'recordings.accelerogram.get_response_spectrum.1.rdis.png')
        fs2 = os.path.join(OUTPUT_DIR,
            'recordings.accelerogram.get_response_spectrum.1.rvel.png')
        fs3 = os.path.join(OUTPUT_DIR,
            'recordings.accelerogram.get_response_spectrum.1.aacc.png')
        fs4 = os.path.join(OUTPUT_DIR,
            'recordings.accelerogram.get_response_spectrum.1.pvel.png')
        plot_response_spectra([tgt_rdis_rs, cal_rdis_rs],
            labels=labels, colors=colors, widths=widths, filespec=fs1)
        plot_response_spectra([tgt_rvel_rs, cal_rvel_rs],
            labels=labels, colors=colors, widths=widths, filespec=fs2)
        plot_response_spectra([tgt_aacc_rs, cal_aacc_rs],
            labels=labels, colors=colors, widths=widths, filespec=fs3)
        plot_response_spectra([tgt_pvel_rs, cal_pvel_rs],
            labels=labels, colors=colors, widths=widths, filespec=fs4)
示例#2
0
 def test_get_response_spectrum(self):
     """
     """
     acc = read_cor(os.path.join(DATA_DIR, '004676xa.cor'))[-1]
     acc = Accelerogram.from_seismogram(acc)
     periods = np.logspace(-2, 2, 200)
     cal_rdis_rs = acc.get_response_spectrum(periods, damping=0.05, gmt='dis')
     cal_rvel_rs = acc.get_response_spectrum(periods, damping=0.05, gmt='vel')
     cal_aacc_rs = acc.get_response_spectrum(periods, damping=0.05, gmt='acc')
     cal_pvel_rs = ResponseSpectrum(periods,
         cal_rdis_rs.responses * (2*np.pi/periods), unit='m/s', damping=0.05)
     tgt_rss = read_spc(os.path.join(DATA_DIR, '004676xa.spc'))[2]
     tgt_rdis_rs, tgt_rvel_rs, tgt_aacc_rs, tgt_pvel_rs = tgt_rss
     fs1 = os.path.join(FIG_DIR, 'response_spectrum_rdis.png')
     fs2 = os.path.join(FIG_DIR, 'response_spectrum_rvel.png')
     fs3 = os.path.join(FIG_DIR, 'response_spectrum_aacc.png')
     fs4 = os.path.join(FIG_DIR, 'response_spectrum_pvel.png')
     plot.response_spectra([tgt_rdis_rs, cal_rdis_rs], png_filespec=fs1)
     plot.response_spectra([tgt_rvel_rs, cal_rvel_rs], png_filespec=fs2)
     plot.response_spectra([tgt_aacc_rs, cal_aacc_rs], png_filespec=fs3)
     plot.response_spectra([tgt_pvel_rs, cal_pvel_rs], png_filespec=fs4)
示例#3
0
 def test_get_response_spectrum_1(self):
     """
     """
     tgt_rss = read_spc(os.path.join(DATA_DIR, '004676xa.spc'))[2]
     tgt_rdis_rs, tgt_rvel_rs, tgt_aacc_rs, tgt_pvel_rs = tgt_rss
     periods = tgt_rdis_rs.periods
     cal_rdis_rs = self.acc.get_response_spectrum(periods, damping=0.05, gmt='dis')
     cal_rvel_rs = self.acc.get_response_spectrum(periods, damping=0.05, gmt='vel')
     cal_aacc_rs = self.acc.get_response_spectrum(periods, damping=0.05, gmt='acc')
     cal_pvel_rs = ResponseSpectrum(periods,
         cal_rdis_rs.responses * (2*np.pi/periods), unit='m/s', damping=0.05)
     labels = ['tgt', 'cal']
     colors = ['r', 'b']
     widths = [2, 0.5]
     fs1 = os.path.join(FIG_DIR, 'recordings.accelerogram.get_response_spectrum.1.rdis.png')
     fs2 = os.path.join(FIG_DIR, 'recordings.accelerogram.get_response_spectrum.1.rvel.png')
     fs3 = os.path.join(FIG_DIR, 'recordings.accelerogram.get_response_spectrum.1.aacc.png')
     fs4 = os.path.join(FIG_DIR, 'recordings.accelerogram.get_response_spectrum.1.pvel.png')
     plot.response_spectra([tgt_rdis_rs, cal_rdis_rs], labels=labels, colors=colors, widths=widths, png_filespec=fs1)
     plot.response_spectra([tgt_rvel_rs, cal_rvel_rs], labels=labels, colors=colors, widths=widths, png_filespec=fs2)
     plot.response_spectra([tgt_aacc_rs, cal_aacc_rs], labels=labels, colors=colors, widths=widths, png_filespec=fs3)
     plot.response_spectra([tgt_pvel_rs, cal_pvel_rs], labels=labels, colors=colors, widths=widths, png_filespec=fs4)
示例#4
0
    def test_read_spc(self):
        """
        """
        rs = read_spc(os.path.join(DATA_DIR, '004676xa.spc'))

        f_ps = np.array([4.000E-02, 4.200E-02, 4.400E-02])
        l_ps = np.array([2.300E+00, 2.400E+00, 2.500E+00])
        f_rs = [
            [
                [1.210E-03, 8.940E-04, 7.670E-04],
                [1.730E-01, 1.330E-01, 1.150E-01],
                [2.470E+01, 2.000E+01, 1.890E+01],
                [1.728E-01, 1.337E-01, 1.205E-01],
            ],
            [
                [5.350E-04, 3.890E-04, 2.940E-04],
                [7.120E-02, 5.170E-02, 3.290E-02],
                [1.090E+01, 8.730E+00, 7.250E+00],
                [7.640E-02, 5.819E-02, 4.618E-02],
            ],
            [
                [3.580E-04, 3.000E-04, 2.640E-04],
                [4.690E-02, 3.800E-02, 2.780E-02],
                [7.280E+00, 6.720E+00, 6.500E+00],
                [5.112E-02, 4.488E-02, 4.147E-02],
            ],
            [
                [2.850E-04, 2.560E-04, 2.360E-04],
                [3.250E-02, 2.850E-02, 2.390E-02],
                [5.880E+00, 5.800E+00, 5.840E+00],
                [4.070E-02, 3.830E-02, 3.707E-02],
            ],
            [
                [2.520E-04, 2.290E-04, 2.070E-04],
                [2.080E-02, 1.960E-02, 1.780E-02],
                [5.280E+00, 5.250E+00, 5.250E+00],
                [3.599E-02, 3.426E-02, 3.252E-02],
            ],
        ]
        l_rs = [
            [
                [8.660E-02, 9.550E-02, 1.020E-01],
                [2.800E-01, 3.100E-01, 3.260E-01],
                [5.470E-01, 6.550E-01, 7.620E-01],
                [2.176E-01, 2.500E-01, 2.786E-01],
            ],
            [
                [7.770E-02, 8.530E-02, 9.080E-02],
                [2.660E-01, 2.880E-01, 2.990E-01],
                [4.910E-01, 5.850E-01, 6.780E-01],
                [1.953E-01, 2.233E-01, 2.480E-01],
            ],
            [
                [6.740E-02, 7.310E-02, 7.740E-02],
                [2.460E-01, 2.600E-01, 2.660E-01],
                [4.310E-01, 5.050E-01, 5.820E-01],
                [1.694E-01, 1.914E-01, 2.114E-01],
            ],
            [
                [5.750E-02, 5.880E-02, 6.160E-02],
                [2.170E-01, 2.240E-01, 2.250E-01],
                [3.830E-01, 4.160E-01, 4.720E-01],
                [1.445E-01, 1.539E-01, 1.683E-01],
            ],
            [
                [4.470E-02, 4.350E-02, 4.290E-02],
                [1.740E-01, 1.740E-01, 1.710E-01],
                [3.250E-01, 3.380E-01, 3.700E-01],
                [1.123E-01, 1.139E-01, 1.172E-01],
            ],
        ]
        gmts = ('dis', 'vel', 'acc', 'vel')
        dampings = [0., 0.02, 0.05, 0.1, 0.2]
        self.assertEqual(len(rs), 5)
        for i, rs_per_d in enumerate(rs):
            self.assertEqual(len(rs_per_d), 4)
            for j, r in enumerate(rs_per_d):
                self.assertListEqual(list(r.periods[:+3]), list(f_ps))
                self.assertListEqual(list(r.periods[-3:]), list(l_ps))
                self.assertListEqual(list(r.responses[:+3]), f_rs[i][j][::-1])
                self.assertListEqual(list(r.responses[-3:]), l_rs[i][j][::-1])
                self.assertEqual(r.unit, UNITS[gmts[j]])
                self.assertEqual(r.damping, dampings[i])
示例#5
0
    def test_read_spc(self):
        """
        """
        rs = read_spc(os.path.join(DATA_DIR, '004676xa.spc'))

        f_ps = np.array([4.000E-02, 4.200E-02, 4.400E-02])
        l_ps = np.array([2.300E+00, 2.400E+00, 2.500E+00])
        f_rs = [
            [
                [1.210E-03, 8.940E-04, 7.670E-04],
                [1.730E-01, 1.330E-01, 1.150E-01],
                [2.470E+01, 2.000E+01, 1.890E+01],
                [1.728E-01, 1.337E-01, 1.205E-01],
            ],
            [
                [5.350E-04, 3.890E-04, 2.940E-04],
                [7.120E-02, 5.170E-02, 3.290E-02],
                [1.090E+01, 8.730E+00, 7.250E+00],
                [7.640E-02, 5.819E-02, 4.618E-02],
            ],
            [
                [3.580E-04, 3.000E-04, 2.640E-04],
                [4.690E-02, 3.800E-02, 2.780E-02],
                [7.280E+00, 6.720E+00, 6.500E+00],
                [5.112E-02, 4.488E-02, 4.147E-02],
            ],
            [
                [2.850E-04, 2.560E-04, 2.360E-04],
                [3.250E-02, 2.850E-02, 2.390E-02],
                [5.880E+00, 5.800E+00, 5.840E+00],
                [4.070E-02, 3.830E-02, 3.707E-02],
            ],
            [
                [2.520E-04, 2.290E-04, 2.070E-04],
                [2.080E-02, 1.960E-02, 1.780E-02],
                [5.280E+00, 5.250E+00, 5.250E+00],
                [3.599E-02, 3.426E-02, 3.252E-02],
            ],
        ]
        l_rs = [
            [
                [8.660E-02, 9.550E-02, 1.020E-01],
                [2.800E-01, 3.100E-01, 3.260E-01],
                [5.470E-01, 6.550E-01, 7.620E-01],
                [2.176E-01, 2.500E-01, 2.786E-01],
            ],
            [
                [7.770E-02, 8.530E-02, 9.080E-02],
                [2.660E-01, 2.880E-01, 2.990E-01],
                [4.910E-01, 5.850E-01, 6.780E-01],
                [1.953E-01, 2.233E-01, 2.480E-01],
            ],
            [
                [6.740E-02, 7.310E-02, 7.740E-02],
                [2.460E-01, 2.600E-01, 2.660E-01],
                [4.310E-01, 5.050E-01, 5.820E-01],
                [1.694E-01, 1.914E-01, 2.114E-01],
            ],
            [
                [5.750E-02, 5.880E-02, 6.160E-02],
                [2.170E-01, 2.240E-01, 2.250E-01],
                [3.830E-01, 4.160E-01, 4.720E-01],
                [1.445E-01, 1.539E-01, 1.683E-01],
            ],
            [
                [4.470E-02, 4.350E-02, 4.290E-02],
                [1.740E-01, 1.740E-01, 1.710E-01],
                [3.250E-01, 3.380E-01, 3.700E-01],
                [1.123E-01, 1.139E-01, 1.172E-01],
            ],
        ]
        gmts = ('dis', 'vel', 'acc', 'vel')
        dampings = [0., 0.02, 0.05, 0.1, 0.2]
        self.assertEqual(len(rs), 5)
        for i, rs_per_d in enumerate(rs):
            self.assertEqual(len(rs_per_d), 4)
            for j, r in enumerate(rs_per_d):
                self.assertListEqual(list(r.periods[:+3]), list(f_ps))
                self.assertListEqual(list(r.periods[-3:]), list(l_ps))
                self.assertListEqual(list(r.responses[:+3]), f_rs[i][j][::-1])
                self.assertListEqual(list(r.responses[-3:]), l_rs[i][j][::-1])
                self.assertEqual(r.unit, UNITS[gmts[j]])
                self.assertEqual(r.damping, dampings[i])