Metadata-Version: 2.1
Name: seismic-python
Version: 0.0.1a0
Summary: Wavefield Imaging
Keywords: SeismicUnix,wavefield,imaging,seismic,gpr
Author-Email: Joseph Capriotti <josephrcapriotti@gmail.com>
License: 
         The MIT License (MIT)
         
         Copyright (c) 2025 Joseph Capriotti
         
         Permission is hereby granted, free of charge, to any person obtaining a copy
         of this software and associated documentation files (the "Software"), to deal
         in the Software without restriction, including without limitation the rights
         to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         copies of the Software, and to permit persons to whom the Software is
         furnished to do so, subject to the following conditions:
         
         The above copyright notice and this permission notice shall be included in all
         copies or substantial portions of the Software.
         
         THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
         SOFTWARE.
         
Classifier: Development Status :: 1 - Planning
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Cython
Classifier: Programming Language :: C
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Topic :: Scientific/Engineering :: Physics
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX
Classifier: Operating System :: Unix
Classifier: Operating System :: MacOS
Classifier: Natural Language :: English
Project-URL: Homepage, http://github.com/jcapriot/seismic-python
Project-URL: Repository, http://github.com/jcapriot/seismic-python.git
Requires-Python: >=3.10
Requires-Dist: numpy>=1.22.4
Requires-Dist: matplotlib
Description-Content-Type: text/markdown

# seispy
This package is currently a proof of concept of directly integrating seismic unix into python. For now
we have included SU source code with enough modifications to get this simple workflow to successfully
execute on Linux, MacOS, **and Windows**!

## Installing:
If you have a working C compiler, installing is as easy as:

```bash
pip install .
```

### Requirements:
At the moment, the external package requirements are quite light:

* `numpy>=1.22.4` To handle some numerical IO
* `matplotlib`

### In place builds:
In place builds, useful for developers, can be accomplished with:

```bash
pip install --no-build-isolation --editable .
```

which requires that you already have `numpy>=2.0`, in your build environment.


> **NOTE**: On Windows you might have to append `--config-settings=setup-args="--vsenv"` to the `pip install` command,
> if you have the mingw compilers on your system, and you require the visual studio compilers for ABI
> compatibility with your python installation.


## The idea:
Seismic unix is dependant on a bash styled unix system, piping outputs between different programs
that all consume and generate either 1 trace, or 1 gather of traces at a time, and dump their output
streams to a file.

E.G.
```bash
suplane | subfilt > out.su
```


The process of working with limited amounts of data at a time, piping it through different programs
allowing each to work sequentially on each trace can easily be mimicked in Python using iterators!

Consider this simple iterator, which adds an echo to `range`:

```Python
>>> def create_data(n):
...     for i in range(n):
...         print(f"creating {i}")
...         yield i
...
```

Evocations of `create_data` return generators:
```Python
>>> type(create_data(3))
<class 'generator'>
```
that do not execute until asked for a value.

```Python
>>> items = [i for i in create_data(3)]
creating 0
creating 1
creating 2
```

But what we can also do is consume generators in other generators!
```Python
>>> def multiply(items, scale):
...     for item in items:
...         print(f"multiplying {item}")
...         yield item * scale
...
```

Chain operators together gives:
```Python
>>> mul_items = [item for item in multiply(create_data(3), 2.0)]
creating 0
multiplying 0
creating 1
multiplying 1
creating 2
multiplying 2
>>> mul_items
[0.0, 2.0, 4.0]
```
The way to think about iterators is that you ask it to return a value. This chain of iterators then
recursively asks for the next value from its input, and so on until one of them actually gives a value
back to work with. This behavoir mimics the exact operations done by SU programs.

## Interfacing with SU
Since we are basically replacing all IO operations of seismic unix with python iterators, we can just rely
on python to handle all of the IO operations when necessary, and we no longer rely on having a unix shell
like interface, meaning this code compiles and works on all systems. My intention is to make as much use
as possible of the proven C code already written in seismic unix. For this purpose, Cython was the clearest
candidate to facilitate that low-level communication between C and Python. Also, transferring the `make` files
in seismic unix to `meson` helped to ensure proper linkage within the project.

Currently, the base `cwp`, `par` and `su` libraries are built and linked into the python package.

A little bit more subtleties here is that I'm using cython iterators to do the above operations, with
the intention of releasing the GIL when inside calls to enable threading. 