def test_cube_attr_rms_two_surfaces_compare_window(load_cube_rsgy1):
    """Get cube attribute (rms) between two surfaces, and compare with
    window."""

    xs1 = RegularSurface(rtop1)
    xs2 = xs1.copy()
    xs2.values += 30

    kube = load_cube_rsgy1

    xss1 = xs1.copy()
    xss1.slice_cube_window(kube,
                           other=xs2,
                           other_position='below',
                           attribute='rms',
                           sampling='trilinear')

    xss2 = xs1.copy()
    xss2.values += 15
    xss2.slice_cube_window(kube,
                           zrange=15,
                           attribute='rms',
                           sampling='trilinear')

    assert xss1.values.mean() == xss2.values.mean()
def test_cube_attr_mean_two_surfaces_with_zeroiso(tmpdir, load_cube_rsgy1):
    """Get cube attribute between two surfaces with partly zero isochore."""

    logger.info("Loading surfaces {} {}".format(RTOP1, RBAS1))
    xs1 = RegularSurface(RTOP1)
    xs2 = RegularSurface(RBAS2)

    logger.info("Loading cube {}".format(RSGY1))
    kube = load_cube_rsgy1

    xss = xs1.copy()
    xss.slice_cube_window(
        kube, other=xs2, other_position="below", attribute="mean", sampling="trilinear"
    )

    xss.to_file(join(tmpdir, "surf_slice_cube_2surf_meantri.gri"))

    xss.quickplot(
        filename=join(tmpdir, "surf_slice_cube_2surf_mean_v2.png"),
        colortable="jet",
        title="Reek two surfs mean",
        minmax=(-0.1, 0.1),
        infotext="Method: trilinear, 2 surfs, partly zero isochore",
    )

    logger.info("Mean is {}".format(xss.values.mean()))
Example #3
0
def test_cube_attr_mean_two_surfaces(load_cube_rsgy1):
    """Get cube attribute (mean) between two surfaces."""

    logger.info("Loading surfaces {} {}".format(RTOP1, RBAS1))
    xs1 = RegularSurface(RTOP1)
    xs2 = RegularSurface(RBAS1)

    logger.info("Loading cube {}".format(RSGY1))
    kube = load_cube_rsgy1

    xss = xs1.copy()
    xss.slice_cube_window(kube,
                          other=xs2,
                          other_position="below",
                          attribute="mean",
                          sampling="trilinear")

    xss.to_file(td + "/surf_slice_cube_2surf_meantri.gri")

    xss.quickplot(
        filename=td + "/surf_slice_cube_2surf_mean.png",
        colortable="jet",
        title="Reek two surfs mean",
        minmax=(-0.1, 0.1),
        infotext="Method: trilinear, 2 surfs",
    )

    logger.info("Mean is {}".format(xss.values.mean()))
def test_cube_attr_mean_two_surfaces_with_zeroiso(load_cube_rsgy1):
    """Get cube attribute between two surfaces with partly zero isochore."""

    logger.info('Loading surfaces {} {}'.format(rtop1, rbas1))
    xs1 = RegularSurface(rtop1)
    xs2 = RegularSurface(rbas2)

    logger.info('Loading cube {}'.format(rsgy1))
    kube = load_cube_rsgy1

    xss = xs1.copy()
    xss.slice_cube_window(kube,
                          other=xs2,
                          other_position='below',
                          attribute='mean',
                          sampling='trilinear')

    xss.to_file(td + '/surf_slice_cube_2surf_meantri.gri')

    xss.quickplot(filename=td + '/surf_slice_cube_2surf_mean_v2.png',
                  colortable='jet',
                  title='Reek two surfs mean',
                  minmax=(-0.1, 0.1),
                  infotext='Method: trilinear, 2 surfs, partly zero isochore')

    logger.info('Mean is {}'.format(xss.values.mean()))
def test_cube_attr_mean_two_surfaces_multiattr(tmpdir, load_cube_rsgy1):
    """Get cube attribute (mean) between two surfaces, many attr at the same
    time.
    """

    logger.info("Loading surfaces {} {}".format(RTOP1, RBAS1))
    xs1 = RegularSurface(RTOP1)
    xs2 = RegularSurface(RBAS1)

    logger.info("Loading cube {}".format(RSGY1))
    kube = load_cube_rsgy1

    xss = xs1.copy()
    xss.slice_cube_window(
        kube,
        other=xs2,
        other_position="below",
        attribute="rms",
        sampling="trilinear",
        showprogress=True,
    )

    logger.debug(xss.values.mean())

    xsx = xs1.copy()
    attrs = xsx.slice_cube_window(
        kube,
        other=xs2,
        other_position="below",
        attribute=["max", "mean", "min", "rms"],
        sampling="trilinear",
        showprogress=True,
    )
    logger.debug(attrs["rms"].values.mean())

    assert xss.values.mean() == attrs["rms"].values.mean()
    assert xss.values.std() == attrs["rms"].values.std()

    for attr in attrs.keys():
        logger.info("Working with %s", attr)

        xxx = attrs[attr]
        xxx.to_file(join(tmpdir, "surf_slice_cube_2surf_" + attr + "multi.gri"))

        minmax = (None, None)
        if attr == "mean":
            minmax = (-0.1, 0.1)

        xxx.quickplot(
            filename=join(tmpdir, "surf_slice_cube_2surf_" + attr + "multi.png"),
            colortable="jet",
            minmax=minmax,
            title="Reek two surfs mean multiattr: " + attr,
            infotext="Method: trilinear, 2 surfs multiattr " + attr,
        )
def test_get_surface_from_cube(load_cube_rsgy1):
    """Construct a constant surface from cube."""

    surf = RegularSurface()
    cube = load_cube_rsgy1

    surf.from_cube(cube, 1999.0)

    assert surf.xinc == cube.xinc
    assert surf.nrow == cube.nrow
    tsetup.assert_almostequal(surf.values.mean(), 1999.0, 0.00001)
def test_slice_attr_window_max(load_cube_rsgy1):
    """Slice a cube within a window, get max, using trilinear interpol."""

    logger.info('Loading surface')
    xs1 = RegularSurface(rtop1)

    logger.info('Loading cube')
    kube = load_cube_rsgy1

    xs1.slice_cube_window(kube, attribute='max', sampling='trilinear')
    logger.info(xs1.values.mean())
    tsetup.assert_almostequal(xs1.values.mean(), 0.08494559, 0.0001)
Example #8
0
def test_simple_plot():
    """Test as simple map plot only making an instance++ and plot."""

    mysurf = RegularSurface()
    mysurf.from_file(SFILE1)

    # just make the instance, with a lot of defaults behind the scene
    myplot = Map()
    myplot.canvas(title="My o my")
    myplot.colormap = "gist_ncar"
    myplot.plot_surface(mysurf)

    myplot.savefig("TMP/map_simple.png")
def test_avg02():
    """Make average map from Reek Eclipse."""
    grd = Grid()
    grd.from_file(GFILE2, fformat="egrid")

    # get the poro
    po = GridProperty()
    po.from_file(IFILE2, fformat="init", name="PORO", grid=grd)

    # get the dz and the coordinates
    dz = grd.get_dz(mask=False)
    xc, yc, _zc = grd.get_xyz(mask=False)

    # get actnum
    actnum = grd.get_actnum()

    # convert from masked numpy to ordinary
    xcuse = np.copy(xc.values3d)
    ycuse = np.copy(yc.values3d)
    dzuse = np.copy(dz.values3d)
    pouse = np.copy(po.values3d)

    # dz must be zero for undef cells
    dzuse[actnum.values3d < 0.5] = 0.0
    pouse[actnum.values3d < 0.5] = 0.0

    # make a map... estimate from xc and yc
    zuse = np.ones((xcuse.shape))

    avgmap = RegularSurface(
        nx=200,
        ny=250,
        xinc=50,
        yinc=50,
        xori=457000,
        yori=5927000,
        values=np.zeros((200, 250)),
    )

    avgmap.avg_from_3dprop(
        xprop=xcuse,
        yprop=ycuse,
        zoneprop=zuse,
        zone_minmax=(1, 1),
        mprop=pouse,
        dzprop=dzuse,
        truncate_le=None,
    )

    # add the faults in plot
    fau = Polygons(FFILE1, fformat="zmap")
    fspec = {"faults": fau}

    avgmap.quickplot(filename="TMP/tmp_poro2.png",
                     xlabelrotation=30,
                     faults=fspec)
    avgmap.to_file("TMP/tmp.poro.gri", fformat="irap_ascii")

    logger.info(avgmap.values.mean())
    assert avgmap.values.mean() == pytest.approx(0.1653, abs=0.01)
Example #10
0
def test_cube_slice_w_ignore_dead_traces_trilinear():
    """Get cube slice trilinear aka Auto4D input, with scrambled data with
    dead traces to be ignored, various YFLIP cases."""

    cube1 = Cube(XCUB2)

    surf1 = RegularSurface()
    surf1.from_cube(cube1, 1000.0)

    cells = [(18, 12), (20, 2), (0, 4)]

    surf1.slice_cube(cube1,
                     sampling="trilinear",
                     snapxy=True,
                     deadtraces=False)
    plotfile = ojn(td, "slice_tri1.png")
    title = "Cube with dead traces; trilinear; keep as is at dead traces"
    surf1.quickplot(filename=plotfile, minmax=(-10000, 10000), title=title)

    for cell in cells:
        icell, jcell = cell
        assert surf1.values[icell,
                            jcell] == pytest.approx(cube1.values[icell, jcell,
                                                                 0],
                                                    abs=0.1)
    assert ma.count_masked(surf1.values) == 0  # shall be no masked cells
def test_cube_attr_mean_two_surfaces_multiattr(load_cube_rsgy1):
    """Get cube attribute (mean) between two surfaces, many attr at the same
    time.
    """

    logger.info('Loading surfaces {} {}'.format(rtop1, rbas1))
    xs1 = RegularSurface(rtop1)
    xs2 = RegularSurface(rbas1)

    logger.info('Loading cube {}'.format(rsgy1))
    kube = load_cube_rsgy1

    xss = xs1.copy()
    xss.slice_cube_window(kube,
                          other=xs2,
                          other_position='below',
                          attribute='rms',
                          sampling='trilinear',
                          showprogress=True)

    logger.debug(xss.values.mean())

    xsx = xs1.copy()
    attrs = xsx.slice_cube_window(kube,
                                  other=xs2,
                                  other_position='below',
                                  attribute=['max', 'mean', 'min', 'rms'],
                                  sampling='trilinear',
                                  showprogress=True)
    logger.debug(attrs['rms'].values.mean())

    assert xss.values.mean() == attrs['rms'].values.mean()
    assert xss.values.std() == attrs['rms'].values.std()

    for attr in attrs.keys():
        logger.info('Working with %s', attr)

        xxx = attrs[attr]
        xxx.to_file(ojn(td, 'surf_slice_cube_2surf_' + attr + 'multi.gri'))

        minmax = (None, None)
        if attr == 'mean':
            minmax = (-0.1, 0.1)

        xxx.quickplot(filename=ojn(
            td, 'surf_slice_cube_2surf_' + attr + 'multi.png'),
                      colortable='jet',
                      minmax=minmax,
                      title='Reek two surfs mean multiattr: ' + attr,
                      infotext='Method: trilinear, 2 surfs multiattr ' + attr)
Example #12
0
def test_map_to_points(reek_map):
    """Get the list of the coordinates"""

    px = Points()

    surf = RegularSurface(ftop1)

    assert isinstance(surf, RegularSurface)

    tsetup.assert_almostequal(surf.values.mean(), 0.5755830099, 0.001)

    px.from_surface(surf)

    # convert to a Points instance
    px = Points(reek_map)
    # or
    # px.from_surface(...)

    outf = os.path.join(td, 'points_from_surf_reek.poi')
    px.to_file(outf)

    assert px.dataframe['X_UTME'].min() == 456719.75
    tsetup.assert_almostequal(px.dataframe['Z_TVDSS'].mean(), 0.57558, 0.001)

    # read the output for comparison
    pxx = Points(outf)

    tsetup.assert_almostequal(px.dataframe['Z_TVDSS'].mean(),
                              pxx.dataframe['Z_TVDSS'].mean(), 0.00001)
Example #13
0
def test_cube_attr_rms_two_surfaces_compare_window_show(load_cube_rsgy1):
    """Get cube attribute (rms) between two surfaces, and compare with
    window, and show plots."""

    logger.info("Loading surfaces {} {}".format(RTOP1, RBAS1))
    xs1 = RegularSurface(RTOP1)
    xs2 = xs1.copy()
    xs2.values += 30

    logger.info("Loading cube {}".format(RSGY1))
    kube = load_cube_rsgy1

    xss1 = xs1.copy()
    xss1.slice_cube_window(kube,
                           other=xs2,
                           other_position="below",
                           attribute="rms",
                           sampling="trilinear")

    xss1.quickplot(
        filename=td + "/surf_slice_cube_2surf_rms1.png",
        colortable="jet",
        minmax=[0, 0.5],
        # TODO: itle='Reek two surfs mean', minmax=(-0.1, 0.1),
        infotext="Method: trilinear, 2 surfs, 30ms apart",
    )

    print("\n\n{}\n".format("=" * 100))

    xss2 = xs1.copy()
    xss2.values += 15
    xss2.slice_cube_window(kube,
                           zrange=15,
                           attribute="rms",
                           sampling="trilinear")

    xss2.quickplot(
        filename=td + "/surf_slice_cube_2surf_rms2.png",
        colortable="jet",
        minmax=[0, 0.5],
        # TODO: itle='Reek two surfs mean', minmax=(-0.1, 0.1),
        infotext="Method: trilinear, 2 surfs, +- 15ms window",
    )

    assert xss1.values.mean() == xss2.values.mean()
def test_slice_attr_window_max_algorithm2(load_cube_rsgy1):
    """Slice a cube within a window, get max, using trilinear interpol,
    alg 2.
    """

    logger.info('Loading surface')
    xs1 = RegularSurface(rtop1)
    # xs2 = xs1.copy()
    # xs3 = xs1.copy()

    logger.info('Loading cube')
    kube = load_cube_rsgy1

    # t1 = xtg.timer()
    xs1.slice_cube_window(kube,
                          attribute='min',
                          sampling='trilinear',
                          algorithm=2)
Example #15
0
def test_create_surf_distance_log(loadwell1):
    """Test making a log which is distance to a surface."""

    well = loadwell1

    surf1 = RegularSurface(SURF1)
    surf2 = RegularSurface(SURF2)

    well.create_surf_distance_log(surf1, name="DIST_TOP")
    well.create_surf_distance_log(surf2, name="DIST_BASE")

    assert well.dataframe.loc[0, "DIST_TOP"] == pytest.approx(1653.303263)
    assert well.dataframe.loc[0, "DIST_BASE"] == pytest.approx(1696.573171)

    # moving the surface so it is outside the well
    surf1.translate_coordinates((10000, 10000, 0))
    well.create_surf_distance_log(surf1, name="DIST_BASE_NEW")
    assert np.isnan(well.dataframe.loc[0, "DIST_BASE_NEW"])
def test_cube_attr_rms_two_surfaces_compare_window_show(load_cube_rsgy1):
    """Get cube attribute (rms) between two surfaces, and compare with
    window, and show plots."""

    logger.info('Loading surfaces {} {}'.format(rtop1, rbas1))
    xs1 = RegularSurface(rtop1)
    xs2 = xs1.copy()
    xs2.values += 30

    logger.info('Loading cube {}'.format(rsgy1))
    kube = load_cube_rsgy1

    xss1 = xs1.copy()
    xss1.slice_cube_window(kube,
                           other=xs2,
                           other_position='below',
                           attribute='rms',
                           sampling='trilinear')

    xss1.quickplot(
        filename=td + '/surf_slice_cube_2surf_rms1.png',
        colortable='jet',
        minmax=[0, 0.5],
        # TODO: itle='Reek two surfs mean', minmax=(-0.1, 0.1),
        infotext='Method: trilinear, 2 surfs, 30ms apart')

    print('\n\n{}\n'.format('=' * 100))

    xss2 = xs1.copy()
    xss2.values += 15
    xss2.slice_cube_window(kube,
                           zrange=15,
                           attribute='rms',
                           sampling='trilinear')

    xss2.quickplot(
        filename=td + '/surf_slice_cube_2surf_rms2.png',
        colortable='jet',
        minmax=[0, 0.5],
        # TODO: itle='Reek two surfs mean', minmax=(-0.1, 0.1),
        infotext='Method: trilinear, 2 surfs, +- 15ms window')

    assert xss1.values.mean() == xss2.values.mean()
Example #17
0
def test_more_features_plot():
    """Map with some more features added, such as label rotation."""

    mysurf = RegularSurface()
    mysurf.from_file(SFILE1)

    myfaults = Polygons(PFILE1)

    # just make the instance, with a lot of defaults behind the scene
    myplot = Map()
    myplot.canvas(title="Label rotation")
    myplot.colormap = "rainbow"
    myplot.plot_surface(mysurf,
                        minvalue=1250,
                        maxvalue=2200,
                        xlabelrotation=45)

    myplot.plot_faults(myfaults)

    myplot.savefig(TD + "/map_more1.png")
def test_slice_nearest(tmpdir, load_cube_rsgy1):
    """Slice a cube with a surface, nearest node, algorithm 1"""

    xs = RegularSurface(RTOP1)
    xs.to_file(join(tmpdir, "surf_slice_cube_initial.gri"))

    kube = load_cube_rsgy1

    t1 = xtg.timer()
    xs.slice_cube(kube, algorithm=1)
    logger.info("Slicing...done in {} seconds".format(xtg.timer(t1)))

    xs.to_file(join(tmpdir, "surf_slice_cube_v1.gri"), fformat="irap_binary")

    xs.quickplot(
        filename=join(tmpdir, "surf_slice_cube_near_v1.png"),
        colortable="seismic",
        minmax=(-1, 1),
        title="Reek",
        infotext="Method: nearest, algorithm 1",
    )
Example #19
0
def test_map_plot_with_points():
    """Test as simple map plot with underlying points."""

    mysurf = RegularSurface()
    mysurf.from_file(SFILE1)

    mypoints = Points()
    mypoints.from_surface(mysurf)

    df = mypoints.dataframe.copy()
    df = df[::20]
    mypoints.dataframe = df

    # just make the instance, with a lot of defaults behind the scene
    myplot = Map()
    myplot.canvas(title="My o my")
    myplot.colormap = "gist_ncar"
    myplot.plot_surface(mysurf)
    myplot.plot_points(mypoints)

    myplot.savefig("TMP/map_with_points.png")
Example #20
0
def test_slice_attr_window_max(load_cube_rsgy1):
    """Slice a cube within a window, get max, using trilinear interpol."""

    logger.info("Loading surface")
    xs1 = RegularSurface(RTOP1)

    logger.info("Loading cube")
    kube = load_cube_rsgy1

    ret = xs1.slice_cube_window(kube,
                                attribute="max",
                                sampling="trilinear",
                                algorithm=2)
    logger.info(xs1.values.mean())
    assert ret is None
    tsetup.assert_almostequal(xs1.values.mean(), 0.08619, 0.001)

    # one attribute but in a list context shall return a dict
    xs1 = RegularSurface(RTOP1)
    ret = xs1.slice_cube_window(kube,
                                attribute=["max"],
                                sampling="trilinear",
                                algorithm=2)
    assert isinstance(ret, dict)

    tsetup.assert_almostequal(ret["max"].values.mean(), 0.08619, 0.001)
def test_resample(tmpdir, reek_map):
    """Do resampling from one surface to another."""
    xs = reek_map
    assert xs.ncol == 554

    xs_copy = xs.copy()

    # create a new map instance, unrotated, based on this map
    ncol = int((xs.xmax - xs.xmin) / 10)
    nrow = int((xs.ymax - xs.ymin) / 10)
    values = np.zeros((nrow, ncol))
    snew = RegularSurface(
        xori=xs.xmin,
        xinc=10,
        yori=xs.ymin,
        yinc=10,
        nrow=nrow,
        ncol=ncol,
        values=values,
    )

    snew.resample(xs)

    fout = join(tmpdir, "reek_resampled.gri")
    snew.to_file(fout, fformat="irap_binary")

    tsetup.assert_almostequal(snew.values.mean(), 1698.458, 2)
    tsetup.assert_almostequal(snew.values.mean(), xs.values.mean(), 2)

    # check that the "other" in snew.resample(other) is unchanged:
    assert xs.xinc == xs_copy.xinc
    tsetup.assert_almostequal(xs.values.mean(), xs_copy.values.mean(), 1e-4)
    tsetup.assert_almostequal(xs.values.std(), xs_copy.values.std(), 1e-4)
def test_avg03():
    """Make average map from Reek Eclipse, speed up by zone_avg."""
    g = Grid()
    g.from_file(gfile2, fformat="egrid")

    # get the poro
    po = GridProperty()
    po.from_file(ifile2, fformat='init', name='PORO', grid=g)

    # get the dz and the coordinates
    dz = g.get_dz(mask=False)
    xc, yc, zc = g.get_xyz(mask=False)

    # get actnum
    actnum = g.get_actnum()
    actnum = actnum.get_npvalues3d()

    # convert from masked numpy to ordinary
    xcuse = xc.get_npvalues3d()
    ycuse = yc.get_npvalues3d()
    dzuse = dz.get_npvalues3d(fill_value=0.0)
    pouse = po.get_npvalues3d(fill_value=0.0)

    # dz must be zero for undef cells
    dzuse[actnum < 0.5] = 0.0
    pouse[actnum < 0.5] = 0.0

    # make a map... estimate from xc and yc
    zuse = np.ones((xcuse.shape))

    avgmap = RegularSurface(nx=200, ny=250, xinc=50, yinc=50,
                            xori=457000, yori=5927000,
                            values=np.zeros((200, 250)))

    avgmap.avg_from_3dprop(xprop=xcuse, yprop=ycuse, zoneprop=zuse,
                           zone_minmax=(1, 1),
                           mprop=pouse, dzprop=dzuse,
                           truncate_le=None, zone_avg=True)

    # add the faults in plot
    fau = Polygons(ffile1, fformat='zmap')
    fspec = {'faults': fau}

    avgmap.quickplot(filename='TMP/tmp_poro3.png', xlabelrotation=30,
                     faults=fspec)
    avgmap.to_file('TMP/tmp.poro3.gri', fformat='irap_ascii')

    logger.info(avgmap.values.mean())
    assert avgmap.values.mean() == pytest.approx(0.1653, abs=0.01)
Example #23
0
def test_perm_logarithmic_map():
    """Map with PERM, log scale."""

    mysurf = RegularSurface(SFILE2)

    myplot = Map()
    myplot.canvas(title="PERMX normal scale")
    myplot.colormap = "rainbow"
    myplot.plot_surface(mysurf,
                        minvalue=0,
                        maxvalue=6000,
                        xlabelrotation=45,
                        logarithmic=True)

    myplot.savefig(TD + "/permx_normal.png")
Example #24
0
def test_perm_logarithmic_map():
    """Map with PERM, log scale."""

    mysurf = RegularSurface(sfile2)

    myplot = Map()
    myplot.canvas(title='PERMX normal scale')
    myplot.colormap = 'gist_rainbow_r'
    myplot.plot_surface(mysurf,
                        minvalue=0,
                        maxvalue=6000,
                        xlabelrotation=45,
                        logarithmic=True)

    myplot.savefig(td + '/permx_normal.png')
def test_resample_small():
    """Do resampling with minimal dataset to test for various yflip etc"""

    xs1 = RegularSurface(
        xori=0,
        yori=0,
        ncol=3,
        nrow=3,
        xinc=100,
        yinc=100,
        values=-888.0,
        yflip=1,
    )
    xs2 = RegularSurface(
        xori=0,
        yori=0,
        ncol=3,
        nrow=3,
        xinc=100,
        yinc=100,
        values=888.0,
        yflip=1,
    )
    xs3 = RegularSurface(
        xori=0,
        yori=200,
        ncol=3,
        nrow=3,
        xinc=100,
        yinc=100,
        values=2888.0,
        yflip=-1,
    )

    xsx = xs1.copy()
    xsx.resample(xs2)
    assert xsx.values.mean() == 888.0

    xsx = xs3.copy()
    xsx.resample(xs2)
    assert xsx.values.mean() == 888.0

    xsx = xs1.copy()
    xsx.resample(xs3)
    assert xsx.values.mean() == 2888.0
def test_resample_partial_sample(tmp_path, reek_map, generate_plot):
    """Do resampling from one surface to another with partial sampling."""
    sml = reek_map

    # note: values is missing by purpose:
    snew = RegularSurface(
        ncol=round(sml.ncol * 0.6),
        nrow=round(sml.nrow * 0.6),
        xori=sml.xori - 2000,
        yori=sml.yori + 3000,
        xinc=sml.xinc * 0.6,
        yinc=sml.xinc * 0.6,
        rotation=sml.rotation,
        yflip=sml.yflip,
    )

    print(sml.yflip)

    logger.info(snew.values)

    snew.resample(sml, mask=True)

    assert snew.values.mean() == pytest.approx(1726.65)

    if generate_plot:
        sml.quickplot(tmp_path / "resampled_input.png")
        snew.quickplot(tmp_path / "resampled_output.png")
        sml.to_file(tmp_path / "resampled_input.gri")
        snew.to_file(tmp_path / "resampled_output.gri")

    snew2 = snew.copy()
    snew2._yflip = -1
    snew2._xori -= 4000
    snew2._yori -= 2000
    snew2.resample(sml, mask=True)

    if generate_plot:
        snew2.to_file(tmp_path / "resampled_output2.gri")
    assert snew2.values.mean() == pytest.approx(1747.20, abs=0.2)
Example #27
0
def test_slice_attr_window_max_w_plotting(load_cube_rsgy1):
    """Slice a cube within a window, get max/min etc, using trilinear
    interpol and plotting."""

    logger.info("Loading surface")
    xs1 = RegularSurface(RTOP1)
    xs2 = xs1.copy()
    xs3 = xs1.copy()

    logger.info("Loading cube")
    kube = load_cube_rsgy1

    t1 = xtg.timer()
    xs1.slice_cube_window(kube, attribute="min", sampling="trilinear")
    t2 = xtg.timer(t1)
    logger.info("Window slicing... {} secs".format(t2))

    xs1.quickplot(
        filename=td + "/surf_slice_cube_window_min.png",
        colortable="seismic",
        minmax=(-1, 1),
        title="Reek Minimum",
        infotext="Method: trilinear, window",
    )

    xs2.slice_cube_window(kube,
                          attribute="max",
                          sampling="trilinear",
                          showprogress=True)

    xs2.quickplot(
        filename=td + "/surf_slice_cube_window_max.png",
        colortable="seismic",
        minmax=(-1, 1),
        title="Reek Maximum",
        infotext="Method: trilinear, window",
    )

    xs3.slice_cube_window(kube, attribute="rms", sampling="trilinear")

    xs3.quickplot(
        filename=td + "/surf_slice_cube_window_rms.png",
        colortable="jet",
        minmax=(0, 1),
        title="Reek rms (root mean square)",
        infotext="Method: trilinear, window",
    )
def test_cube_slice_w_dead_traces_nearest():
    """Get cube slice nearest aka Auto4D input, with scrambled data with
    dead traces, various YFLIP cases, undef at dead traces."""

    cube1 = Cube(xcub2)

    surf1 = RegularSurface()
    surf1.from_cube(cube1, 1000.1)

    cells = ((18, 12), )

    surf1.slice_cube(cube1, deadtraces=True)
    plotfile = ojn(td, 'slice_nea1_dead.png')
    title = 'Cube with dead traces; nearest; UNDEF at dead traces'
    surf1.quickplot(filename=plotfile, minmax=(-10000, 10000), title=title)

    for cell in cells:
        icell, jcell = cell
        assert surf1.values[icell, jcell] == cube1.values[icell, jcell, 0]

    ndead = (cube1.traceidcodes == 2).sum()
    print(ndead)

    assert ma.count_masked(surf1.values) == ndead

    # swap cube only
    surf2 = surf1.copy()
    surf2.values = 1000.1

    cube2 = cube1.copy()
    cube2.swapaxes()
    surf2.slice_cube(cube2, deadtraces=True)
    plotfile = ojn(td, 'slice_nea1_dead_cubeswap.png')
    surf2.quickplot(filename=plotfile, minmax=(-10000, 10000))
    assert ma.count_masked(surf2.values) == ndead
    assert surf2.values.mean() == surf1.values.mean()
Example #29
0
def test_slice_nearest_v2(load_cube_rsgy1):
    """Slice a cube with a surface, nearest node, algorithm 2."""

    xs = RegularSurface(RTOP1)

    kube = load_cube_rsgy1

    t1 = xtg.timer()

    xs.slice_cube(kube, algorithm=2)
    logger.info("Slicing...done in {} seconds".format(xtg.timer(t1)))

    xs.to_file(td + "/surf_slice_cube_alg2.gri", fformat="irap_binary")

    xs.quickplot(
        filename=td + "/surf_slice_cube_alg2.png",
        colortable="seismic",
        minmax=(-1, 1),
        title="Reek",
        infotext="Method: nearest",
    )
def test_slice_attr_window_max_w_plotting(load_cube_rsgy1):
    """Slice a cube within a window, get max/min etc, using trilinear
    interpol and plotting."""

    logger.info('Loading surface')
    xs1 = RegularSurface(rtop1)
    xs2 = xs1.copy()
    xs3 = xs1.copy()

    logger.info('Loading cube')
    kube = load_cube_rsgy1

    t1 = xtg.timer()
    xs1.slice_cube_window(kube, attribute='min', sampling='trilinear')
    t2 = xtg.timer(t1)
    logger.info('Window slicing... {} secs'.format(t2))

    xs1.quickplot(filename=td + '/surf_slice_cube_window_min.png',
                  colortable='seismic',
                  minmax=(-1, 1),
                  title='Reek Minimum',
                  infotext='Method: trilinear, window')

    xs2.slice_cube_window(kube,
                          attribute='max',
                          sampling='trilinear',
                          showprogress=True)

    xs2.quickplot(filename=td + '/surf_slice_cube_window_max.png',
                  colortable='seismic',
                  minmax=(-1, 1),
                  title='Reek Maximum',
                  infotext='Method: trilinear, window')

    xs3.slice_cube_window(kube, attribute='rms', sampling='trilinear')

    xs3.quickplot(filename=td + '/surf_slice_cube_window_rms.png',
                  colortable='jet',
                  minmax=(0, 1),
                  title='Reek rms (root mean square)',
                  infotext='Method: trilinear, window')