Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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),
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())
tov[tov < 1.0e-32] = 1.0e-32
hcpfz = hcpfz * dzv / tov
# make a map... estimate from xc and yc
xmin = xcv.min()
xmax = xcv.max()
ymin = ycv.min()
ymax = ycv.max()
xinc = (xmax - xmin) / 50
yinc = (ymax - ymin) / 50
logger.debug("xmin xmax ymin ymax, xinc, yinc: %s %s %s %s %s %s",
xmin, xmax, ymin, ymax, xinc, yinc
)
hcmap = RegularSurface(
nx=50,
ny=50,
xinc=xinc,
yinc=yinc,
xori=xmin,
yori=ymin,
values=np.zeros((50, 50)),
)
hcmap2 = RegularSurface(
nx=50,
ny=50,
xinc=xinc,
yinc=yinc,
xori=xmin,
yori=ymin,
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",
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)
def test_surface_from_grd3d_layer():
"""Create a surface from a 3D grid layer"""
surf = xtgeo.surface.RegularSurface()
grd = xtgeo.grid3d.Grid(rgrd2, fformat='roff')
# grd = xtgeo.Grid("../xtgeo-testdata-equinor/data/3dgrids/gfb/gullfaks_gg.roff")
surf.from_grid3d(grd)
surf.fill()
surf.to_file(ojn(td, 'surf_from_grid3d_top.gri'))
tmp = surf.copy()
surf.quickplot(filename=ojn(td, 'surf_from_grid3d_top.png'))
surf.from_grid3d(grd, template=tmp, mode="i")
surf.to_file(ojn(td, 'surf_from_grid3d_top_icell.gri'))
surf.quickplot(filename=ojn(td, 'surf_from_grid3d_top_icell.png'))
surf.from_grid3d(grd, template=tmp, mode="j")
surf.fill()
def reek_map():
logger.info('Loading surface')
return RegularSurface(ftop1)
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",
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),
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