Metadata-Version: 2.1
Name: pyggms
Version: 0.1.0
Summary: A Python package for seafloor topography modeling using GGM and EGGM
Home-page: https://github.com/WChao1988/pyggm_projects
Author: Luting Hua
Author-email: HUAluting1780172@outlook.com
License: UNKNOWN
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.7
Description-Content-Type: text/markdown
Requires-Dist: numpy>=1.19.0
Requires-Dist: opencv-python>=4.5.0
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: black; extra == "dev"
Requires-Dist: flake8; extra == "dev"

# pyggms

`pyggms` is a Python package for gravity field modeling and gridded prediction. It provides **GGM (Generalized Gravity Model)** and **EGGM (Extended Generalized Gravity Model)** for fitting and interpolating 2D gridded data such as satellite and shipborne gravity measurements.

## Features

- Grid modeling based on radial basis functions (RBF)
- Joint fitting of irregular shipborne points and gridded gravity anomalies
- Direct generation of prediction matrices for output grids
- Built-in latitude/longitude bounds and Gaussian smoothing parameters

## Installation

### Dependencies

- Python >= 3.7
- numpy
- opencv-python

### Install via pip

```bash
pip install pyggms
git clone https://github.com/WChao1988/pyggm_projects.git
cd pyggms
pip install .
```
### Quick start
import numpy as np
from pyggms import ggmModel, eggmModel
from cv2 import resize

# Load data
faa_matrix = np.loadtxt('faa_matrix_22_19_157_160.txt')
faa_matrix = resize(faa_matrix, (720, 720))          # resample to target size
ship_grid = np.loadtxt('ship_matrix_22_19_157_160.txt')

# Initialize GGM model
gm = ggmModel(
    c0=1.63,
    lat_up=22, lat_down=19,
    lon_left=157, lon_right=160,
    radius=0.5,
    sigma=0.0001
)

# Fit the model
reference_depth = ship_grid.min()
gm.fit(faa_matrix, ship_grid, reference_depth)

# Predict full grid
ggm_matrix = gm.prediction_matrix()

# Initialize EGGM model
egm = eggmModel(
    c0=1.63,
    c1=0.83,
    lat_up=22, lat_down=19,
    lon_left=157, lon_right=160,
    radius=0.5,
    sigma=0.5
)

# Fit EGGM model
egm.fit(ggm_matrix, faa_matrix, ship_grid, reference_depth)

# Final prediction
eggm_matrix = egm.predict_matrix()

API Reference
```ggmModel
Parameter	Type	Description
c0	float	Primary model coefficient
lat_up, lat_down	float	Northern / southern latitude bounds
lon_left, lon_right	float	Western / eastern longitude bounds
radius	float	Radial basis function radius
sigma	float	Regularization parameter
```
Main methods:

fit(faa_matrix, ship_grid, reference_depth): Fit the model

prediction_matrix(): Return the fitted regular grid matrix

