Metadata-Version: 2.4
Name: sbpio
Version: 0.1.0
Summary: Sub-Bottom Profiler (SBP) seismic data I/O and processing toolkit
Author-email: Ali Mohamed <aliarafa327@gmail.com>
License: MIT License
        
        Copyright (c) 2024 Ali Mohamed
        
        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.
        
Project-URL: Homepage, https://github.com/PG-Ali-E-Mohamed/sbpio
Project-URL: Repository, https://github.com/PG-Ali-E-Mohamed/sbpio
Project-URL: Issues, https://github.com/PG-Ali-E-Mohamed/sbpio/issues
Project-URL: Changelog, https://github.com/PG-Ali-E-Mohamed/sbpio/blob/main/CHANGELOG.md
Keywords: sub-bottom profiler,SBP,SEG-Y,marine geophysics,seismic processing,oceanography
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: matplotlib>=3.3
Requires-Dist: numpy>=1.20
Requires-Dist: pandas>=1.3
Requires-Dist: geopandas>=0.10
Requires-Dist: segyio>=1.9
Requires-Dist: tqdm>=4.50
Requires-Dist: scikit-image>=0.2
Requires-Dist: shapely>=1.8
Requires-Dist: pyproj>=3.1
Requires-Dist: scipy>=1.7
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov>=3.0; extra == "dev"
Requires-Dist: black>=22.0; extra == "dev"
Requires-Dist: isort>=5.0; extra == "dev"
Requires-Dist: flake8>=4.0; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"
Dynamic: license-file

# sbpio

**Sub-Bottom Profiler I/O and Processing Toolkit**

A Python library for reading, processing, and writing sub-bottom profiler (SBP) data stored in SEG-Y format.

---

## Features

- Load SEG-Y SBP files 
- Apply duplicate-trace removal
- Apply time-varying gain (TVG) with built-in or custom functions
- Recording-delay time correction
- Water-column and multiple muting
- Shot-point navigation extraction, reprojection, and shapefile export
- Cropping in specific time and traces ranges or within ROI polygon
- Coordinate reprojection (e.g., from arc seconds to UTM)
- One-shot `write_processed()` pipeline for batch export

---

## Installation

### From PyPI 

```bash
pip install sbpio
```

### From GitHub

```bash
pip install git+https://github.com/PG-Ali-E-Mohamed/sbpio.git
```

## Quick Start

```python
from sbpio import sbp

# Open a SEG-Y file
data = sbp("profile.segy")

# Display the envelope attribute
data.show()

# One-shot processing pipeline
data.write_processed(
    "output.segy",
    correct_delay=True,
    tvg={"method": 3, "kwargs": {"n": 0.2}},
    recoverable_penetration=200,
    out_projection="EPSG:32618",
)
```

---

## API Overview

### `sbp` class

The main entry point.

| Method | Description |
|---|---|
| `sbp(fname)` | Open a SEG-Y file |
| `.load()` | Load traces and optionally compute envelope |
| `.show()` | Display the profile |
| `.tvg_gain()` | Apply time-varying gain |
| `.correct_delay()` | Correct recording delay |
| `.clean_water_column()` | Mute the water column |
| `.clean_below_seafloor()` | Mute below seafloor + offset |
| `.crop()` | Define a time/trace crop window |
| `.write()` | Write to SEG-Y |
| `.write_processed()` | Full pipeline in one call |

### `nav` class

Accessed via `data.navs`.

| Method | Description |
|---|---|
| `.shot_points()` | Extract navigation from headers |
| `.coords_2_utm()` | Reproject coordinates to UTM |
| `.to_shp(outfile)` | Export to shapefile (line or points) |

### TVG methods

Three built-in gain functions are available via `tvg_gain(method=N)`:

| Key | Function | Formula |
|---|---|---|
| `1` | `power_gain_1` | `(a·t + b)^n` |
| `2` | `power_gain_2` | `t^n` |
| `3` | `power_gain_3` | `(t/dt)^n` |

The default is `tv_gamma` — a time-varying gamma correction that progressively brightens sub-seafloor reflections.

Pass a custom callable with signature `f(t, traces, **kwargs)` for full control.

---

## SEG-Y Conventions

sbpio follows standard SEG-Y Rev 1 trace header fields:

| Field | Byte location |
|---|---|
| Source X | 73 |
| Source Y | 77 |
| SourceGroupScalar | 69 |
| CoordinateUnits | 89 |
| DelayRecordingTime | 109 |
| SourceWaterDepth | 61 |
| EnergySourcePoint | 17 |

---

## Dependencies

| Package | Purpose |
|---|---|
| `segyio` | SEG-Y read/write |
| `numpy` | Array operations |
| `pandas` | Tabular data (navigation) |
| `geopandas` | Shapefile I/O |
| `shapely` | Geometry operations |
| `pyproj` | Coordinate reprojection |
| `matplotlib` | Plotting |
| `scikit-image` | Image enhancement and resize |
| `tqdm` | Progress bars |
| `scipy` | Interpolation/ Envelope calculation |
