def fixture_create_project(): """Create a tmp RMS project for testing, populate with basic data. After the yield command, the teardown phase will remove the tmp RMS project. """ prj1 = str(PRJ) print("\n******** Setup RMS project!\n") if isdir(prj1): print("Remove existing project! (1)") shutil.rmtree(prj1) project = roxar.Project.create() rox = xtgeo.RoxUtils(project) print("Roxar version is", rox.roxversion) print("RMS version is", rox.rmsversion(rox.roxversion)) assert "1." in rox.roxversion for wfile in WELLS1: wobj = xtgeo.well_from_file(WELLSFOLDER1 / wfile) if "XP_with" in wfile: wobj.name = "OP2_w_repeat" wobj.to_roxar(project, wobj.name, logrun="log", trajectory="My trajectory") # populate with cube data cube = xtgeo.cube_from_file(CUBEDATA1) cube.to_roxar(project, CUBENAME1, domain="depth") # populate with surface data rox.create_horizons_category(SURFCAT1) for num, name in enumerate(SURFNAMES1): srf = xtgeo.surface_from_file(SURFTOPS1[num]) project.horizons.create(name, roxar.HorizonType.interpreted) srf.to_roxar(project, name, SURFCAT1) # populate with grid and props grd = xtgeo.grid_from_file(GRIDDATA1) grd.to_roxar(project, GRIDNAME1) por = xtgeo.gridproperty_from_file(PORODATA1, name=PORONAME1) por.to_roxar(project, GRIDNAME1, PORONAME1) zon = xtgeo.gridproperty_from_file(ZONEDATA1, name=ZONENAME1) zon.values = zon.values.astype(np.uint8) zon.to_roxar(project, GRIDNAME1, ZONENAME1) # save project (both an initla version and a work version) and exit project.save_as(prj1) project.close() yield project print("\n******* Teardown RMS project!\n") if isdir(prj1): print("Remove existing project! (1)") shutil.rmtree(prj1)
def attribute_around_constant_cube_slices(): """Get attribute around a constant cube slices""" cubefile = EXPATH1 / "ib_test_cube2.segy" level1 = 1010 level2 = 1100 mycube = xtgeo.cube_from_file(cubefile) # instead of using zrange, we make some tmp surfaces that # reflects the assymmetric; here sample slices from cube sabove = xtgeo.surface_from_cube(mycube, level1) sbelow = xtgeo.surface_from_cube(mycube, level2) if DEBUG: sabove.describe() sbelow.describe() attrs = "all" myattrs = sabove.slice_cube_window(mycube, attribute=attrs, sampling="trilinear", zsurf=sabove, other=sbelow) for attr in myattrs.keys(): if DEBUG: myattrs[attr].describe() myattrs[attr].to_file(TMPDIR / ("myfile_constlevels_" + attr + ".dat"), fformat="ijxyz")
def test_create_project(): """Create a tmp RMS project for testing, populate with basic data""" prj1 = PRJ prj2 = PRJ + "_initial" if isdir(prj1): print("Remove existing project! (1)") shutil.rmtree(prj1) if isdir(prj2): print("Remove existing project! (2)") shutil.rmtree(prj2) project = roxar.Project.create() rox = xtgeo.RoxUtils(project) print("Roxar version is", rox.roxversion) print("RMS version is", rox.rmsversion(rox.roxversion)) assert "1." in rox.roxversion # populate with cube data cube = xtgeo.cube_from_file(CUBEDATA1) cube.to_roxar(project, CUBENAME1, domain="depth") # populate with surface data rox.create_horizons_category(SURFCAT1) for num, name in enumerate(SURFNAMES1): srf = xtgeo.surface_from_file(SURFTOPS1[num]) project.horizons.create(name, roxar.HorizonType.interpreted) srf.to_roxar(project, name, SURFCAT1) # populate with grid and props grd = xtgeo.grid_from_file(GRIDDATA1) grd.to_roxar(project, GRIDNAME1) por = xtgeo.gridproperty_from_file(PORODATA1, name=PORONAME1) por.to_roxar(project, GRIDNAME1, PORONAME1) # populate with well data (postponed) # save project (both an initla version and a work version) and exit project.save_as(prj1) project.save_as(prj2) project.close()
def slice_a_cube_with_surface(): """Slice a seismic cube with a surface on OW dat/map format""" cubefile = EXPATH1 / "ib_test_cube2.segy" surfacefile = EXPATH2 / "h1.dat" mycube = xtgeo.cube_from_file(cubefile) # import map/dat surface using cube as template (inline/xline # must match) mysurf = xtgeo.surface_from_file(surfacefile, fformat="ijxyz", template=mycube) # sample cube values to mysurf (replacing current depth values) mysurf.slice_cube(mycube, sampling="trilinear") # export result mysurf.to_file(TMPDIR / "slice.dat", fformat="ijxyz")
def attribute_around_surface_symmetric(): """Get atttribute around a surface (symmetric)""" cubefile = EXPATH1 / "ib_test_cube2.segy" surfacefile = EXPATH2 / "h1.dat" mycube = xtgeo.cube_from_file(cubefile) mysurf = xtgeo.surface_from_file(surfacefile, fformat="ijxyz", template=mycube) attrs = ["max", "mean"] myattrs = mysurf.slice_cube_window(mycube, attribute=attrs, sampling="trilinear", zrange=10.0) for attr in myattrs.keys(): myattrs[attr].to_file(TMPDIR / ("myfile_symmetric_" + attr + ".dat"), fformat="ijxyz")
def attribute_around_surface_asymmetric(): """Get attribute around a surface (asymmetric)""" cubefile = EXPATH1 / "ib_test_cube2.segy" surfacefile = EXPATH2 / "h1.dat" above = 10 below = 20 mycube = xtgeo.cube_from_file(cubefile) mysurf = xtgeo.surface_from_file(surfacefile, fformat="ijxyz", template=mycube) # instead of using zrange, we make some tmp surfaces that # reflects the assymmetric sabove = mysurf.copy() sbelow = mysurf.copy() sabove.values -= above sbelow.values += below if DEBUG: sabove.describe() sbelow.describe() attrs = "all" myattrs = mysurf.slice_cube_window(mycube, attribute=attrs, sampling="trilinear", zsurf=sabove, other=sbelow) for attr in myattrs.keys(): if DEBUG: myattrs[attr].describe() myattrs[attr].to_file(TMPDIR / ("myfile_asymmetric_" + attr + ".dat"), fformat="ijxyz")
def load_cube_data(cube_path: str) -> xtgeo.Cube: return xtgeo.cube_from_file(cube_path)