Skip to content

Commit

Permalink
Rename to resfo
Browse files Browse the repository at this point in the history
  • Loading branch information
eivindjahren committed Oct 23, 2023
1 parent c25d4fd commit b9d1a7c
Show file tree
Hide file tree
Showing 38 changed files with 411 additions and 430 deletions.
28 changes: 15 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
ecl-data-io
resfo
===========
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![docs](https://readthedocs.org/projects/ecl-data-io/badge/?version=latest&style=plastic)](https://ecl-data-io.readthedocs.io/)
[![docs](https://readthedocs.org/projects/resfo/badge/?version=latest&style=plastic)](https://resfo.readthedocs.io/)

Parser for the ecl output format, such as found in files with
extensions .UNRST, .EGRID, .INIT, etc. and also the corresponding
ascii files with extension .FUNRST, .FEGRID, .FINIT, etc.
resfo (Reservoir simulator fortran output) is a parser for the output format
used by several reservoir simulators such as [opm
flow](https://github.com/OPM/opm-simulators), such as found in files with
extensions .UNRST, .EGRID, .INIT, etc. and also the corresponding ascii files
with extension .FUNRST, .FEGRID, .FINIT, etc.


Installation
============

ecl-data-io can be installed with pip:
resfo can be installed with pip:

```bash
pip install ecl-data-io
pip install resfo
```

Getting started
===============

Ecl output files consist of a sequence of named arrays. ecl-data-io does not
interpret the names, but simply give you a tuple of the name and a numpy array
with the read function:
Reservoir simulator output files consist of a sequence of named arrays. resfo
does not interpret the names, but simply give you a tuple of the name and a
numpy array with the read function:

```
import ecl_data_io as eclio
import resfo
for kw, arr in eclio.read("my_grid.egrid"):
for kw, arr in resfo.read("my_grid.egrid"):
print(kw)
>>> "FILEHEAD"
Expand All @@ -38,4 +40,4 @@ for kw, arr in eclio.read("my_grid.egrid"):
>>> "MAPAXES"
```

For more information, see [the docs](http://ecl-data-io.rtfd.io).
For more information, see [the docs](http://resfo.rtfd.io).
12 changes: 6 additions & 6 deletions docs/source/api_doc.rst
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
API-Doc
=======

.. autofunction:: ecl_data_io.lazy_read
.. autofunction:: resfo.lazy_read

.. autofunction:: ecl_data_io.read
.. autofunction:: resfo.read

.. autofunction:: ecl_data_io.write
.. autofunction:: resfo.write

.. autoclass:: ecl_data_io.Format
.. autoclass:: resfo.Format

.. autoclass:: ecl_data_io.MESS
.. autoclass:: resfo.MESS

.. autoclass:: ecl_data_io.array_entry.EclArray
.. autoclass:: resfo.array_entry.ResArray
:exclude-members: is_eof, parse
:members:
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
project = "ecl-data-io"
project = "resfo"
copyright = "2022, Equinor"
author = "Equinor"
release = "1.0.0"
Expand Down
10 changes: 5 additions & 5 deletions docs/source/developer_guide.rst
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
Building from source and running the tests
==========================================

ecl-data-io is set up to use tox which can simplify development,
resfo is set up to use tox which can simplify development,
but all that is necessary in order to get started is git, pip and python:

First, install ecl-data-io in editable mode:
First, install resfo in editable mode:

.. code-block:: console
git clone [email protected]:equinor/ecl-data-io.git
cd ecl-data-io
git clone [email protected]:equinor/resfo.git
cd resfo
pip install -e .
Second, install the dev-requirements.txt, which contains the packages ecl-data-io
Second, install the dev-requirements.txt, which contains the packages resfo
require in order to run tests:

.. code-block:: console
Expand Down
14 changes: 7 additions & 7 deletions docs/source/error_handling.rst
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
Error Handling
==============

Reading of ecl files will throw :py:class:`ecl_data_io.EclParsingError`
when the given file does not contain valid ecl data:
Reading of res files will throw :py:class:`resfo.ResfoParsingError`
when the given file does not contain valid res data:

.. doctest::

>>> from ecl_data_io import read, write, EclParsingError, EclWriteError
>>> from resfo import read, write, ResfoParsingError, ResfoWriteError
>>> from io import StringIO
>>>
>>> file_contents = StringIO("Not valid ecl content")
>>> file_contents = StringIO("Not valid res content")
>>> try:
... read(file_contents)
... except EclParsingError as e:
... except ResfoParsingError as e:
... print(e)
Expected "'" before keyword, got N at 1

Similarly, write will produce :py:class:`ecl_data_io.EclWriteError`
Similarly, write will produce :py:class:`resfo.ResfoWriteError`
when the given data is not suitable for writing.

.. doctest::

>>> try:
... write("my_file.egrid", [("FILEHEAD", ["a"*100])])
... except EclWriteError as e:
... except ResfoWriteError as e:
... print(e)
Could not convert numpy type <U100...

Expand Down
38 changes: 19 additions & 19 deletions docs/source/example_usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

Example Usage
=============
The basic usage of ecl_data_io is to use the :meth:`ecl_data_io.read`
and :meth:`ecl_data_io.write` functions:
The basic usage of resfo is to use the :meth:`resfo.read`
and :meth:`resfo.write` functions:


read
Expand All @@ -14,9 +14,9 @@ of the keywords and arrays.

.. testsetup::

>>> import ecl_data_io as eclio
>>> import resfo
>>>
>>> eclio.write(
>>> resfo.write(
... "my_grid.egrid",
... [
... ("FILEHEAD", []),
Expand All @@ -26,11 +26,11 @@ of the keywords and arrays.
... ("ACTNUM", []),
... ("MAPAXES", []),
... ],
... fileformat=eclio.Format.FORMATTED,
... fileformat=resfo.Format.FORMATTED,
... )

>>> import ecl_data_io as eclio
>>> for kw, arr in eclio.read("my_grid.egrid"):
>>> import resfo
>>> for kw, arr in resfo.read("my_grid.egrid"):
... print(kw.strip())
FILEHEAD
GRIDHEAD
Expand All @@ -42,19 +42,19 @@ MAPAXES
write
-----

The :meth:`ecl_data_io.write` function will write such files
The :meth:`resfo.write` function will write such files
from lists of keywords, array tuples:

>>> eclio.write("my_grid.egrid", [("FILEHEAD", [1]), ("GRIDHEAD", [10,10,10])])
>>> resfo.write("my_grid.egrid", [("FILEHEAD", [1]), ("GRIDHEAD", [10,10,10])])

The default format is is binary (unformatted), but it is possible to
read and write ascii (formatted) aswell:


>>> eclio.write(
>>> resfo.write(
... "my_grid.fegrid",
... {"FILEHEAD": [1], "GRIDHEAD": [10,10,10]},
... fileformat=eclio.Format.FORMATTED
... fileformat=resfo.Format.FORMATTED
... )

lazy reading
Expand All @@ -63,21 +63,21 @@ lazy reading
It is possible to read through the file without loading all arrays into
memory, ie. lazily:

>>> for item in eclio.lazy_read("my_grid.fegrid"):
>>> for item in resfo.lazy_read("my_grid.fegrid"):
... print(item.read_keyword())
FILEHEAD
GRIDHEAD


Note that :meth:`ecl_data_io.lazy_read` in the above example is a generator of array
Note that :meth:`resfo.lazy_read` in the above example is a generator of array
entries and the file will be closed once the generator is finished. Therefore,
care will have to be taken in when arrays/keywords are read from the entries.
For better control, one can pass the opened file:

>>> import ecl_data_io as eclio
>>> import resfo
>>>
>>> with open("my_grid.egrid", "rb") as f:
... generator = eclio.lazy_read(f)
... generator = resfo.lazy_read(f)
... item = next(generator)
... print(item.read_keyword())
FILEHEAD
Expand All @@ -88,15 +88,15 @@ Writing MESS
The special MESS types keyword can be written as follows:


>>> eclio.write("output.EGRID", [("MESSHEAD", eclio.MESS)])
>>> resfo.write("output.EGRID", [("MESSHEAD", resfo.MESS)])

array types
-----------

Generally, the array will translate the given python array to the
expected type of array in ecl. However, for better control a numpy
expected type of array. However, for better control a numpy
array can be passed with an explicit dtype for finer control. The
numpy dtypes are mapped to ecl file types as follows:
numpy dtypes are mapped to res file types as follows:

* INTE to `numpy.int32`
* REAL to `numpy.float32`
Expand All @@ -119,7 +119,7 @@ with the following:
>>> new_array = [2]
>>>
>>> with open("my_grid.egrid", "br+") as f: # Open with read and write
... for entry in eclio.lazy_read(f):
... for entry in resfo.lazy_read(f):
... if entry.read_keyword() == "FILEHEAD":
... entry.update(keyword="FILEHEAD", array=new_array)
... break
14 changes: 7 additions & 7 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
=======================================
ecl-data-io: Low level IO for ecl files
resfo: Low level IO for res files
=======================================

.. toctree::
Expand All @@ -20,17 +20,17 @@ Quick Start Guide

.. code-block:: console
pip install ecl_data_io
pip install resfo
Using the library
-----------------

.. testsetup::

>>> import ecl_data_io as eclio
>>> import resfo
>>>
>>> eclio.write(
>>> resfo.write(
... "my_grid.egrid",
... [
... ("FILEHEAD", []),
Expand All @@ -40,11 +40,11 @@ Using the library
... ("ACTNUM", []),
... ("MAPAXES", []),
... ],
... fileformat=eclio.Format.FORMATTED,
... fileformat=resfo.Format.FORMATTED,
... )

>>> import ecl_data_io as eclio
>>> for kw, arr in eclio.read("my_grid.egrid"):
>>> import resfo
>>> for kw, arr in resfo.read("my_grid.egrid"):
... print(kw.strip())
FILEHEAD
GRIDHEAD
Expand Down
4 changes: 2 additions & 2 deletions docs/source/the_file_format.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ the type one of the following 4 character strings:
Formatted
---------

The formatted ecl file format is very similar to the the unformatted
The formatted res file format is very similar to the the unformatted
files, except ascii. The layout is as follows

* keyword
Expand Down Expand Up @@ -72,7 +72,7 @@ formatting specifiers, based on type:
Unformatted
-----------

The unformatted ecl file format is a binary format based on the fortran fwrite.
The unformatted res file format is a binary format based on the fortran fwrite.

All numerical values are big-endian.

Expand Down
12 changes: 6 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2"]
build-backend = "setuptools.build_meta"

[project]
name = "ecl-data-io"
description="A (lazy) parser and writer for the ecl output format."
name = "resfo"
description="A (lazy) parser and writer for reservoir simulator fortran output format."
readme = "README.md"
classifiers=[
"Development Status :: 1 - Planning",
Expand All @@ -29,10 +29,10 @@ maintainers = [
text = "LGPL-3.0"

[project.urls]
"Homepage" = "https://github.com/equinor/ecl-data-io"
"Repository" = "https://github.com/equinor/ecl-data-io"
"Documentation" = "https://ecl-data-io.readthedocs.io/en/stable/"
"Bug Tracker" = "https://github.com/equinor/ecl-data-io/issues"
"Homepage" = "https://github.com/equinor/resfo"
"Repository" = "https://github.com/equinor/resfo"
"Documentation" = "https://resfo.readthedocs.io/en/stable/"
"Bug Tracker" = "https://github.com/equinor/resfo/issues"

[project.optional-dependencies]
doc = [
Expand Down
14 changes: 0 additions & 14 deletions src/ecl_data_io/errors.py

This file was deleted.

10 changes: 5 additions & 5 deletions src/ecl_data_io/__init__.py → src/resfo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ecl_data_io.version
import resfo.version

from .errors import EclParsingError, EclWriteError
from .errors import ResfoParsingError, ResfoWriteError
from .format import Format
from .read import lazy_read, read
from .types import MESS
Expand All @@ -9,14 +9,14 @@
__author__ = "Equinor"
__email__ = "[email protected]"

__version__ = ecl_data_io.version.version
__version__ = resfo.version.version

__all__ = [
"read",
"lazy_read",
"write",
"Format",
"MESS",
"EclParsingError",
"EclWriteError",
"ResfoParsingError",
"ResfoWriteError",
]
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
This module implements the read and write
functionality for formatted ecl files (see
functionality for formatted res files (see
:ref:`formatted-format`) and is
not part of the ecl-data-io public API.
not part of the resfo public API.
"""
Loading

0 comments on commit b9d1a7c

Please sign in to comment.