コード例 #1
0
ファイル: test_sum_equinor.py プロジェクト: trhallam/ecl
    def test_resample(self):
        time_points = TimeVector()
        start_time = self.ecl_sum.get_data_start_time()
        end_time = self.ecl_sum.get_end_time()
        delta = end_time - start_time
        N = 25
        time_points.initRange(
            CTime(start_time),
            CTime(end_time),
            CTime(int(delta.total_seconds() / (N - 1))),
        )
        time_points.append(CTime(end_time))
        resampled = self.ecl_sum.resample("OUTPUT_CASE", time_points)

        for key in self.ecl_sum.keys():
            self.assertIn(key, resampled)

        self.assertEqual(
            self.ecl_sum.get_data_start_time(), resampled.get_data_start_time()
        )
        delta = self.ecl_sum.get_end_time() - resampled.get_end_time()
        self.assertTrue(delta.total_seconds() <= 1)

        keys = ["FOPT", "FOPR", "BPR:15,28,1", "WGOR:OP_1"]
        for key in keys:
            for time_index, t in enumerate(time_points):
                self.assertFloatEqual(
                    resampled.iget(key, time_index),
                    self.ecl_sum.get_interp_direct(key, t),
                )
コード例 #2
0
    def test_resample_extrapolate(self):
        """
        Test resampling of summary with extrapolate option of lower and upper boundaries enabled
        """
        from ecl.util.util import TimeVector, CTime

        time_points = TimeVector()

        path = os.path.join(self.TESTDATA_ROOT,
                            "local/ECLIPSE/cp_simple3/SIMPLE_SUMMARY3")
        ecl_sum = EclSum(path, lazy_load=True)

        start_time = ecl_sum.get_data_start_time() - datetime.timedelta(
            seconds=86400)
        end_time = ecl_sum.get_end_time() + datetime.timedelta(seconds=86400)
        delta = end_time - start_time

        N = 25
        time_points.initRange(CTime(start_time), CTime(end_time),
                              CTime(int(delta.total_seconds() / (N - 1))))
        time_points.append(CTime(end_time))
        resampled = ecl_sum.resample("OUTPUT_CASE",
                                     time_points,
                                     lower_extrapolation=True,
                                     upper_extrapolation=True)

        for key in ecl_sum.keys():
            self.assertIn(key, resampled)

        self.assertEqual(
            ecl_sum.get_data_start_time() - datetime.timedelta(seconds=86400),
            resampled.get_data_start_time())

        key_not_rate = "FOPT"
        for time_index, t in enumerate(time_points):
            if t < ecl_sum.get_data_start_time():
                self.assertFloatEqual(resampled.iget(key_not_rate, time_index),
                                      ecl_sum._get_first_value(key_not_rate))
            elif t > ecl_sum.get_end_time():
                self.assertFloatEqual(resampled.iget(key_not_rate, time_index),
                                      ecl_sum.get_last_value(key_not_rate))
            else:
                self.assertFloatEqual(
                    resampled.iget(key_not_rate, time_index),
                    ecl_sum.get_interp_direct(key_not_rate, t))

        key_rate = "FOPR"
        for time_index, t in enumerate(time_points):
            if t < ecl_sum.get_data_start_time():
                self.assertFloatEqual(resampled.iget(key_rate, time_index), 0)
            elif t > ecl_sum.get_end_time():
                self.assertFloatEqual(resampled.iget(key_rate, time_index), 0)
            else:
                self.assertFloatEqual(resampled.iget(key_rate, time_index),
                                      ecl_sum.get_interp_direct(key_rate, t))
コード例 #3
0
ファイル: test_sum_statoil.py プロジェクト: OPM/ResInsight
    def test_resample(self):
        time_points = TimeVector()
        start_time = self.ecl_sum.get_data_start_time()
        end_time = self.ecl_sum.get_end_time()
        delta = end_time - start_time
        N = 25
        time_points.initRange( CTime(start_time),
                               CTime(end_time),
                               CTime(int(delta.total_seconds()/(N - 1))))
        time_points.append(CTime(end_time))
        resampled = self.ecl_sum.resample( "OUTPUT_CASE", time_points )

        for key in self.ecl_sum.keys():
            self.assertIn( key, resampled )

        self.assertEqual(self.ecl_sum.get_data_start_time(), resampled.get_data_start_time())
        delta = self.ecl_sum.get_end_time() - resampled.get_end_time()
        self.assertTrue( delta.total_seconds() <= 1 )

        keys = ["FOPT", "FOPR", "BPR:15,28,1", "WGOR:OP_1"]
        for key in keys:
            for time_index,t in enumerate(time_points):
                self.assertFloatEqual(resampled.iget( key, time_index), self.ecl_sum.get_interp_direct( key, t))