Skip to content

Commit

Permalink
fixup: to_roxar etc
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrivenaes committed Sep 22, 2023
1 parent 646ed36 commit 824d6d4
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/xtgeo/cube/cube1.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import pathlib
import tempfile
import warnings
from typing import Any, Optional
from typing import Any, Optional, Tuple

import deprecation
import numpy as np
Expand Down Expand Up @@ -955,7 +955,7 @@ def to_roxar(
folder: Optional[str] = None,
propname: str = "seismic_attribute",
domain: str = "time",
compression: tuple = ("wavelet", 5),
compression: Tuple[str, float] = ("wavelet", 5.0),
target: str = "seismic",
): # pragma: no cover
"""Export (transfer) a cube from a XTGeo cube object to Roxar data.
Expand All @@ -974,7 +974,8 @@ def to_roxar(
propname: Name of grid property; only relevant when target is "grid" and
defaults to "seismic_attribute"
domain: 'time' (default) or 'depth'
compression (tuple): description to come...
compression: Reference to Roxar API 'compression method' and 'compression
tolerance', but implementation is pending. Hence inactive.
target: Optionally, the seismic cube can be written to the `Grid model`
tree in RMS. Internally, it will be convert to a "box" grid with one
gridproperty, before it is written to RMS. The ``compression``and
Expand Down Expand Up @@ -1081,9 +1082,10 @@ def _ensure_correct_values(self, values):

if isinstance(values, numbers.Number):
self._values = np.zeros(self.dimensions, dtype=np.float32) + values
self._values = self._values.astype(np.float32) # ensure 32 bit floats

elif isinstance(values, np.ndarray):
values = values.reshape(self.dimensions)
values = values.reshape(self.dimensions).astype(np.float32)

if not values.data.c_contiguous:
values = np.ascontiguousarray(values)
Expand All @@ -1092,4 +1094,5 @@ def _ensure_correct_values(self, values):
elif isinstance(values, (list, tuple)):
self._values = np.array(values, dtype=np.float32).reshape(self.dimensions)

self._values = self._values.astype(np.float32)
else:
raise RuntimeError("Cannot process _ensure_correct_values")

0 comments on commit 824d6d4

Please sign in to comment.