Exemple #1
0
    def test_sum(self):
        grid = EclGrid.createRectangular((10, 10, 1), (1, 1, 1))
        kw_mask = EclKW("INT", grid.getGlobalSize(), EclDataType.ECL_INT)
        int_value = EclKW("INT", grid.getGlobalSize(), EclDataType.ECL_INT)
        float_value = EclKW("FLOAT", grid.getGlobalSize(),
                            EclDataType.ECL_FLOAT)
        double_value = EclKW("DOUBLE", grid.getGlobalSize(),
                             EclDataType.ECL_DOUBLE)
        bool_value = EclKW("BOOL", grid.getGlobalSize(), EclDataType.ECL_BOOL)

        kw_mask[0:50] = 1

        for i in range(len(int_value)):
            float_value[i] = i
            double_value[i] = i
            int_value[i] = i
            bool_value[i] = True

        region = EclRegion(grid, False)
        region.select_equal(kw_mask, 1)

        self.assertEqual(int_value.sum(), 99 * 100 / 2)
        self.assertEqual(int_value.sum(mask=region), 49 * 50 / 2)
        self.assertEqual(double_value.sum(mask=region), 1.0 * 49 * 50 / 2)
        self.assertEqual(float_value.sum(mask=region), 1.0 * 49 * 50 / 2)
        self.assertEqual(bool_value.sum(mask=region), 50)
Exemple #2
0
    def test_equal(self):
        grid = EclGrid.createRectangular((10, 10, 1), (1, 1, 1))
        kw_int = EclKW("INT", grid.getGlobalSize(), EclDataType.ECL_INT)
        kw_float = EclKW("FLOAT", grid.getGlobalSize(), EclDataType.ECL_FLOAT)

        kw_int[0:49] = 1
        region = EclRegion(grid, False)
        region.select_equal(kw_int, 1)
        glist = region.getGlobalList()
        for g in glist:
            self.assertEqual(kw_int[g], 1)

        with self.assertRaises(ValueError):
            region.select_equal(kw_float, 1)
Exemple #3
0
    pv = grid.compressed_kw_copy( init_file["PORV"][0] )

    # Extract an integer region keyword from the init file
    region_kw = init_file["EQLNUM"][0]


    sim_days = []
    result = {}
    for header in rst_file.headers():
        line = {}
        rst_block = rst_file.restart_view( report_step = header.get_report_step( ) )
        p = rst_block["PRESSURE"][0]
        sw = rst_block["SWAT"][0]


        for region_id in range(region_kw.get_max( ) + 1):
            region = EclRegion( grid, False )
            region.select_equal( region_kw, region_id )
            avg_pressure( p, sw, pv , region, region_id, result)

        avg_pressure( p, sw, pv , EclRegion( grid, True ), "field", result)
        sim_days.append( header.get_sim_days( ) )


    for key in result.keys():
        plt.figure(1)
        for index,p in enumerate(result[key]):
            plt.plot( sim_days, p , label="Region:%s  P%d" % (key, index + 1))
        plt.legend()
        plt.show()
Exemple #4
0
    init_file = EclFile("%s.INIT" % case)

    # Create PORV keyword where all the inactive cells have been removed.
    pv = grid.compressed_kw_copy(init_file["PORV"][0])

    # Extract an integer region keyword from the init file
    region_kw = init_file["EQLNUM"][0]

    sim_days = []
    result = {}
    for header in rst_file.headers():
        line = {}
        rst_block = rst_file.restart_view(report_step=header.get_report_step())
        p = rst_block["PRESSURE"][0]
        sw = rst_block["SWAT"][0]

        for region_id in range(region_kw.get_max() + 1):
            region = EclRegion(grid, False)
            region.select_equal(region_kw, region_id)
            avg_pressure(p, sw, pv, region, region_id, result)

        avg_pressure(p, sw, pv, EclRegion(grid, True), "field", result)
        sim_days.append(header.get_sim_days())

    for key in result.keys():
        plt.figure(1)
        for index, p in enumerate(result[key]):
            plt.plot(sim_days, p, label="Region:%s  P%d" % (key, index + 1))
        plt.legend()
        plt.show()