Skip to content

Commit

Permalink
dep: drop matplotlib (#69)
Browse files Browse the repository at this point in the history
+ remove matplotlib from the dependency list, as it's not needed in the actual SET calculation, but for result plotting and inspection only.
   - remove matplotlib in `pyproject.toml`, `requirements.txt` and `setup.py` files
   - move the module import of matplotlib into point.py

+ add `docs/requirements.txt` for extra dependencies needed for running notebooks

+ add `tests/requirements.txt` for extra dependencies needed for running tests
  • Loading branch information
yunjunz authored Aug 16, 2023
1 parent c27c8d7 commit b62dae7
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
command: |
export PYTHONUNBUFFERED=1
# install dependencies and source code
mamba install --verbose --yes fortran-compiler --file ${PYSOLID_HOME}/requirements.txt
mamba install --verbose --yes fortran-compiler --file ${PYSOLID_HOME}/requirements.txt --file ${PYSOLID_HOME}/tests/requirements.txt
python -m pip install ${PYSOLID_HOME}
- run:
Expand Down
4 changes: 4 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# extra dependencies required for running notebooks
cartopy
matplotlib
mintpy
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ classifiers=[
dependencies = [
"numpy",
"scipy",
"matplotlib",
]
dynamic = ["version"]

Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# for running
numpy
scipy
matplotlib
# 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 @@ -42,7 +42,6 @@ def readme():
install_requires=[
"numpy",
"scipy",
"matplotlib",
],

# package discovery
Expand Down
17 changes: 10 additions & 7 deletions src/pysolid/point.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
import os

import numpy as np
from matplotlib import pyplot as plt, ticker, dates as mdates
from scipy import signal


## Tidal constituents
Expand Down Expand Up @@ -94,10 +92,10 @@ def calc_solid_earth_tides_point(lat, lon, dt0, dt1, step_sec=60, display=False,
"""

print('PYSOLID: calculate solid Earth tides in east/north/up direction')
print('PYSOLID: lot/lon: {}/{} degree'.format(lat, lon))
print('PYSOLID: start UTC: {}'.format(dt0.isoformat()))
print('PYSOLID: end UTC: {}'.format(dt1.isoformat()))
print('PYSOLID: time step: {} seconds'.format(step_sec))
print(f'PYSOLID: lot/lon: {lat}/{lon} degree')
print(f'PYSOLID: start UTC: {dt0.isoformat()}')
print(f'PYSOLID: end UTC: {dt1.isoformat()}')
print(f'PYSOLID: time step: {step_sec} seconds')

dt_out = []
tide_e = []
Expand All @@ -108,7 +106,7 @@ def calc_solid_earth_tides_point(lat, lon, dt0, dt1, step_sec=60, display=False,
for i in range(ndays):
di = dt0.date() + dt.timedelta(days=i)
if verbose:
print('SOLID : {} {}/{} ...'.format(di.isoformat(), i+1, ndays))
print(f'SOLID : {di.isoformat()} {i+1}/{ndays} ...')

# calc tide_u/n/u for the whole day
(dt_outi,
Expand Down Expand Up @@ -185,6 +183,8 @@ def calc_solid_earth_tides_point_per_day(lat, lon, date_str, step_sec=60):
def plot_solid_earth_tides_point(dt_out, tide_e, tide_n, tide_u, lalo=None,
out_fig=None, save=False, display=True):
"""Plot the solid Earth tides at one point."""
from matplotlib import pyplot as plt, dates as mdates

# plot
fig, axs = plt.subplots(nrows=3, ncols=1, figsize=[6, 4], sharex=True)
for ax, data, label in zip(axs.flatten(),
Expand Down Expand Up @@ -227,6 +227,9 @@ def plot_power_spectral_density4tides(tide_ts, sample_spacing, out_fig=None, fig
"""Plot the power spectral density (PSD) of tides time-series.
Note: for accurate PSD analysis, a long time-series, e.g. one year, is recommended.
"""
from matplotlib import pyplot as plt, ticker
from scipy import signal

## calc PSD
freq, psd = signal.periodogram(tide_ts, fs=1/sample_spacing, scaling='density')
# get rid of zero in the first element
Expand Down
2 changes: 2 additions & 0 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# extra dependency required for testing
matplotlib

0 comments on commit b62dae7

Please sign in to comment.