XTGeo 4.0 migration guide
This document contains a set of instructions on how to update your code to work with XTGeo 4.0.
Importing from file or Roxar
One of the most significant changes in XTGeo 4.0 relates to how files are imported. The following table lists the style that is now deprecated with its replacement function alongside it.
Note that the example file extension given in the old imports are merely suggestive and that all valid file extensions are subject to the same manner of deprecation.
Class |
Deprecated import |
Replacement |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Instantiating XTGeo objects
In addition to the deprecations related to creating XTGeo objects from file some XTGeo objects have deprecated alternative ways of being initialized.
The general principle is that default initializations are no longer supported.
Cube
Cubes have previously given default values for empty initializations. This means that you could do something like
import xtgeo
# ncol, nrow, nlay, xinc, yinc, zinc set to default values
mycube = xtgeo.Cube() # ⛔️ no longer allowed!
This pattern is no longer allowed and explicit values must be provided for at least the following keywords.
import xtgeo
mycube = xtgeo.Cube(
ncol=40,
nrow=30,
nlay=10,
xinc=25.0,
yinc=25.0,
zinc=2.0,
)
Grid
Grids have previously given default values for empty initializations. This means that if you wanted to create a default box grid you could do
import xtgeo
# Box grid with shape ncol=4, nrow=3, nlay=5
mygrid = xtgeo.Grid() # ⛔️ no longer allowed!
This functionality has been replaced with xtgeo.create_box_grid()
:
import xtgeo
mybox = xtgeo.create_box_grid(4, 3, 5)
GridProperties
Creating a GridProperties()
instance with dimensions is deprecated. Dimensions
will be inferred from any provided properties.
import xtgeo
gprops = xtgeo.GridProperties(3, 4, 5) # ⛔️ no longer allowed!
GridProperty
GridProperty’s have previously given default values for empty initializations. This is now deprecated.
import xtgeo
# ncol=4, nrow=3, nlay=4, values=np.ndarray[...]
gprop = xtgeo.GridProperty() # ⛔️ no longer allowed!
These values must now be provided explicitly.
import xtgeo
# values=np.ndarray[...]
gprop = xtgeo.GridProperty(ncol=4, nrow=3, nlay=5)
Points
It’s previously been possible to initialize a Points()
object from a
RegularSurface
. This is now deprecated.
import xtgeo
surf = xtgeo.surface_from_file("some.gri")
mypoints = xtgeo.Points(surf) # ⛔️ no longer allowed!
This functionality has been replaced with an explicit function for this purpose.
import xtgeo
surf = xtgeo.surface_from_file("some.gri")
mypoints = xtgeo.points_from_surface(surf)
RegularSurface
RegularSurface’s have previously given default values for empty initializations. This is now deprecated.
import xtgeo
# ncol=4, nrow=3, xinc = 25.0, yinc = 25.0, values = [[..], ..]
surf = xtgeo.RegularSurface() # ⛔️ no longer allowed!
These values must be provided explicitly. Note that if values=...
is not
provided it defaults to an array of zeroes.
import xtgeo
surf = xtgeo.RegularSurface(ncol=4, nrow=3, xinc=25.0, yinc=25.0)
Well
Wells can no longer be initialized empty.
import xtgeo
# rkb=0.0, xpos=0.0, ypos=0.0, wname="", df={..=[]}
well = xtgeo.Well() # ⛔️ no longer allowed!
A well must be created with these values set explicitly.
import xtgeo
well = xtgeo.Well(
rkb=100.0,
xpos=0.0,
ypos=0.0,
wname="OP_1",
df=some_dataframe
)
xtgeo.plot
The xtgeo.plot
module is now deprecated. This functionality has been moved
to its own package called xtgeoviz
which maintains the same API. To update
just change
import xtgeo.plot # ⛔️ no longer allowed! use:
import xtgeoviz.plot # same functionality, new package
In the near term we no longer automatically expose the plot
module directly
from the xtgeo
namespace. This means that you cannot use a pattern like
this:
import xtgeo
someplot = xtgeo.plot.Map() # ⛔️ no longer allowed!
You must import xtgeo.plot
explicitly:
import xtgeo.plot
someplot = xtgeo.plot.Map() # ✅
For more information about xtgeoviz feel free to check out its repository at https://github.com/equinor/xtgeoviz and its documentation at https://equinor.github.io/xtgeoviz/.
API Deprecations
This section describes method or property deprecations that apply to class methods.
Cube
segy scanning methods have been deprecated. Please use segyio if you still need the information these functions provided.
Cube.scan_segy_traces()
- deprecatedCube.scan_segy_header()
- deprecated
Grid
The following methods are deprecated but with replacements already in place.
Grid().create_box()
is deprecated. Usextgeo.create_box_grid()
instead.Grid().dataframe
is deprecated. UseGrid().get_dataframe()
instead.Grid().get_gridproperties()
is deprecated. UseGrid().gridprops
instead.Grid().get_dxdy()
is deprecated. UseGrid().get_dx()
andGrid().get_dy()
instead.
These methods are deprecating the mask
argument that they can receive. This
argument has been changed to asmasked
which is already in place.
Grid().get_actnum(mask=True)
is deprecated. Useasmasked
instead, e.g.Grid().get_actnum(asmasked=True)
.Grid().get_dz(mask=True)
is deprecated. Useasmasked
instead, e.g.Grid().get_dz(asmasked=True)
.Grid().get_ijk(mask=True)
is deprecated. Useasmasked
instead, e.g.Grid().get_ijk(asmasked=True)
.Grid().get_xyz(mask=True)
is deprecated. Useasmasked
instead, e.g.Grid().get_xyz(asmasked=True)
.
Additionally,
Grid().report_zone_mismatch()
has deprecated theonelayergrid
option. This option is redundant and unneeded.Grid().grid_from_roxar()
has deprecated thedimensions_only
option. This option is redundant and unneeded.
GridProperties
Setting
GridProperties().names
has been deprecated. Names can still be set in the following manner:for prop in gridprops: prop.name = newname
GridProperties().dataframe()
has been deprecated. UseGridProperties().get_dataframe()
instead.GridProperties.scan_keywords()
has been deprecated. Usextgeo.list_gridproperties()
instead.
These methods are deprecating the mask
argument that they can receive. This
argument has been changed to asmasked
which is already in place.
GridProperties().get_actnum(mask=True)
is deprecated. Useasmasked
instead, e.g.GridProperties().get_actnum(asmasked=True)
.GridProperties().get_ijk(mask=True)
is deprecated. Useasmasked
instead, e.g.GridProperties().get_ijk(asmasked=True)
.
GridProperty
GridProperty().values3d
has been deprecated. UseGridProperty().values
instead.GridProperty().get_actnum(mask=True)
is deprecated. Useasmasked
instead, e.g.GridProperty().get_actnum(asmasked=True)
.
Points
Points().from_list()
is deprecated. Use a direct initialization instead asPoints(values=plist)
.Points().from_dataframe()
is deprecated. UsePoints(values=df[[east, north, tvdmsl]], xname=east, yname=north, zname=tvdmsl)
instead.
Polygons
Polygons().from_list()
is deprecated. Use a direct initialization instead asPolygons(plist)
.
RegularSurface
RegularSurface().quickplot(colortable=...)
thecolortable=
argument is deprecated. Usequickplot(colormap=...)
instead.