Skip to content

Commit

Permalink
CLN: Add types to gridprop-import-roff
Browse files Browse the repository at this point in the history
  • Loading branch information
JB Lovland authored and janbjorge committed Nov 28, 2023
1 parent 537741a commit 81d71ae
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
3 changes: 0 additions & 3 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ ignore_errors = True
[mypy-xtgeo.grid3d._gridprop_import_grdecl]
ignore_errors = True

[mypy-xtgeo.grid3d._gridprop_import_roff]
ignore_errors = True

[mypy-xtgeo.grid3d._gridprop_import_xtgcpprop]
ignore_errors = True

Expand Down
19 changes: 15 additions & 4 deletions src/xtgeo/grid3d/_gridprop_import_roff.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
"""Importing grid props from ROFF, binary"""

from __future__ import annotations

import warnings
from typing import TYPE_CHECKING, Any

import numpy as np

from xtgeo.common import null_logger

from ._roff_parameter import RoffParameter

if TYPE_CHECKING:
from xtgeo.common import _XTGeoFile
from xtgeo.grid3d import Grid

logger = null_logger(__name__)


def import_roff(pfile, name=None, grid=None):
def import_roff(
pfile: _XTGeoFile,
name: str | None = None,
grid: Grid | None = None,
) -> dict[str, Any]:
"""Import ROFF format"""

if name == "unknown":
Expand All @@ -23,7 +33,7 @@ def import_roff(pfile, name=None, grid=None):
)
name = None

result = dict()
result: dict[str, Any]= dict()
roff_param = RoffParameter.from_file(pfile._file, name)
result["codes"] = roff_param.xtgeo_codes()
result["name"] = roff_param.name
Expand All @@ -32,9 +42,10 @@ def import_roff(pfile, name=None, grid=None):
result["nlay"] = int(roff_param.nz)
result["discrete"] = roff_param.is_discrete
result["values"] = roff_param.xtgeo_values()
if grid is not None:

if grid is not None and (actnum := grid.get_actnum()):
result["values"] = np.ma.masked_where(
grid.get_actnum().values < 1,
actnum.values < 1,
result["values"],
)

Expand Down

0 comments on commit 81d71ae

Please sign in to comment.