From 513ab1543d6c354c4566190e0d02f35b2948e117 Mon Sep 17 00:00:00 2001 From: Zhang Yunjun Date: Wed, 16 Aug 2023 11:38:09 +0800 Subject: [PATCH] dep: drop matplotlib + 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 --- docs/requirements.txt | 4 ++++ pyproject.toml | 1 - requirements.txt | 1 - setup.py | 1 - src/pysolid/point.py | 17 ++++++++++------- tests/requirements.txt | 2 ++ 6 files changed, 16 insertions(+), 10 deletions(-) create mode 100644 docs/requirements.txt create mode 100644 tests/requirements.txt diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 0000000..33675f6 --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,4 @@ +# extra dependencies required for running notebooks +cartopy +matplotlib +mintpy diff --git a/pyproject.toml b/pyproject.toml index ba9fb9d..ca719ab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,6 @@ classifiers=[ dependencies = [ "numpy", "scipy", - "matplotlib", ] dynamic = ["version"] diff --git a/requirements.txt b/requirements.txt index 6ae98e6..6cc9738 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,6 @@ # for running numpy scipy -matplotlib # for packaging and installation #fortran-compiler # Fortran compiler across platforms through conda-forge channel pip diff --git a/setup.py b/setup.py index 20ed3f4..fe0a858 100644 --- a/setup.py +++ b/setup.py @@ -42,7 +42,6 @@ def readme(): install_requires=[ "numpy", "scipy", - "matplotlib", ], # package discovery diff --git a/src/pysolid/point.py b/src/pysolid/point.py index ef1bde3..9486d61 100644 --- a/src/pysolid/point.py +++ b/src/pysolid/point.py @@ -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 @@ -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 = [] @@ -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, @@ -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(), @@ -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 diff --git a/tests/requirements.txt b/tests/requirements.txt new file mode 100644 index 0000000..6f43c87 --- /dev/null +++ b/tests/requirements.txt @@ -0,0 +1,2 @@ +# extra dependency required for testing +matplotlib