equinor / xtgeo

XTGeo Python class library for subsurface Surfaces, Cubes, Wells, Grids, Points, etc
https://xtgeo.readthedocs.io/en/latest/
GNU Lesser General Public License v3.0
110 stars 58 forks source link

Can't write cubes to memory stream #1251

Closed tnatt closed 1 month ago

tnatt commented 1 month ago

The error below 👇 is raised in xtgeo when trying to write cubes to memory stream.

https://github.com/equinor/xtgeo/blob/2a144ec2123b192944591914adc7b4b654db5f16/src/xtgeo/io/_file.py#L304-L306

A solution would be to wrap the check_folder function in Cube.to_file() with an if not fobj.memstream like done for grids, or to stop raising an ValueError and instead return out of the function.

https://github.com/equinor/xtgeo/blob/2a144ec2123b192944591914adc7b4b654db5f16/src/xtgeo/cube/cube1.py#L871-L873

https://github.com/equinor/xtgeo/blob/2a144ec2123b192944591914adc7b4b654db5f16/src/xtgeo/grid3d/grid.py#L712-L715

jcrivenaes commented 1 month ago

... , or to stop raising an ValueError and instead return out of the function.

Agree that this is a better solution

Another problem is that support for memory stream for SEGY files must be enabled

jcrivenaes commented 1 month ago

Thin I will close this soon, as segyio currently seems not be able to support memory streams. However it would trigger a few new issues that can be solved as separate issues: