示例#1
0
    def test_contains_time(self):
        start = datetime.datetime(2010, 1, 1, 0, 0, 0)
        end = datetime.datetime(2010, 2, 1, 0, 0, 0)
        other = datetime.datetime(2010, 1, 15, 0, 0, 0)

        tv = TimeVector()
        tv.append(start)
        tv.append(end)

        self.assertTrue(start in tv)
        self.assertTrue(end in tv)
        self.assertTrue(other not in tv)
示例#2
0
    def test_time_vector(self):
        time_vector = TimeVector()

        time1 = CTime(datetime.datetime(2013, 8, 13, 0, 0, 0))
        time2 = CTime(datetime.datetime(2013, 8, 13, 1, 0, 0))

        time_vector.setDefault(time2)

        time_vector.append(time1)
        time_vector[2] = time2

        self.assertEqual(time_vector[0], time1)
        self.assertEqual(time_vector[1], time2)
        self.assertEqual(time_vector[2], time2)

        tv1 = TimeVector(default_value=datetime.date(2000, 1, 1),
                         initial_size=2)
        self.assertEqual(tv1[0], datetime.date(2000, 1, 1))

        tv2 = TimeVector()
        tv2.append(time2)
        print(tv2)
示例#3
0
    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))