Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies and clear out deprecation warnings. #25

Merged
merged 6 commits into from
Sep 14, 2024
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
11 changes: 9 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ on: [pull_request, push]
jobs:
tests:

runs-on: ubuntu-latest
strategy:
fail-fast: false # don't cancel other matrix jobs when one fails
matrix:
python-version: ["3.10", "3.11", "3.12"]
os: [ubuntu-latest, macos-latest, windows-latest]


runs-on: ${{ matrix.os }}

steps:
- name: Checkout
Expand All @@ -14,7 +21,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
Expand Down
5 changes: 4 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,7 @@ site itself.
- Added matplotlib dependency
- Move demos back to the parent directory using nblink
# Version 0.4.6 - Sept 13, 2024
- Fix license name in cfg
- Fix license name in cfg
# Version 0.4.7 - Sept 14, 2024
- Updating dependencies and test targets
- Fix deprecation warnings raised by numpy
28 changes: 14 additions & 14 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = solarspatialtools
version = 0.4.6
version = 0.4.7
author = 'Joe Ranalli'
author_email = [email protected]
description = A package for spatial analysis of solar energy and solar irradiance
Expand All @@ -19,14 +19,14 @@ classifiers =

[options]
install_requires =
numpy<2
pandas<=2.2.2
tables<=3.9.2
pyproj<=3.6.1
pvlib<=0.11.0
netcdf4<1.7.2
scipy<=1.14.0
matplotlib<=3.9.2
numpy
pandas
tables
pyproj
pvlib
netcdf4
scipy
matplotlib

[options.extras_require]
tests =
Expand All @@ -36,8 +36,8 @@ demos =
jupyter

docs =
sphinx
sphinx_rtd_theme
nbsphinx
ipython
nbsphinx-link
sphinx==7.4.7
sphinx_rtd_theme==2.0.0
nbsphinx==0.9.5
ipython==8.27.0
nbsphinx-link==1.3.0
6 changes: 3 additions & 3 deletions src/solarspatialtools/signalproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ def _residual(dels, freqs, phases, mask):

if method == 'diff':
if not np.any(np.array(np.shape(tf)) == 1):
raise ValueError('tf must be a 1D array for method: fit')
raise ValueError('tf must be a 1D array for method: diff')

# # Method 1: unwrap phase and take derivative
tfv = tf.values.flatten()
Expand All @@ -479,7 +479,7 @@ def _residual(dels, freqs, phases, mask):
try:
return (curve_fit(_delay_fitter,
np.expand_dims(tf.index, axis=1)[ix],
np.unwrap(np.angle(tf.loc[ix]).flatten()))[0],
np.unwrap(np.angle(tf.loc[ix]).flatten()))[0].item(),
ix)
except ValueError:
from warnings import warn
Expand Down Expand Up @@ -653,7 +653,7 @@ def compute_delays(ts_in, ts_out, mode='loop', scaling='coeff'):

extras['peak_corr'][i] = xcorr[peak_lag_index]
extras['mean_corr'][i] = np.mean(xcorr)
extras['zero_corr'][i] = xcorr[zero_lag_ind]
extras['zero_corr'][i] = xcorr[zero_lag_ind].item()

# Scale
extras['peak_corr'] *= corr_scale
Expand Down
3 changes: 3 additions & 0 deletions src/solarspatialtools/spatial.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,9 @@ def magnitude(vec):
magnitude : numeric
the magnitude of the vector
"""
# respond differently for Pandas Types
if isinstance(vec, pd.Series):
return np.sqrt(vec.iloc[0]**2 + vec.iloc[1]**2)
return np.sqrt(vec[0]**2+vec[1]**2)


Expand Down
5 changes: 4 additions & 1 deletion src/solarspatialtools/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,10 @@ def calc_quantile(timeseries, n_days="30d", quantile=0.9):
p90.index.astype(str))

# Concat this day onto the output object
out_df = pd.concat((out_df, p90), axis=0)
if len(out_df) == 0:
out_df = p90
else:
out_df = pd.concat((out_df, p90), axis=0)

# localize the timeseries and the column names back to the input
out_df = out_df.tz_localize(ts.index.tz).reindex(ts.index)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cmv.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def test_cmv_artificial(theta_deg, velocity, mode):
signals[4, :] = x
for i, delay in enumerate(delays):
signals[i, :] = np.roll(x, int(delay*fs))
df = pd.DataFrame(signals.T, index=pd.TimedeltaIndex(t, 's'))
df = pd.DataFrame(signals.T, index=pd.to_timedelta(t, 's'))

# Compute the CMV
cld_spd, cld_dir, dat = cmv.compute_cmv(df, pos_utm,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def test_compute_delays(delay, delay_method):
y3 = np.roll(x, int(3*delay * fs))
y4 = np.roll(x, int(4*delay * fs))

df = pd.DataFrame(np.array([x,y1,y2,y3,y4]).T, index=pd.TimedeltaIndex(t, 's'), columns=['x1','x2','x3','x4','x5'])
df = pd.DataFrame(np.array([x,y1,y2,y3,y4]).T, index=pd.to_timedelta(t, 's'), columns=['x1','x2','x3','x4','x5'])
ref = 'x1'

delays, coh = field.compute_delays(df, ref, navgs=5, coh_limit=0.6, freq_limit=1, method=delay_method)
Expand All @@ -154,7 +154,7 @@ def test_compute_delays_nan(delay_method):
y3 = np.roll(x, int(3*delay * fs))
y4 = np.nan * np.zeros_like(y3)

df = pd.DataFrame(np.array([x,y1,y2,y3,y4]).T, index=pd.TimedeltaIndex(t, 's'), columns=['x1','x2','x3','x4','x5'])
df = pd.DataFrame(np.array([x,y1,y2,y3,y4]).T, index=pd.to_timedelta(t, 's'), columns=['x1','x2','x3','x4','x5'])
ref = 'x1'

delays, coh = field.compute_delays(df, ref, navgs=5, coh_limit=0.6, freq_limit=1, method=delay_method)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_irradiance.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_clearsky_index():
assert_allclose(out, expected, atol=0.001)

# GHI series & CS series
times = pd.date_range(start='20180601', periods=2, freq='12H')
times = pd.date_range(start='20180601', periods=2, freq='12h')
ghi_measured = pd.Series([100, 500], index=times)
ghi_modeled = pd.Series([500, 1000], index=times)
out = clearsky_index(ghi_measured, ghi_modeled)
Expand All @@ -44,7 +44,7 @@ def test_clearsky_index():
assert out.values == approx(expected.values)

# GHI 2D frame & CS 1D series
times = pd.date_range(start='20180601', periods=3, freq='12H')
times = pd.date_range(start='20180601', periods=3, freq='12h')
ghi_measured = pd.DataFrame([[100, 100], [200, 200], [500, 500]], index=times)
ghi_modeled = pd.Series([500, 800, 1000], index=times)
out = clearsky_index(ghi_measured, ghi_modeled)
Expand Down
40 changes: 20 additions & 20 deletions tests/test_signalproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def test_averaged_psd():
T = 5.0 # seconds
t = np.linspace(0, T, int(T*fs), endpoint=False) # time variable
x = 0.5*np.sin(2*np.pi*2*t) # +0.1*np.sin(2*np.pi*10*t)
input_tsig = pd.Series(x, index=pd.TimedeltaIndex(t, 's'))
input_tsig = pd.Series(x, index=pd.to_timedelta(t, 's'))

# Calculate the averaged PSD using the function
navgs = 5
Expand All @@ -103,8 +103,8 @@ def test_averaged_tf():
t = np.linspace(0, T, int(T*fs), endpoint=False) # time variable
x = 0.5*np.sin(2*np.pi*2*t) # input signal
y = 0.5*np.sin(2*np.pi*2*t + np.pi/4) # output signal with phase shift
x_tsig = pd.Series(x, index=pd.TimedeltaIndex(t, 's'))
y_tsig = pd.Series(y, index=pd.TimedeltaIndex(t, 's'))
x_tsig = pd.Series(x, index=pd.to_timedelta(t, 's'))
y_tsig = pd.Series(y, index=pd.to_timedelta(t, 's'))

# Calculate the averaged transfer function using the function
navgs = 5
Expand Down Expand Up @@ -168,8 +168,8 @@ def test_tf_delay(delay):
noise = np.random.random(len(t))/5 # add broadband noise
x = 0.5*np.sin(2*np.pi*2*t) + noise # noisy signal
y = np.roll(x, int(delay*fs)) # Explicitly delay the signal
x_tsig = pd.Series(x, index=pd.TimedeltaIndex(t, 's'))
y_tsig = pd.Series(y, index=pd.TimedeltaIndex(t, 's'))
x_tsig = pd.Series(x, index=pd.to_timedelta(t, 's'))
y_tsig = pd.Series(y, index=pd.to_timedelta(t, 's'))

# Calculate the averaged transfer function using the function
navgs = 5
Expand Down Expand Up @@ -199,8 +199,8 @@ def test_tf_delay_multi(delay):
y2 = np.roll(x, int(2 * delay * fs))
y3 = np.roll(x, int(3 * delay * fs))
y4 = np.roll(x, int(4 * delay * fs))
x_tsig = pd.Series(x, index=pd.TimedeltaIndex(t, 's'))
ysigs = [pd.Series(y, index=pd.TimedeltaIndex(t, 's')) for y in
x_tsig = pd.Series(x, index=pd.to_timedelta(t, 's'))
ysigs = [pd.Series(y, index=pd.to_timedelta(t, 's')) for y in
[y1, y2, y3, y4]]
ysigs_df = pd.DataFrame(np.array(ysigs).T, columns=[0, 1, 2, 3],
index=ysigs[0].index)
Expand Down Expand Up @@ -235,8 +235,8 @@ def test_tf_delay_nan():
y3 = np.roll(x, int(3 * delay * fs))
y4 = np.nan * np.zeros_like(y3)

x_tsig = pd.Series(x, index=pd.TimedeltaIndex(t, 's'))
ysigs = [pd.Series(y, index=pd.TimedeltaIndex(t, 's')) for y in
x_tsig = pd.Series(x, index=pd.to_timedelta(t, 's'))
ysigs = [pd.Series(y, index=pd.to_timedelta(t, 's')) for y in
[y1, y2, y3, y4]]
ysigs_df = pd.DataFrame(np.array(ysigs).T, columns=[0, 1, 2, 3],
index=ysigs[0].index)
Expand Down Expand Up @@ -267,8 +267,8 @@ def test_xcorr_delay(delay):
noise = np.random.random(len(t))/5 # add broadband noise
x = 0.5*np.sin(2*np.pi*0.01*t) + noise # noisy signal
y = np.roll(x, int(delay*fs)) # Explicitly delay the signal
x_tsig = pd.Series(x, index=pd.TimedeltaIndex(t, 's'))
y_tsig = pd.Series(y, index=pd.TimedeltaIndex(t, 's'))
x_tsig = pd.Series(x, index=pd.to_timedelta(t, 's'))
y_tsig = pd.Series(y, index=pd.to_timedelta(t, 's'))

# Calculate the averaged transfer function using the function
delay_result, _ = xcorr_delay(x_tsig, y_tsig, "coeff")
Expand Down Expand Up @@ -310,7 +310,7 @@ def test_averaged_psd_multi():
x4 = 0.5 * np.sin(2 * np.pi * 2 * t) + np.random.random(len(t))

xs = [x1, x2, x3, x4]
tsigs = [pd.Series(x, index=pd.TimedeltaIndex(t, 's')) for x in xs]
tsigs = [pd.Series(x, index=pd.to_timedelta(t, 's')) for x in xs]
tsigs_df = pd.DataFrame(np.array(tsigs).T, columns=[0, 1, 2, 3], index=tsigs[0].index)
navgs = 5
overlap = 0.5
Expand Down Expand Up @@ -342,8 +342,8 @@ def test_averaged_tf_multiout():
y2 = np.roll(x, int(2*delay * fs))
y3 = np.roll(x, int(3*delay * fs))
y4 = np.roll(x, int(4*delay * fs))
x_tsig = pd.Series(x, index=pd.TimedeltaIndex(t, 's'))
ysigs = [pd.Series(y, index=pd.TimedeltaIndex(t, 's')) for y in [y1, y2, y3, y4]]
x_tsig = pd.Series(x, index=pd.to_timedelta(t, 's'))
ysigs = [pd.Series(y, index=pd.to_timedelta(t, 's')) for y in [y1, y2, y3, y4]]
ysigs_df = pd.DataFrame(np.array(ysigs).T, columns=[0, 1, 2, 3], index=ysigs[0].index)

navgs = 5
Expand Down Expand Up @@ -378,8 +378,8 @@ def test_averaged_tf_multiin():
y2 = np.roll(x, int(2*delay * fs))
y3 = np.roll(x, int(3*delay * fs))
y4 = np.roll(x, int(4*delay * fs))
x_tsig = pd.Series(x, index=pd.TimedeltaIndex(t, 's'))
ysigs = [pd.Series(y, index=pd.TimedeltaIndex(t, 's')) for y in [y1, y2, y3, y4]]
x_tsig = pd.Series(x, index=pd.to_timedelta(t, 's'))
ysigs = [pd.Series(y, index=pd.to_timedelta(t, 's')) for y in [y1, y2, y3, y4]]
ysigs_df = pd.DataFrame(np.array(ysigs[0]).T, columns=[0], index=ysigs[0].index)

xsigs = [x_tsig, ysigs[0], ysigs[1], ysigs[2]]
Expand Down Expand Up @@ -416,8 +416,8 @@ def test_averaged_tf_multiboth():
y2 = np.roll(x, int(2*delay * fs))
y3 = np.roll(x, int(3*delay * fs))
y4 = np.roll(x, int(4*delay * fs))
x_tsig = pd.Series(x, index=pd.TimedeltaIndex(t, 's'))
ysigs = [pd.Series(y, index=pd.TimedeltaIndex(t, 's')) for y in [y1, y2, y3, y4]]
x_tsig = pd.Series(x, index=pd.to_timedelta(t, 's'))
ysigs = [pd.Series(y, index=pd.to_timedelta(t, 's')) for y in [y1, y2, y3, y4]]
ysigs_df = pd.DataFrame(np.array(ysigs).T, columns=[0, 1, 2, 3], index=ysigs[0].index)

xsigs = [x_tsig, ysigs[0], ysigs[1], ysigs[2]]
Expand Down Expand Up @@ -464,8 +464,8 @@ def test_compute_delays(delay, compute_delays_modes):
ys.append(yi)
delay_ins.append(deli)

x_tsig = pd.Series(x, index=pd.TimedeltaIndex(t, 's'))
ysigs = [pd.Series(y, index=pd.TimedeltaIndex(t, 's')) for y in ys]
x_tsig = pd.Series(x, index=pd.to_timedelta(t, 's'))
ysigs = [pd.Series(y, index=pd.to_timedelta(t, 's')) for y in ys]
xsigs = [x_tsig for y in ys]
xsigs = pd.DataFrame(np.array(xsigs).T, index=x_tsig.index)

Expand Down