Exemple #1
0
def test_roffbin_banal6():
    """Test roff binary for banal no. 6 case"""

    grd1 = Grid()
    grd1.from_file(BANAL6)

    grd2 = Grid()
    grd2.from_file(BANAL6, _xtgformat=2)

    assert grd1.get_xyz_cell_corners() == grd2.get_xyz_cell_corners()

    assert grd1.get_xyz_cell_corners((4, 2, 3)) == grd2.get_xyz_cell_corners(
        (4, 2, 3))

    grd2._convert_xtgformat2to1()

    assert grd1.get_xyz_cell_corners((4, 2, 3)) == grd2.get_xyz_cell_corners(
        (4, 2, 3))
Exemple #2
0
def test_roffbin_import_v2_banal():
    """Test roff binary import ROFF using new API, banal case"""

    t0 = xtg.timer()
    grd1 = Grid()
    grd1._xtgformat = 1
    grd1.from_file(BANAL6)
    print("V1: ", xtg.timer(t0))

    t0 = xtg.timer()

    grd2 = Grid()
    grd2._xtgformat = 2
    grd2.from_file(BANAL6)
    print("V2: ", xtg.timer(t0))

    t0 = xtg.timer()
    grd3 = Grid()
    grd3._xtgformat = 2
    grd3.from_file(BANAL6)
    grd3._convert_xtgformat2to1()
    print("V3: ", xtg.timer(t0))

    t0 = xtg.timer()
    grd4 = Grid()
    grd4._xtgformat = 1
    grd4.from_file(BANAL6)
    grd4._convert_xtgformat1to2()
    print("V4: ", xtg.timer(t0))

    for irange in range(grd1.ncol):
        for jrange in range(grd1.nrow):
            for krange in range(grd1.nlay):
                cell = (irange + 1, jrange + 1, krange + 1)

                xx1 = grd1.get_xyz_cell_corners(cell, activeonly=False)
                xx2 = grd2.get_xyz_cell_corners(cell, activeonly=False)
                xx3 = grd3.get_xyz_cell_corners(cell, activeonly=False)
                xx4 = grd4.get_xyz_cell_corners(cell, activeonly=False)

                assert np.allclose(np.array(xx1), np.array(xx2)) is True
                assert np.allclose(np.array(xx1), np.array(xx3)) is True
                assert np.allclose(np.array(xx1), np.array(xx4)) is True
Exemple #3
0
def test_roffbin_bigbox(tmpdir):
    """Test roff binary for bigbox, to monitor performance"""

    bigbox = os.path.join(tmpdir, "bigbox.roff")
    if not os.path.exists(bigbox):
        logger.info("Create tmp big roff grid file...")
        grd0 = Grid()
        grd0.create_box(dimension=(500, 500, 100))
        grd0.to_file(bigbox)

    grd1 = Grid()
    t0 = xtg.timer()
    grd1._xtgformat = 1
    grd1.from_file(bigbox)
    t_old = xtg.timer(t0)
    logger.info("Reading bigbox xtgeformat=1 took %s seconds", t_old)
    cell1 = grd1.get_xyz_cell_corners((13, 14, 15))

    grd2 = Grid()
    t0 = xtg.timer()
    t1 = xtg.timer()
    grd2._xtgformat = 2
    grd2.from_file(bigbox)
    t_new = xtg.timer(t0)
    logger.info("Reading bigbox xtgformat=2 took %s seconds", t_new)
    cell2a = grd2.get_xyz_cell_corners((13, 14, 15))

    t0 = xtg.timer()
    grd2._convert_xtgformat2to1()
    cell2b = grd2.get_xyz_cell_corners((13, 14, 15))
    logger.info("Conversion to xtgformat1 took %s seconds", xtg.timer(t0))
    t_newtot = xtg.timer(t1)
    logger.info("Total run time xtgformat=2 + conv took %s seconds", t_newtot)

    logger.info("Speed gain new vs old: %s", t_old / t_new)
    logger.info("Speed gain new incl conv vs old: %s", t_old / t_newtot)

    assert cell1 == cell2a
    assert cell1 == cell2b