Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
include README.md
include License.md
include CONTRIBUTING.md
include CHANGES_SUMMARY.md
include TESTING.md
include requirements.txt
include pytest.ini
recursive-include examples *.ipynb
recursive-include tests *.py
global-exclude __pycache__
global-exclude *.py[co]
global-exclude .DS_Store
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ Converted from: https://github.com/metocean/diwasp

## Installation

### Basic Installation
### From Source

```bash
# Clone the repository
git clone https://github.com/SBFRF/pyDIWASP.git
cd pyDIWASP

# Install dependencies
pip install numpy scipy matplotlib
# Install the package
pip install -e .
```

### Requirements

- Python 3.6+
- Python 3.8+
- NumPy
- SciPy
- Matplotlib
Expand All @@ -38,7 +38,7 @@ pip install numpy scipy matplotlib

```python
import numpy as np
from dirspec import dirspec
from pydiwasp import dirspec

# Define instrument data structure
ID = {
Expand Down
14 changes: 3 additions & 11 deletions examples/pyDIWASP_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,9 @@
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"\n",
"# Add pyDIWASP to Python path\n",
"# This assumes you're running the notebook from the examples/ directory\n",
"# The parent directory (..) contains the pyDIWASP modules\n",
"if os.getcwd().endswith('examples'):\n",
" sys.path.insert(0, '..')\n",
"elif os.path.basename(os.getcwd()) != 'pyDIWASP':\n",
" print('Warning: Notebook should be run from examples/ directory or repo root')\n",
"\n",
"from dirspec import dirspec\n",
"from infospec import infospec\n",
"from plotspec import plotspec\n",
"# Import pyDIWASP functions\n",
"# If the package is installed (pip install -e .), you can import directly\n",
"from pydiwasp import dirspec, infospec, plotspec\n",
"\n",
"# Set random seed for reproducibility\n",
"np.random.seed(42)\n",
Expand Down
30 changes: 30 additions & 0 deletions pydiwasp/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""
pyDIWASP - DIrectional WAve SPectrum analysis in Python

Python conversion of the DIWASP package (DIrectional WAve SPectrum analysis Version 1.4)

Main Functions:
- dirspec: Main directional wave spectrum estimation
- infospec: Calculate wave statistics from spectrum
- plotspec: Plot directional spectrum
- interpspec: Interpolate spectrum to different grid
- writespec: Write spectrum to file
"""

__version__ = "0.1.0"

# Import main API functions
from .dirspec import dirspec
from .infospec import infospec, compangle
from .plotspec import plotspec
from .interpspec import interpspec
from .writespec import writespec

__all__ = [
'dirspec',
'infospec',
'compangle',
'plotspec',
'interpspec',
'writespec',
]
32 changes: 16 additions & 16 deletions dirspec.py → pydiwasp/dirspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
import numpy as np
import matplotlib.pyplot as plt
from scipy.signal import detrend
from interpspec import interpspec
from infospec import infospec
from writespec import writespec
from plotspec import plotspec
from private.velx import velx
from private.vely import vely
from private.pres import pres
from private.elev import elev
from private.vels import vels
from private.accs import accs, accz
from private.wavenumber import wavenumber
from private.IMLM import IMLM
from private.EMEP import EMEP
from private.smoothspec import smoothspec
from private.diwasp_csd import diwasp_csd
from private.check_data import check_data
from .interpspec import interpspec
from .infospec import infospec
from .writespec import writespec
from .plotspec import plotspec
from .private.velx import velx
from .private.vely import vely
from .private.pres import pres
from .private.elev import elev
from .private.vels import vels
from .private.accs import accs, accz
from .private.wavenumber import wavenumber
from .private.IMLM import IMLM
from .private.EMEP import EMEP
from .private.smoothspec import smoothspec
from .private.diwasp_csd import diwasp_csd
from .private.check_data import check_data

def dirspec(ID, SM, EP, Options_=None):
"""
Expand Down
2 changes: 1 addition & 1 deletion infospec.py → pydiwasp/infospec.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import numpy as np
from private.hsig import hsig
from .private.hsig import hsig

def infospec(SM):
"""
Expand Down
4 changes: 2 additions & 2 deletions interpspec.py → pydiwasp/interpspec.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import numpy as np
from warnings import warn
from scipy.interpolate import griddata
from private.hsig import hsig
from private.spectobasis import spectobasis
from .private.hsig import hsig
from .private.spectobasis import spectobasis

def interpspec(SMin, SMout, method='linear'):
"""
Expand Down
2 changes: 1 addition & 1 deletion plotspec.py → pydiwasp/plotspec.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import matplotlib.pyplot as plt
import numpy as np
from private.spectobasis import spectobasis
from .private.spectobasis import spectobasis

def plotspec(SM, ptype):
"""
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions pydiwasp/private/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""
Private internal functions for pyDIWASP.

This module contains internal functions used by the main analysis routines.
These are not part of the public API and may change without notice.
"""
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion private/vels.py → pydiwasp/private/vels.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from private.velz import velz
from .velz import velz

def vels(ffreqs, dirs, wns, z, depth):
"""
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
38 changes: 38 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[build-system]
requires = ["setuptools>=45", "wheel"]
build-backend = "setuptools.build_meta"
Comment thread
SBFRF marked this conversation as resolved.

[project]
name = "pyDIWASP"
version = "0.1.0"
description = "Python conversion of DIWASP: DIrectional WAve SPectrum analysis"
readme = "README.md"
authors = [
{name = "SBFRF", email = "support@sbfrf.org"}
]
license = {text = "GPL-3.0"}
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering :: Physics",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
requires-python = ">=3.8"
dependencies = [
"numpy>=1.20.0,<2.0",
"scipy>=1.7.0,<2.0",
"matplotlib>=3.3.0,<4.0",
]

[project.urls]
Homepage = "https://github.com/SBFRF/pyDIWASP"
Repository = "https://github.com/SBFRF/pyDIWASP"

[tool.setuptools.packages.find]
include = ["pydiwasp*"]
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/SBFRF/pyDIWASP",
packages=find_packages(),
packages=find_packages(include=['pydiwasp', 'pydiwasp.*']),
classifiers=[
"Development Status :: 3 - Alpha",
"Intended Audience :: Science/Research",
Expand Down
6 changes: 2 additions & 4 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
import os
from contextlib import redirect_stdout

from infospec import infospec
from interpspec import interpspec
from writespec import writespec
from pydiwasp import infospec, interpspec, writespec


class TestInfospec:
Expand Down Expand Up @@ -106,7 +104,7 @@ def test_interpspec_basic(self):

def test_interpspec_preserves_energy(self):
"""Test that interpolation approximately preserves energy."""
from private.hsig import hsig
from pydiwasp.private.hsig import hsig

# Create a peaked spectrum
freqs_in = np.linspace(0.05, 0.5, 15)
Expand Down
17 changes: 7 additions & 10 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,15 @@


import unittest
import numpy as np
from infospec import compangle
from private.hsig import hsig
from private.check_data import check_data

import numpy as np
import pytest

from pydiwasp.infospec import compangle

try:
from private.wavenumber import wavenumber
from private.hsig import hsig
from private.check_data import check_data
from pydiwasp.private.wavenumber import wavenumber
from pydiwasp.private.hsig import hsig
from pydiwasp.private.check_data import check_data
Comment thread
SBFRF marked this conversation as resolved.
except ImportError as exc:
raise ImportError(
"Could not import pyDIWASP modules. Ensure the package is installed, "
Expand Down Expand Up @@ -182,7 +179,7 @@ class TestTransferFunctions:

def test_elev_transfer_function(self):
"""Test elevation transfer function."""
from private.elev import elev
from pydiwasp.private.elev import elev

# Test parameters
w = 2 * np.pi * np.array([0.1, 0.2]) # Angular frequencies
Expand All @@ -198,7 +195,7 @@ def test_elev_transfer_function(self):

def test_pres_transfer_function(self):
"""Test pressure transfer function."""
from private.pres import pres
from pydiwasp.private.pres import pres

w = 2 * np.pi * np.array([0.1, 0.2])
dirs = np.array([0, np.pi/4, np.pi/2])
Expand Down
2 changes: 1 addition & 1 deletion tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import os
from contextlib import redirect_stdout

from dirspec import dirspec
from pydiwasp import dirspec


class TestDirspecIntegration:
Expand Down