forked from equinor/xtgeo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b2824d2
commit a6c459f
Showing
27 changed files
with
1,698 additions
and
902 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
[build-system] | ||
requires = [ | ||
"scikit-build-core[pyproject]", | ||
"swig", | ||
"numpy==1.19.2; python_version == '3.8'", | ||
"numpy==1.19.5; python_version == '3.9'", | ||
"numpy==1.21.6; python_version == '3.10'", | ||
"numpy==1.23.5; python_version == '3.11'", | ||
"scikit-build-core[pyproject]", | ||
"swig", | ||
"numpy==1.19.2; python_version == '3.8'", | ||
"numpy==1.19.5; python_version == '3.9'", | ||
"numpy==1.21.6; python_version == '3.10'", | ||
"numpy==1.23.5; python_version == '3.11'", | ||
] | ||
build-backend = "scikit_build_core.build" | ||
|
||
|
@@ -22,9 +22,7 @@ description = "XTGeo is a Python library for 3D grids, surfaces, wells, etc" | |
readme = "README.md" | ||
requires-python = ">=3.8" | ||
license = { text = "LGPL-3.0" } | ||
authors = [ | ||
{ name = "Equinor", email = "[email protected]" }, | ||
] | ||
authors = [{ name = "Equinor", email = "[email protected]" }] | ||
keywords = ["grids", "surfaces", "wells", "cubes"] | ||
classifiers = [ | ||
"Development Status :: 5 - Production/Stable", | ||
|
@@ -50,6 +48,7 @@ dependencies = [ | |
"ecl-data-io>=2.1", | ||
"h5py>=3", | ||
"hdf5plugin>=2.3", | ||
"joblib", | ||
"matplotlib>=3.3", | ||
"numpy>=1.19", | ||
"pandas>=1.1", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
"""Auxillary functions for the well class | ||
'self' is a Well() instance | ||
""" | ||
|
||
from __future__ import annotations | ||
|
||
import functools | ||
import warnings | ||
from pathlib import Path | ||
from typing import Callable, Optional | ||
|
||
import pandas as pd | ||
|
||
import xtgeo | ||
import xtgeo.cxtgeo._cxtgeo as _cxtgeo # type: ignore | ||
from xtgeo.common import XTGeoDialog | ||
|
||
from ..xyz_common._xyz_enum import _AttrName | ||
from . import _well_io | ||
|
||
xtg = XTGeoDialog() | ||
logger = xtg.functionlogger(__name__) | ||
|
||
|
||
def _data_reader_factory(file_format: Optional[str] = None): | ||
if file_format in ["rmswell", "irap_ascii", None]: | ||
return _well_io.import_rms_ascii | ||
if file_format == "hdf": | ||
return _well_io.import_hdf5_well | ||
raise ValueError( | ||
f"Unknown file format {file_format}, supported formats are " | ||
"'rmswell', 'irap_ascii' and 'hdf'" | ||
) | ||
|
||
|
||
def allow_deprecated_init(func: Callable): | ||
# This decorator is here to maintain backwards compatibility in the | ||
# construction of Well and should be deleted once the deprecation period | ||
# has expired, the construction will then follow the new pattern. | ||
@functools.wraps(func) | ||
def wrapper(self, *args, **kwargs): | ||
if not args and not kwargs: | ||
warnings.warn( | ||
"Initializing empty well is deprecated, please provide " | ||
"non-defaulted values, or use mywell = " | ||
"xtgeo.well_from_file('filename')", | ||
DeprecationWarning, | ||
) | ||
return func( | ||
self, | ||
*([0.0] * 3), | ||
"", | ||
pd.DataFrame( | ||
{ | ||
_AttrName.XNAME.value: [], | ||
_AttrName.YNAME.value: [], | ||
_AttrName.ZNAME.value: [], | ||
} | ||
), | ||
) | ||
|
||
# Checking if we are doing an initialization from file and raise a | ||
# deprecation warning if we are. | ||
if "wfile" in kwargs or ( | ||
len(args) >= 1 and isinstance(args[0], (str, Path, xtgeo._XTGeoFile)) | ||
): | ||
warnings.warn( | ||
"Initializing directly from file name is deprecated and will be " | ||
"removed in xtgeo version 4.0. Use: " | ||
"mywell = xtgeo.well_from_file('filename') instead", | ||
DeprecationWarning, | ||
) | ||
if len(args) >= 1: | ||
wfile = args[0] | ||
args = args[1:] | ||
else: | ||
wfile = kwargs.pop("wfile", None) | ||
if len(args) >= 1: | ||
fformat = args[0] | ||
args = args[1:] | ||
else: | ||
fformat = kwargs.pop("fformat", None) | ||
|
||
mfile = xtgeo._XTGeoFile(wfile) | ||
if fformat is None or fformat == "guess": | ||
fformat = mfile.detect_fformat() | ||
else: | ||
fformat = mfile.generic_format_by_proposal(fformat) | ||
kwargs = _data_reader_factory(fformat)(mfile, *args, **kwargs) | ||
kwargs["filesrc"] = mfile.file | ||
return func(self, **kwargs) | ||
return func(self, *args, **kwargs) | ||
|
||
return wrapper |
Oops, something went wrong.