Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: fix well export to rms for masked numpy with Nan #1284

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/xtgeo/well/_well_roxapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from xtgeo.common import XTGeoDialog, null_logger
from xtgeo.common._xyz_enum import _AttrName, _AttrType
from xtgeo.common.constants import UNDEF_INT_LIMIT, UNDEF_LIMIT
from xtgeo.common.constants import UNDEF, UNDEF_INT, UNDEF_INT_LIMIT, UNDEF_LIMIT
from xtgeo.roxutils import RoxUtils

if TYPE_CHECKING:
Expand Down Expand Up @@ -189,9 +189,11 @@ def _store_log_in_roxapi(self, lrun: Any, logname: str) -> None:

isdiscrete = False
xtglimit = UNDEF_LIMIT
apply_undef = UNDEF
if self.wlogtypes[logname] == _AttrType.DISC.value:
isdiscrete = True
xtglimit = UNDEF_INT_LIMIT
apply_undef = UNDEF_INT

store_logname = logname

Expand All @@ -215,7 +217,10 @@ def _store_log_in_roxapi(self, lrun: Any, logname: str) -> None:

vals = np.ma.masked_invalid(self.get_dataframe(copy=False)[logname].values)
vals = np.ma.masked_greater(vals, xtglimit)
vals = vals.astype(usedtype)

# to avoid that Nans behind the masks trigger RuntimeWarning, they are converted to
# the apply_undef value prior to astype() cast (see issue 1283)
vals = np.nan_to_num(vals, nan=apply_undef).astype(usedtype)
thelog.set_values(vals)

if isdiscrete:
Expand Down
Loading