Skip to content

Commit

Permalink
Cut scikit-image dependency (#67)
Browse files Browse the repository at this point in the history
* grid: replace `skimage.transform.resize()` with `scipy.ndimage.zoom()`, as the former is a thin wrapper around the latter. The added anti-aliasing filter in skimage might make more of a difference in other cases, but the SET is so smooth that it doesn't matter to us. Although slower, the time difference for a (400, 500) image is 0.02 vs 0.2 seconds.

* remove `scikit-image` from the dependency in the following files:
   - setup.py
   - pyproject.toml
   - requirements.txt

* remove the redundant `environment.yml` file and update README.md for it.

---------

Co-authored-by: Zhang Yunjun <[email protected]>
  • Loading branch information
scottstanie and yunjunz authored Aug 16, 2023
1 parent 045c21b commit c27c8d7
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 27 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ git clone https://github.com/insarlab/PySolid.git
# option 1: use conda to install dependencies into an existing, activated environment
conda install -c conda-forge fortran-compiler --file PySolid/requirements.txt

# option 2: use conda to create a new environment named "pysolid"
conda env create -f PySolid/environment.yml
# option 2: use conda to install dependencies into a new environment, e.g. named "pysolid"
conda create --name pysolid fortran-compiler --file PySolid/requirements.txt
conda activate pysolid

# option 3: have a Fortran compiler already installed and use pip to install the rest dependencies
Expand Down
17 changes: 0 additions & 17 deletions environment.yml

This file was deleted.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ dependencies = [
"numpy",
"scipy",
"matplotlib",
"scikit-image",
]
dynamic = ["version"]

Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
numpy
scipy
matplotlib
scikit-image
# for packaging and installation
#fortran-compiler # Fortran compiler across platforms through conda-forge channel
pip
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def readme():
"numpy",
"scipy",
"matplotlib",
"scikit-image",
],

# package discovery
Expand Down
13 changes: 8 additions & 5 deletions src/pysolid/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import os

import numpy as np
from skimage.transform import resize
from scipy import ndimage


################################## Earth tides - grid mode ###################################
Expand Down Expand Up @@ -79,13 +79,16 @@ def calc_solid_earth_tides_grid(dt_obj, atr, step_size=1e3, display=False, verbo
lon0, lon_step, width)

# resample to the input size
# via scipy.ndimage.zoom or skimage.transform.resize
if num_step > 1:
in_shape = tide_e.shape
out_shape = (int(atr['LENGTH']), int(atr['WIDTH']))
vprint('PYSOLID: resize data to the shape of {} using order-1 spline interpolation'.format(out_shape))
kwargs = dict(order=1, mode='edge', anti_aliasing=True, preserve_range=True)
tide_e = resize(tide_e, out_shape, **kwargs)
tide_n = resize(tide_n, out_shape, **kwargs)
tide_u = resize(tide_u, out_shape, **kwargs)

enu = np.stack([tide_e, tide_n, tide_u])
zoom_factors = [1, *np.divide(out_shape, in_shape)]
kwargs = dict(order=1, mode="nearest", grid_mode=True)
tide_e, tide_n, tide_u = ndimage.zoom(enu, zoom_factors, **kwargs)

# plot
if display:
Expand Down

0 comments on commit c27c8d7

Please sign in to comment.