Ejemplo n.º 1
0
    def test_fit(self):
        # Case 1: users only have Vs profile
        vs_profile = Vs_Profile('./files/profile_FKSH14.txt')
        hh_c = HH_Calibration(vs_profile)
        HH_G_param = hh_c.fit(verbose=False)
        HH_G_param_benchmark = HH_Param_Multi_Layer('./files/HH_G_FKSH14.txt')
        self.assertTrue(
            np.allclose(HH_G_param.serialize_to_2D_array(),
                        HH_G_param_benchmark.serialize_to_2D_array(),
                        rtol=1e-5,
                        atol=0.0))

        # Case 2: users have both Vs profile and G/Gmax curves
        curves = Multiple_GGmax_Curves('./files/curve_FKSH14.txt')
        hh_c = HH_Calibration(vs_profile, GGmax_curves=curves)
        HH_G_param = hh_c.fit(verbose=False)
        HH_G_benchmark_data \
            = np.array([[0.0003, 0.0001, 0.0001, 0.0001, 0.0001],
                        [100, 100, 100, 100, 100],
                        [0.000285072, 0.000516205, 0.000944545, 0.00129825, 0.00144835],
                        [1.75224, 1.71444, 1.64057, 1.58664, 1.56314],
                        [0.918975, 0.919001, 0.918973, 0.919007, 0.918999],
                        [2.11104e+07, 6.859e+07, 1.4896e+08, 2.25441e+09, 3.28398e+09],
                        [0.233357, 0.199149, 0.253784, 1, 1],
                        [26501, 64856.6, 148805, 804855, 1.10785e+06],
                        [0.937739, 0.850905, 0.861759, 0.984774, 0.981156]])
        HH_G_param_benchmark = HH_Param_Multi_Layer(HH_G_benchmark_data)
        self.assertTrue(
            np.allclose(HH_G_param.serialize_to_2D_array(),
                        HH_G_param_benchmark.serialize_to_2D_array(),
                        rtol=1e-2,
                        atol=0.0))
 def test_fit__case_1_with_only_Vs_profile(self):
     vs_profile = Vs_Profile(_join(f_dir, 'profile_FKSH14.txt'))
     hh_c = HH_Calibration(vs_profile)
     HH_G_param = hh_c.fit(verbose=False)
     HH_G_param_benchmark = HH_Param_Multi_Layer(
         _join(f_dir, 'HH_G_FKSH14.txt'))
     self.assertTrue(
         np.allclose(HH_G_param.serialize_to_2D_array(),
                     HH_G_param_benchmark.serialize_to_2D_array(),
                     rtol=1e-5,
                     atol=0.0))