Skip to content

Commit

Permalink
Merge pull request #10 from FESOM/fix-packaging
Browse files Browse the repository at this point in the history
Fix packaging
  • Loading branch information
kacpnowak authored Mar 5, 2024
2 parents aed5929 + a0496ff commit 4b49ab6
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 31 deletions.
4 changes: 3 additions & 1 deletion implicit_filter/jax_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from ._jax_function import make_smooth, make_smat, make_smat_full, transform_veloctiy_to_nodes
from ._utils import VeryStupidIdeaError, SolverNotConvergedError
from implicit_filter.filter import Filter
from scipy.sparse import csc_matrix, identity
from scipy.sparse import csc_matrix, identity, spdiags
from scipy.sparse.linalg import cg


Expand Down Expand Up @@ -97,6 +97,8 @@ def _compute(self, n, kl, ttu, tol=1e-6, maxiter=150000) -> np.ndarray:
Smat1 = csc_matrix((self._ss * (1.0 / jnp.square(kl)), (self._ii, self._jj)), shape=(self._n2d, self._n2d))
Smat = identity(self._n2d) + 0.5 * (Smat1 ** n)

# b = Smat.diagonal()
# pre = csc_matrix((b, (np.arange(self._n2d), np.arange(self._n2d))), shape=(self._n2d, self._n2d))
ttw = ttu - Smat @ ttu # Work with perturbations

tts, code = cg(Smat, ttw, tol=tol, maxiter=maxiter)
Expand Down
40 changes: 39 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,42 @@ requires = [
"setuptools>=42",
"wheel"
]
build-backend = "setuptools.build_meta"
build-backend = "setuptools.build_meta"

[project]
name = "implicit_filter"
version = "0.1.0"
description = "Python package implementing implicit filtering method on any type of mesh."
readme = "readme.md"
authors = [{ name = "Kacper Nowak", email = "[email protected]" }]

classifiers = [
"Development Status :: 3 - Alpha",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
]

requires-python = ">=3.9,<3.11"

dynamic = ["dependencies"]
[tool.setuptools.dynamic]
dependencies = {file = ["requirements.txt"]}

[project.optional-dependencies]
gpu = [
"cupy"
]

[project.urls]
Homepage = "https://github.com/FESOM/implicit_filter"

[tool.setuptools]
platforms = ["any"]
zip-safe = false
include-package-data = true

[tool.setuptools.packages.find]
where = ["implicit_filter"]
include = ["implicit_filter*"]


26 changes: 26 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,29 @@ For optimal performance usage of Nvidia GPU is highly recommended.

**IO:** Xarray


## Installation
Currently Python version 3.10 and 3.9 are supported. Using newer version can enabled
```shell
source ./path/to/enviroment/of/your/choice
git clone https://github.com/FESOM/implicit_filter

cd implicit_filter
# CPU only installation
pip install -e .
# GPU installation
pip install -e .[gpu]
```
### Known issues
Installing CuPy can cause an error, in case this happens try installing it manually:

```shell
pip install cupy
```

In case it also doesn't work, check your Nvidia driver version using `nvidia-smi` and install
CuPy version matching your drivers.

# Tutorial

Lets start with loading FESOM mesh file and data that we want to filter
Expand All @@ -45,6 +68,9 @@ from implicit_filter import CuPyFilter
flter = CuPyFilter()
flter.prepare_from_file(path + "fesom.mesh.diag.nc")
```
JAX warning might appear about GPU not being available, but it should be ignored.

If you don't have GPU support enabled importing CuPyFilter will cause an import error.

Alternatively you can set arrays by yourself, but this is shown in notebooks in examples.

Expand Down
7 changes: 3 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ contourpy==1.0.5
cycler==0.11.0
fastrlock==0.8
fonttools==4.25.0
jax==0.3.25
jaxlib==0.3.25
jax==0.4.25
jaxlib==0.4.25
kiwisolver==1.4.4
matplotlib==3.7.1
munkres==1.1.4
Expand All @@ -27,5 +27,4 @@ six==1.16.0
tornado==6.3.2
typing_extensions==4.7.1
wheel==0.38.4
xarray==2023.6.0
cupy==12.1.0
xarray==2023.6.0
25 changes: 0 additions & 25 deletions setup.cfg

This file was deleted.

4 changes: 4 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from setuptools import setup

if __name__ == "__main__":
setup()

0 comments on commit 4b49ab6

Please sign in to comment.