Skip to content

Commit

Permalink
WIP: Grid from cube
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrivenaes committed Sep 14, 2023
1 parent f6d07e0 commit 6321114
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 81 deletions.
134 changes: 54 additions & 80 deletions src/xtgeo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import timeit
import warnings


try:
from ._theversion import version

Expand Down Expand Up @@ -80,38 +79,30 @@ def _xprint(msg):
#
_xprint("Import matplotlib etc...DONE")

from xtgeo.common.constants import UNDEF
from xtgeo.common.constants import UNDEF_LIMIT
from xtgeo.common.constants import UNDEF_INT
from xtgeo.common.constants import UNDEF_INT_LIMIT

from xtgeo.common.exceptions import DateNotFoundError
from xtgeo.common.exceptions import KeywordNotFoundError
from xtgeo.common.exceptions import KeywordFoundNoDateError
from xtgeo.common.exceptions import WellNotFoundError
from xtgeo.common.exceptions import GridNotFoundError
from xtgeo.common.exceptions import BlockedWellsNotFoundError
from xtgeo.cxtgeo._cxtgeo import XTGeoCLibError

from xtgeo.common.xtgeo_dialog import XTGeoDialog
from xtgeo.common.constants import UNDEF, UNDEF_INT, UNDEF_INT_LIMIT, UNDEF_LIMIT
from xtgeo.common.exceptions import (
BlockedWellsNotFoundError,
DateNotFoundError,
GridNotFoundError,
KeywordFoundNoDateError,
KeywordNotFoundError,
WellNotFoundError,
)
from xtgeo.common.sys import _XTGeoFile
from xtgeo.common.xtgeo_dialog import XTGeoDialog
from xtgeo.cxtgeo._cxtgeo import XTGeoCLibError

_xprint("Import common... done")

_xprint("Import various XTGeo modules...")

from xtgeo.roxutils import roxutils
from xtgeo.roxutils.roxutils import RoxUtils

from xtgeo.well import well1
from xtgeo.well import wells
from xtgeo.well import blocked_well
from xtgeo.well import blocked_wells

from xtgeo.well.well1 import Well
from xtgeo.well.wells import Wells
from xtgeo.well import blocked_well, blocked_wells, well1, wells
from xtgeo.well.blocked_well import BlockedWell
from xtgeo.well.blocked_wells import BlockedWells
from xtgeo.well.well1 import Well
from xtgeo.well.wells import Wells

_xprint("Import various XTGeo modules... wells...")

Expand All @@ -126,83 +117,66 @@ def _xprint(msg):

_xprint("Import various XTGeo modules... cube...")

from xtgeo.grid3d import grid
from xtgeo.grid3d import grid_property
from xtgeo.grid3d import grid_properties

from xtgeo.grid3d import Units
from xtgeo.grid3d import GridRelative
from xtgeo.grid3d import GridRelative, Units, grid, grid_properties, grid_property
from xtgeo.grid3d.grid import Grid
from xtgeo.grid3d.grid_properties import GridProperties, gridproperties_dataframe
from xtgeo.grid3d.grid_property import GridProperty
from xtgeo.grid3d.grid_properties import GridProperties
from xtgeo.grid3d.grid_properties import gridproperties_dataframe

_xprint("Import various XTGeo modules... 3D grids...")

from xtgeo.xyz import points
from xtgeo.xyz import polygons

from xtgeo.metadata.metadata import (
MetaDataCPGeometry,
MetaDataCPProperty,
MetaDataRegularCube,
MetaDataRegularSurface,
MetaDataWell,
)
from xtgeo.xyz import points, polygons
from xtgeo.xyz.points import Points
from xtgeo.xyz.polygons import Polygons

from xtgeo.metadata.metadata import MetaDataRegularSurface
from xtgeo.metadata.metadata import MetaDataRegularCube
from xtgeo.metadata.metadata import MetaDataCPGeometry
from xtgeo.metadata.metadata import MetaDataCPProperty
from xtgeo.metadata.metadata import MetaDataWell


_xprint("Import various XTGeo modules... xyz...")

if not ROXAR:
from xtgeo.plot import baseplot
from xtgeo.plot import xsection
from xtgeo.plot import xtmap
from xtgeo.plot import grid3d_slice
from xtgeo.plot import baseplot, grid3d_slice, xsection, xtmap

_xprint("Import various XTGeo modules... plots...")

_xprint("Import various XTGeo modules...DONE")

# some function wrappers to initiate objects from imports
_xprint("Import various XTGeo wrappers...")
from xtgeo.surface.regular_surface import surface_from_file
from xtgeo.surface.regular_surface import surface_from_roxar
from xtgeo.surface.regular_surface import surface_from_cube
from xtgeo.surface.regular_surface import surface_from_grid3d

from xtgeo.grid3d.grid import grid_from_file
from xtgeo.grid3d.grid import grid_from_roxar
from xtgeo.grid3d.grid import create_box_grid

from xtgeo.grid3d.grid_property import gridproperty_from_file
from xtgeo.grid3d.grid_property import gridproperty_from_roxar

from xtgeo.cube.cube1 import cube_from_file, cube_from_roxar
from xtgeo.grid3d.grid import (
create_box_grid,
grid_from_cube,
grid_from_file,
grid_from_roxar,
)
from xtgeo.grid3d.grid_properties import gridproperties_from_file

from xtgeo.cube.cube1 import cube_from_file
from xtgeo.cube.cube1 import cube_from_roxar

from xtgeo.well.well1 import well_from_file
from xtgeo.well.well1 import well_from_roxar

from xtgeo.grid3d.grid_property import gridproperty_from_file, gridproperty_from_roxar
from xtgeo.surface.regular_surface import (
surface_from_cube,
surface_from_file,
surface_from_grid3d,
surface_from_roxar,
)
from xtgeo.well.blocked_well import blockedwell_from_file, blockedwell_from_roxar
from xtgeo.well.blocked_wells import blockedwells_from_files, blockedwells_from_roxar
from xtgeo.well.well1 import well_from_file, well_from_roxar
from xtgeo.well.wells import wells_from_files

from xtgeo.well.blocked_well import blockedwell_from_file
from xtgeo.well.blocked_well import blockedwell_from_roxar

from xtgeo.well.blocked_wells import blockedwells_from_roxar
from xtgeo.well.blocked_wells import blockedwells_from_files

from xtgeo.xyz.polygons import polygons_from_file
from xtgeo.xyz.polygons import polygons_from_roxar
from xtgeo.xyz.polygons import polygons_from_wells

from xtgeo.xyz.points import points_from_file
from xtgeo.xyz.points import points_from_roxar
from xtgeo.xyz.points import points_from_surface
from xtgeo.xyz.points import points_from_wells
from xtgeo.xyz.points import points_from_wells_dfrac
from xtgeo.xyz.points import (
points_from_file,
points_from_roxar,
points_from_surface,
points_from_wells,
points_from_wells_dfrac,
)
from xtgeo.xyz.polygons import (
polygons_from_file,
polygons_from_roxar,
polygons_from_wells,
)

warnings.filterwarnings("default", category=DeprecationWarning, module="xtgeo")

Expand Down
36 changes: 35 additions & 1 deletion src/xtgeo/grid3d/grid.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
"""Module/class for 3D grids (corner point geometry) with XTGeo."""
from __future__ import annotations

import functools
import json
Expand Down Expand Up @@ -163,7 +164,7 @@ def create_box_grid(
origin (tuple of float): Startpoint of grid (x, y, z)
oricenter (bool): If False, startpoint is node, if True, use cell center
increment (tuple of float): Grid increments (xinc, yinc, zinc)
rotation (float): Roations in degrees, anticlock from X axis.
rotation (float): Rotation in degrees, anticlock from X axis.
flip (int): If +1, grid origin is lower left and left-handed;
if -1, origin is upper left and right-handed (row flip).
Expand All @@ -184,6 +185,39 @@ def create_box_grid(
return Grid(**kwargs)


def grid_from_cube(
cube: xtgeo.Cube, prop_name: str = "seismics", oricenter: bool = True
):
"""Create a rectangular 'shoebox' grid from an existing cube.
The cube values itself will then be stored with name given by property key.
Since the cube actually is node centered, while grids are cell oriented,
the geometries here are shifted half an increment as default. To avoiud this, use
oricenter=False.
Args:
cube: The xtgeo Cube instance
prop_name: Name of seismic property, if None then only the grid geometry
will be made
oricenter: Default is True, to treat seismic nodes as cell center values in
a grid.
.. versionadded:: 3.24
"""

grd = create_box_grid(
cube.dimensions,
(cube.xori, cube.yori, cube.zori),
oricenter=oricenter,
increment=(cube.xinc, cube.yinc, cube.zinc),
rotation=cube.rotation,
flip=cube.yflip,
)
grd.prop
return grd


# --------------------------------------------------------------------------------------
# Comment on dual porosity grids:
#
Expand Down

0 comments on commit 6321114

Please sign in to comment.