Skip to content

Commit

Permalink
hann window compatibility bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
xtyangpsp committed Apr 23, 2024
1 parent acbc628 commit 1f3af98
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 6 additions & 0 deletions changes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Updates in v0.8.3:
UTILS:
1. Replace obspy.core.util.base._get_function_from_entry_point for
taper hann window with scipy.signal.windows.hann for compatibility with new scipy.

=============================================================
Updates in v0.8.1
TYPES:
1. Types.CorrData.subset: clarified documentary of overwrite option. Default False.
Expand Down
8 changes: 4 additions & 4 deletions seisgo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
import matplotlib.pyplot as plt
from collections import OrderedDict
from scipy.signal import hilbert
from scipy.signal.windows import tukey
from scipy.signal.windows import tukey,hann
from obspy.clients.fdsn import Client
from obspy.core import Stream, Trace, read
from obspy.core.util.base import _get_function_from_entry_point
# from obspy.core.util.base import _get_function_from_entry_point
from obspy.signal.util import _npts2nfft
from obspy.signal.filter import bandpass
from scipy.fftpack import fft,ifft,fftfreq,next_fast_len
Expand Down Expand Up @@ -2182,7 +2182,7 @@ def taper(data,fraction=0.05,maxlen=20):
if wlen>maxlen:wlen = maxlen

# taper values
func = _get_function_from_entry_point('taper', 'hann')
func = hann #_get_function_from_entry_point('taper', 'hann')
if 2*wlen == npts:
taper_sides = func(2*wlen)
else:
Expand All @@ -2196,7 +2196,7 @@ def taper(data,fraction=0.05,maxlen=20):
wlen = int(npts*fraction)
if wlen>maxlen:wlen = maxlen
# taper values
func = _get_function_from_entry_point('taper', 'hann')
func = hann #_get_function_from_entry_point('taper', 'hann')
if 2*wlen == npts:
taper_sides = func(2*wlen)
else:
Expand Down

5 comments on commit 1f3af98

@juvenalandres
Copy link

@juvenalandres juvenalandres commented on 1f3af98 Apr 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello,

I've updated the SeisGo package but I keep getting the same error.

time segment:2014_02_01_00_00_00 to 2014_02_01_06_00_00
module 'scipy.signal' has no attribute 'hann' for DEC05

@xtyangpsp
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did you update SeisGo? Can you check whether your utils.py has been updated? The new fix is not on pip repository yet. If you downloaded SeisGo via GitHub, run in terminal: git pull. Then run: pip install . in the main SeisGo folder that contains the setup.py.

@juvenalandres
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I downloaded it via GitHub and also checked the utils.py file after I encountered the error and it seems to contain the changes. In fact I deleted the environment and created a fresh one just to make sure that everything is in place, and still got the same error.

@juvenalandres
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you reproduce the error in a fresh environment?

@xtyangpsp
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to reproduce the error. I found another place that uses ObsPy's taper function, which is the cause of the error. I have replaced it with seisgo.utils.taper(), which is independent of ObsPy's taper function. The seisgo version on both GitHub and pip has been consistently updated. I also updated and tested the seisgo_download_xcorr_demo.ipynb with the latest usage. I should run just fine. Let me know if you have any further issues with it. Thanks again for using SeisGo and report errors.

Please sign in to comment.