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_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_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()))
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_slice_nearest(load_cube_rsgy1): """Slice a cube with a surface, nearest node.""" t1 = xtg.timer() logger.info('Loading surface') xs = RegularSurface(rtop1) xs.to_file(td + '/surf_slice_cube_initial.gri') logger.info('Loading cube') kube = load_cube_rsgy1 # now slice logger.info('Slicing cube which has YFLIP status {}'.format(kube.yflip)) t1 = xtg.timer() print(t1) xs.slice_cube(kube) t2 = xtg.timer(t1) logger.info('Slicing...done in {} seconds'.format(t2)) xs.to_file(td + '/surf_slice_cube.fgr', fformat='irap_ascii') xs.to_file(td + '/surf_slice_cube.gri', fformat='irap_binary') xs.quickplot(filename=td + '/surf_slice_cube.png', colortable='seismic', minmax=(-1, 1), title='Reek', infotext='Method: nearest') mean = xs.values.mean() logger.info(xs.values.min()) logger.info(xs.values.max()) mean = xs.values.mean() assert mean == pytest.approx(0.0198142, abs=0.001) # 0.019219 in RMS logger.info('Avg X is {}'.format(mean)) # try same ting with swapaxes active ================================== ys = RegularSurface() ys.from_file(rtop1) kube.swapaxes() # Now slice logger.info('Slicing... (now with swapaxes)') ys.slice_cube(kube) logger.info('Slicing...done') mean = ys.values.mean() logger.info('Avg for surface is now {}'.format(mean)) ys.to_file(td + '/surf_slice_cube_swap.gri') assert mean == pytest.approx(0.0198142, abs=0.003)
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)
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_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)
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)
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_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_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_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_slice_various_reek(tmpdir, load_cube_rsgy1): """Slice a cube with a surface, both nearest node and interpol, Reek.""" logger.info("Loading surface") xs = RegularSurface(RTOP1) logger.info("Loading cube") kube = load_cube_rsgy1 t1 = xtg.timer() xs.slice_cube(kube) t2 = xtg.timer(t1) logger.info("Slicing... nearest, done in {} seconds".format(t2)) xs.to_file(join(tmpdir, "surf_slice_cube_reek_interp.gri")) xs.quickplot( filename=join(tmpdir, "surf_slice_cube_reek_interp.png"), colortable="seismic", minmax=(-1, 1), title="Reek", infotext="Method: nearest", ) # trilinear interpolation: logger.info("Loading surface") xs = RegularSurface(RTOP1) t1 = xtg.timer() xs.slice_cube(kube, sampling="trilinear") t2 = xtg.timer(t1) logger.info("Slicing... trilinear, done in {} seconds".format(t2)) xs.to_file(join(tmpdir, "surf_slice_cube_reek_trilinear.gri")) xs.quickplot( filename=join(tmpdir, "surf_slice_cube_reek_trilinear.png"), colortable="seismic", minmax=(-1, 1), title="Reek", infotext="Method: trilinear", )
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)
def test_cube_slice_w_ignore_dead_traces_nearest(): """Get cube slice nearest aka Auto4D input, with scrambled data with dead traces, various YFLIP cases, ignore dead traces.""" cube1 = Cube(XCUB2) surf1 = RegularSurface() surf1.from_cube(cube1, 1000.1) cells = ((18, 12), (20, 2), (0, 4)) surf1.slice_cube(cube1, deadtraces=False) plotfile = ojn(td, "slice_nea1.png") title = "Cube with dead traces; nearest; use just values as is" 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.01) assert ma.count_masked(surf1.values) == 0 # shall be no masked cells # swap surface surf2 = surf1.copy() surf2.values = 1000.1 surf2.swapaxes() surf2.slice_cube(cube1, deadtraces=False) assert surf2.values.mean() == pytest.approx(surf1.values.mean(), rel=0.001) # swap surface and cube surf2 = surf1.copy() surf2.values = 1000.1 surf2.swapaxes() cube2 = cube1.copy() cube2.swapaxes() surf2.slice_cube(cube2, deadtraces=False) assert surf2.values.mean() == pytest.approx(surf1.values.mean(), rel=0.001) # swap cube only surf2 = surf1.copy() surf2.values = 1000.1 cube2 = cube1.copy() cube2.swapaxes() surf2.slice_cube(cube2, deadtraces=False) assert surf2.values.mean() == pytest.approx(surf1.values.mean(), rel=0.001)
def test_slice_various_reek(load_cube_rsgy1): """Slice a cube with a surface, both nearest node and interpol, Reek.""" logger.info('Loading surface') xs = RegularSurface(rtop1) logger.info('Loading cube') kube = load_cube_rsgy1 t1 = xtg.timer() xs.slice_cube(kube) t2 = xtg.timer(t1) logger.info('Slicing... nearest, done in {} seconds'.format(t2)) xs.to_file(td + '/surf_slice_cube_reek_interp.gri') xs.quickplot(filename=td + '/surf_slice_cube_reek_interp.png', colortable='seismic', minmax=(-1, 1), title='Reek', infotext='Method: nearest') # trilinear interpolation: logger.info('Loading surface') xs = RegularSurface(rtop1) t1 = xtg.timer() xs.slice_cube(kube, sampling='trilinear') t2 = xtg.timer(t1) logger.info('Slicing... trilinear, done in {} seconds'.format(t2)) xs.to_file(td + '/surf_slice_cube_reek_trilinear.gri') xs.quickplot(filename=td + '/surf_slice_cube_reek_trilinear.png', colortable='seismic', minmax=(-1, 1), title='Reek', infotext='Method: trilinear')
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_cube_slice_auto4d_data(): """Get cube slice aka Auto4D input, with synthetic/scrambled data""" xs1 = RegularSurface(XTOP1, fformat="gri") xs1.describe() xs1out = ojn(td, "XTOP1.ijxyz") xs1.to_file(xs1out, fformat="ijxyz") xs2 = RegularSurface(xs1out, fformat="ijxyz") assert xs1.values.mean() == pytest.approx(xs2.values.mean(), abs=0.0001) kube1 = Cube(XCUB1) kube1.describe() assert xs2.nactive == 10830 xs2.slice_cube_window(kube1, sampling="trilinear", mask=True, attribute="max") xs2out1 = ojn(td, "XTOP2_sampled_from_cube.ijxyz") xs2out2 = ojn(td, "XTOP2_sampled_from_cube.gri") xs2out3 = ojn(td, "XTOP2_sampled_from_cube.png") xs2.to_file(xs2out1, fformat="ijxyz") xs2.to_file(xs2out2) assert xs2.nactive == 3275 # 3320 # shall be fewer cells xs2.quickplot( filename=xs2out3, colortable="seismic", title="Auto4D Test", minmax=(0, 12000), infotext="Method: max", )
def test_cube_slice_w_dead_traces_nearest(tmpdir): """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, algorithm=1) plotfile = join(tmpdir, "slice_nea1_dead1.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() assert ma.count_masked(surf1.values) == ndead surf2 = RegularSurface() surf2.from_cube(cube1, 1000.1) surf2.slice_cube(cube1, deadtraces=True, algorithm=2) plotfile = join(tmpdir, "slice_nea1_dead2.png") title = "Cube with dead traces; nearest; UNDEF at dead traces algo 2" surf1.quickplot(filename=plotfile, minmax=(-10000, 10000), title=title) for cell in cells: icell, jcell = cell assert surf2.values[icell, jcell] == cube1.values[icell, jcell, 0] ndead = (cube1.traceidcodes == 2).sum() assert ma.count_masked(surf1.values) == ndead
def test_cube_slice_auto4d_data(): """Get cube slice aka Auto4D input, with synthetic/scrambled data""" xs1 = RegularSurface(xtop1, fformat='gri') xs1.describe() xs1out = ojn(td, 'xtop1.ijxyz') xs1.to_file(xs1out, fformat='ijxyz') xs2 = RegularSurface(xs1out, fformat='ijxyz') assert xs1.values.mean() == pytest.approx(xs2.values.mean(), abs=0.0001) kube1 = Cube(xcub1) kube1.describe() assert xs2.nactive == 10830 xs2.slice_cube_window(kube1, sampling='trilinear', mask=True, attribute='max') xs2out1 = ojn(td, 'xtop2_sampled_from_cube.ijxyz') xs2out2 = ojn(td, 'xtop2_sampled_from_cube.gri') xs2out3 = ojn(td, 'xtop2_sampled_from_cube.png') xs2.to_file(xs2out1, fformat='ijxyz') xs2.to_file(xs2out2) assert xs2.nactive == 3320 # shall be fewer cells xs2.quickplot(filename=xs2out3, colortable='seismic', title='Auto4D Test', minmax=(0, 12000), infotext='Method: max')
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)
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")
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_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_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)
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()