Ejemplo n.º 1
0
    def test_create(self):
        with self.assertRaises(IOError):
            s = Surface("File/does/not/exist")

        with self.assertRaises(ValueError):
            s = Surface(self.surface_short)

        with self.assertRaises(ValueError):
            s = Surface(self.surface_long)

        s = Surface(self.surface_valid)

        self.assertEqual(s.getNX(), 49)
        self.assertEqual(s.getNY(), 79)
        self.assertEqual(len(s), 49 * 79)

        with self.assertRaises(IndexError):
            v = s[49 * 79]

        with self.assertRaises(TypeError):
            v = s["KEY"]

        self.assertEqual(s[0], 0.0051)
        self.assertEqual(s[-1], -0.0014)

        with self.assertRaises(IndexError):
            s[49 * 79] = 787

        s[0] = 10
        self.assertEqual(s[0], 10)

        s[-1] = 77
        self.assertEqual(s[len(s) - 1], 77)
Ejemplo n.º 2
0
    def test_create_new(self):
        with self.assertRaises(ValueError):
            s = Surface(None, 1, 1, 1)
        with self.assertRaises(IOError):
            s = Surface(50, 1, 1, 1)

        # values copied from irap surface_small
        ny, nx = 20, 30
        xinc, yinc = 50.0, 50.0
        xstart, ystart = 463325.5625, 7336963.5
        angle = -65.0
        s_args = (None, nx, ny, xinc, yinc, xstart, ystart, angle)
        s = Surface(*s_args)
        self.assertEqual(ny * nx, len(s))
        self.assertEqual(nx, s.getNX())
        self.assertEqual(ny, s.getNY())
        small = Surface(self.surface_small)
        self.assertTrue(small.headerEqual(s))
        valid = Surface(self.surface_valid)
        self.assertFalse(valid.headerEqual(s))

        self.assertNotEqual(s, small)
        idx = 0
        for i in range(nx):
            for j in range(ny):
                s[idx] = small[idx]
                idx += 1
        self.assertEqual(s, small)
Ejemplo n.º 3
0
    def test_create(self):
        with self.assertRaises(IOError):
            s = Surface("File/does/not/exist")

        with self.assertRaises(ValueError):
            s = Surface(self.surface_short)

        with self.assertRaises(ValueError):
            s = Surface(self.surface_long)

        s = Surface( self.surface_valid )

        self.assertEqual( s.getNX( ) , 49 )
        self.assertEqual( s.getNY( ) , 79 )
        self.assertEqual( len(s) , 49*79 )

        with self.assertRaises(IndexError):
            v = s[49 * 79]

        with self.assertRaises(TypeError):
            v = s["KEY"]

        self.assertEqual( s[0]  ,  0.0051 )
        self.assertEqual( s[-1] , -0.0014 )

        with self.assertRaises(IndexError):
            s[49*79] = 787

        s[0] = 10
        self.assertEqual( s[0]  ,  10 )

        s[-1] = 77
        self.assertEqual( s[len(s) - 1]  ,  77 )
Ejemplo n.º 4
0
    def test_create_new(self):
        with self.assertRaises(ValueError):
            s = Surface(None, 1, 1, 1)
        with self.assertRaises(IOError):
            s = Surface(50, 1, 1, 1)

        # values copied from irap surface_small
        ny,nx = 20,30
        xinc,yinc = 50.0, 50.0
        xstart,ystart = 463325.5625, 7336963.5
        angle = -65.0
        s_args = (None, nx, ny, xinc, yinc, xstart, ystart, angle)
        s = Surface(*s_args)
        self.assertEqual(ny*nx, len(s))
        self.assertEqual(nx, s.getNX())
        self.assertEqual(ny, s.getNY())
        small = Surface (self.surface_small)
        self.assertTrue(small.headerEqual(s))
        valid = Surface (self.surface_valid)
        self.assertFalse(valid.headerEqual(s))

        self.assertNotEqual(s, small)
        idx = 0
        for i in range(nx):
            for j in range(ny):
                s[idx] = small[idx]
                idx += 1
        self.assertEqual(s, small)
Ejemplo n.º 5
0
def test_irap_surface(setUp):
    spec, actnum, parms = setUp
    grid = EclGridGenerator.createRectangular(
        dims=(2, 2, 2), dV=(100, 100, 100), actnum=actnum
    )

    # with TestAreaContext("test_irap_surface"):
    create_restart(grid, "TEST")
    create_init(grid, "TEST")
    grid.save_EGRID("TEST.EGRID")

    parms.velocity_model = "TEST.segy"
    create_segy_file(parms.velocity_model, spec)

    ots = OverburdenTimeshift(
        parms.eclbase,
        parms.mapaxes,
        parms.seabed,
        parms.youngs,
        parms.poisson,
        parms.rfactor,
        parms.convention,
        parms.above,
        parms.velocity_model,
    )

    f_name = "irap.txt"
    s = ots._create_surface()
    s.write(f_name)
    s = Surface(f_name)

    assert s.getNX() == 2
    assert s.getNY() == 2

    for val in s:
        assert val == 90
Ejemplo n.º 6
0
def test_ots_config_run_parameters(ots_tmpdir_enter, res_scale, size_scale,
                                   pos_shift, results, surf_res):
    eclcase_dir = ots_tmpdir_enter
    grid_file = os.path.join(eclcase_dir, "NORNE_ATW2013.EGRID")
    grid = EclGrid(grid_file, apply_mapaxes=True)

    mock_segy(grid, res_scale, size_scale, pos_shift, "norne_vol.segy")

    conf = {
        "eclbase": os.path.join(eclcase_dir, "NORNE_ATW2013"),
        "above": 100,
        "seabed": 300,
        "youngs": 0.5,
        "poisson": 0.3,
        "rfactor": 20,
        "mapaxes": False,
        "convention": 1,
        "output_dir": "ts",
        "horizon": "horizon.irap",
        "ascii": "ts.txt",
        "velocity_model": "norne_vol.segy",
        "vintages": {
            "ts_simple": [["1997-11-06", "1998-02-01"],
                          ["1997-12-17", "1998-01-01"]],
            "dpv": [["1997-11-06", "1997-12-17"]],
        },
    }
    with open("ots_config.yml", "w") as f:
        yaml.dump(conf, f, default_flow_style=False)
    ots_run("ots_config.yml")

    # test results
    # 1. we compare the surface resolution
    # 2. we test sum of output surface heightfields for
    #   2a. top left and bottom right corners (which is due to shift segy volume)
    #   2b. we expect the surface to drop with each timeshift
    def to_numpy(surf):
        arr = np.array([surf[i]
                        for i in range(len(surf))]).reshape(-1, surf.getNX())
        return arr

    # horizon
    s_horizon = Surface("horizon.irap")
    assert surf_res[0] == s_horizon.getNX()
    assert surf_res[1] == s_horizon.getNY()
    assert (s_horizon.getNX() > grid.getNY()) == results[-1]
    assert (s_horizon.getNY() > grid.getNX()) == results[-1]

    _err = 0.01
    nx = s_horizon.getNX()
    ny = s_horizon.getNY()
    arr = to_numpy(s_horizon)
    sh_top_left = arr[:ny // 2 - 1, :nx // 2 - 1].sum()
    sh_bottom_right = arr[ny // 2:, nx // 2:].sum()
    assert ((sh_top_left - _err) > 0) == results[0]
    assert ((sh_bottom_right - _err) > 0) == results[1]

    # ts_simple1
    ts_simple1 = Surface("ts_ts_simple/ots_1997_11_06_1998_02_01.irap")
    assert nx == ts_simple1.getNX()
    assert ny == ts_simple1.getNY()
    assert (ts_simple1.getNX() > grid.getNY()) == results[-1]
    assert (ts_simple1.getNY() > grid.getNX()) == results[-1]

    arr = to_numpy(ts_simple1)
    ts1_top_left = arr[:ny // 2 - 1, :nx // 2 - 1].sum()
    ts1_bottom_right = arr[ny // 2:, nx // 2:].sum()
    assert ((ts1_top_left - _err) > 0) == results[0]
    assert ((ts1_bottom_right - _err) > 0) == results[1]
    assert ts1_top_left + ts1_bottom_right < sh_top_left + sh_bottom_right

    # ts_simple2
    ts_simple2 = Surface("ts_ts_simple/ots_1997_12_17_1998_01_01.irap")
    assert nx == ts_simple2.getNX()
    assert ny == ts_simple2.getNY()
    assert (ts_simple2.getNX() > grid.getNY()) == results[-1]
    assert (ts_simple2.getNY() > grid.getNX()) == results[-1]

    arr = to_numpy(ts_simple2)
    ts2_top_left = arr[:ny // 2 - 1, :nx // 2 - 1].sum()
    ts2_bottom_right = arr[ny // 2:, nx // 2:].sum()
    assert ((ts2_top_left - _err) > 0) == results[0]
    assert ((ts2_bottom_right - _err) > 0) == results[1]
    assert ts2_top_left + ts2_bottom_right < sh_top_left + sh_bottom_right
    assert ts2_top_left + ts2_bottom_right < ts1_top_left + ts1_bottom_right

    # ts_dpv
    ts_dpv = Surface("ts_dpv/ots_1997_11_06_1997_12_17.irap")
    assert nx == ts_dpv.getNX()
    assert ny == ts_dpv.getNY()
    assert (ts_dpv.getNX() > grid.getNY()) == results[-1]
    assert (ts_dpv.getNY() > grid.getNX()) == results[-1]

    arr = to_numpy(ts_simple2)
    dpv_top_left = arr[:ny // 2 - 1, :nx // 2 - 1].sum()
    dpv_bottom_right = arr[ny // 2:, nx // 2:].sum()
    assert ((dpv_top_left - _err) > 0) == results[0]
    assert ((dpv_bottom_right - _err) > 0) == results[1]
    assert dpv_top_left + dpv_bottom_right < sh_top_left + sh_bottom_right