Skip to content

Commit

Permalink
BUG: fix well export to rms for masked numpy with Nan
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrivenaes committed Jan 7, 2025
1 parent 1af8dbb commit 5daa411
Showing 1 changed file with 7 additions and 2 deletions.
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 priot to astype() (see issue 1283)
vals = np.nan_to_num(vals, nan=apply_undef).astype(usedtype)
thelog.set_values(vals)

if isdiscrete:
Expand Down

0 comments on commit 5daa411

Please sign in to comment.