Skip to content

Commit

Permalink
SEG-Y creation functionality (#52)
Browse files Browse the repository at this point in the history
* Remove src/segy/typing.py file and refactor ibm.py

The src/segy/typing.py file was deleted and consequently, the ibm.py file has been refactored. Now, the typing imports and alias definitions initially in the typing.py file have been moved directly into ibm.py.

* Add IBM Float conversion strategy in transforms

A new transformation strategy, IbmFloatStrategy, is introduced in the transforms module. This strategy includes conversions between IBM and IEEE formats. It allows to transform an array of data to and from these formats, enhancing the flexibility of the transformation pipeline.

* Rename field in rev0.py

The name of the field "nsamples" in the file "src/segy/standards/rev0.py" has been changed to "samples_per_trace" to provide more clarity and improve understanding of the code.

* Add SEG-Y file creation factory class

A new factory class, `SegyFactory`, has been introduced for constructing SEG-Y files from their components. This class provides methods for creating a textual header, binary header, and trace headers/templates as per the SEG-Y specifications. Additionally, it includes functionality for transforming data types and conforming to endianness requirements.

* Refactor default text header and mypy

* numerical and structured array byte swapping, dtype casting, IBM float conversions, and scaling.

* Refactor transformation pipeline creation in indexing.py

Simplified the way transformations are added to a pipeline in indexing.py. Instead of using the TransformStrategyFactory, we now use the simpler TransformFactory. Also altered pipeline calls from 'transform' to 'apply'.

* Refactor transformation pipeline in file.py

The code for setting up transformation pipeline in src/segy/file.py has been refactored for better efficiency and readability. The binary_endian is directly replaced with a byte_swap using the TransformFactory.create, thereby simplifying the pipeline addition process. This change effectively reduces the complexity and improves maintainability of the code.

* Update typer, ruff, pre-commit, and typeguard versions

The versions of four dependencies in pyproject.toml have been updated. Specifically, typer's version has been updated from 0.9.0 to 0.10.0. Additionally, ruff, pre-commit, and typeguard versions have been bumped to 0.3.4, 3.7.0, and 4.2.1, respectively.

* Refactor transform operations in factory.py

The TransformStrategyFactory related code has been simplified by using a new TransformFactory class. This refactoring effort includes streamlining the creation of "byte_swap" and "ibm_float" transforms and adjusting their application in the header and data pipelines. The revised code has a cleaner, more direct structure, contributing to better maintainability and readability.

* Set SEG-Y revision in binary header

A new line has been added to the factory inferring the SEG-Y revision from the specification and setting it in the binary header. This ensures that the binary header accurately reflects the SEG-Y standard being used.

* Add tutorial on creating new SEG-Y files

A tutorial document 'creation.ipynb' and its index entry have been newly added. This tutorial contains detailed instructions on how to create new SEG-Y files from spec specifications, import necessary modules, populate trace values, create the binary SEG-Y file, and open it with the SegyFile function.

* Update rtd dependencies

* Update rtd dependencies

* Update rtd dependencies

* Refactor dtype casting tests for better flexibility

* Refactor method name in test_transforms.py

The method test_cast_dtype_field_little was renamed to test_cast_dtype_field. This change was made to simplify the method name and make it easier to understand its function.

* Add test cases for SegyFactory functionality

This commit introduces thorough testing for the SegyFactory class which is used for creating SEG-Y files. It ensures that files created by the factory have correct values, and it properly handles improper inputs, raising expected exceptions.

* Add SegyFactory to root package and documentation

The commit introduces SegyFactory to the SEG-Y implementation. It modifies __init__.py to import and include SegyFactory in the module. The documentation in api_reference.md is also updated to describe the new class.

* Update documentation in SegyFactory class

The comments and function annotations in src/segy/factory.py have been enhanced to provide more details for better understanding of the class and its methods. This includes information such as function argument definitions, return values, as well as more descriptive explanations of each function's purpose and behavior.

* Update text header handling in factory

This commit modifies the handling of the text header in the factory module. Previously, an argument 'text' was required to create a text header. With this change, if 'text' is left blank, a default textual header will be created.

* Update return type in method docstrings

The docstrings for two methods within the `factory.py` file were updated to more accurately reflect their return types. Previously, they noted a return type of `header_template`, which was changed to `ndarray`. This change provides much clearer and precise information about what is being returned by these methods.

* Update return type descriptions in docstrings

A revision was made to correct the descriptions of the return types in the docstrings of various methods in the src/segy/factory.py file. The 'Returns' section of the docstrings for the encode_text_header, create_binary_header, create

* Increase minimum code coverage threshold

The minimum code coverage requirement has been raised from 80% to 90% in pyproject.toml. This stringent requirement will ensure a higher level of code coverage, promoting the development of reliable and maintainable software.

---------

Co-authored-by: Altay Sansal <[email protected]>
  • Loading branch information
tasansal and Altay Sansal authored Mar 26, 2024
1 parent 8b44ed6 commit 35f2de1
Show file tree
Hide file tree
Showing 16 changed files with 1,637 additions and 432 deletions.
7 changes: 7 additions & 0 deletions docs/api_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
:members:
```

## SEG-Y Factory

```{eval-rst}
.. autoclass:: segy.SegyFactory
:members:
```

## Configuration

```{eval-rst}
Expand Down
4 changes: 2 additions & 2 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
sphinx==7.2.6
sphinx-design==0.5.0
sphinxcontrib-typer==0.1.11
sphinxcontrib-typer==0.1.12
sphinx-copybutton==0.5.2
furo==2024.1.29
myst-nb==1.0.0
linkify-it-py==2.0.3
autodoc-pydantic==2.0.1
autodoc-pydantic==2.1.0
Loading

0 comments on commit 35f2de1

Please sign in to comment.