Skip to content

Commit b5637d8

Browse files
committed
small bugfix wrt dependecies
1 parent a77e749 commit b5637d8

File tree

4 files changed

+33
-38
lines changed

4 files changed

+33
-38
lines changed

msnoise/api.py

+24-27
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,9 @@
2525
import pandas as pd
2626
import scipy as sp
2727
import scipy.signal as ss
28-
if sp.__version__ < "1.4.0":
29-
import scipy.fftpack as sf
30-
from scipy.fftpack.helper import next_fast_len
31-
import scipy.fftpack._fftpack as sff
32-
else:
33-
import scipy.fft as sf
34-
from scipy.fft import next_fast_len
28+
29+
import scipy.fft as sf
30+
from scipy.fft import next_fast_len
3531

3632

3733
import scipy.optimize
@@ -1659,7 +1655,7 @@ def check_and_phase_shift(trace, taper_length=20.0):
16591655
FFTdata = FFTdata * np.exp(1j * 2. * np.pi * fftfreq * dt)
16601656
FFTdata = FFTdata.astype(np.complex64)
16611657
sf.ifft(FFTdata, n=n, overwrite_x=True)
1662-
trace.data = np.real(FFTdata[:len(trace.data)]).astype(np.float)
1658+
trace.data = np.real(FFTdata[:len(trace.data)]).astype(float)
16631659
trace.stats.starttime += dt
16641660
del FFTdata, fftfreq
16651661
clean_scipy_cache()
@@ -1768,25 +1764,26 @@ def make_same_length(st):
17681764
def clean_scipy_cache():
17691765
"""This functions wraps all destroy scipy cache at once. It is a workaround
17701766
to the memory leak induced by the "caching" functions in scipy fft."""
1771-
if scipy.__version__ >= "1.4.0":
1772-
return
1773-
sff.destroy_zfft_cache()
1774-
sff.destroy_zfftnd_cache()
1775-
sff.destroy_drfft_cache()
1776-
sff.destroy_cfft_cache()
1777-
sff.destroy_cfftnd_cache()
1778-
sff.destroy_rfft_cache()
1779-
sff.destroy_ddct2_cache()
1780-
sff.destroy_ddct1_cache()
1781-
# sff.destroy_ddct4_cache()
1782-
sff.destroy_dct2_cache()
1783-
sff.destroy_dct1_cache()
1784-
# sff.destroy_dct4_cache()
1785-
sff.destroy_ddst2_cache()
1786-
sff.destroy_ddst1_cache()
1787-
sff.destroy_dst2_cache()
1788-
sff.destroy_dst1_cache()
1789-
sf.convolve.destroy_convolve_cache()
1767+
return
1768+
# if scipy.__version__ >= "1.4.0":
1769+
# return
1770+
# sff.destroy_zfft_cache()
1771+
# sff.destroy_zfftnd_cache()
1772+
# sff.destroy_drfft_cache()
1773+
# sff.destroy_cfft_cache()
1774+
# sff.destroy_cfftnd_cache()
1775+
# sff.destroy_rfft_cache()
1776+
# sff.destroy_ddct2_cache()
1777+
# sff.destroy_ddct1_cache()
1778+
# # sff.destroy_ddct4_cache()
1779+
# sff.destroy_dct2_cache()
1780+
# sff.destroy_dct1_cache()
1781+
# # sff.destroy_dct4_cache()
1782+
# sff.destroy_ddst2_cache()
1783+
# sff.destroy_ddst1_cache()
1784+
# sff.destroy_dst2_cache()
1785+
# sff.destroy_dst1_cache()
1786+
# sf.convolve.destroy_convolve_cache()
17901787

17911788

17921789
def preload_instrument_responses(session):

msnoise/move2obspy.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,9 @@
33

44
import numpy as np
55
import scipy
6-
if scipy.__version__ < "1.4.0":
7-
import scipy.fftpack as sf
8-
from scipy.fftpack.helper import next_fast_len
9-
import scipy.fftpack._fftpack as sff
10-
else:
11-
import scipy.fft as sf
12-
from scipy.fft import next_fast_len
6+
7+
import scipy.fft as sf
8+
from scipy.fft import next_fast_len
139

1410
import scipy.optimize
1511
import scipy.signal
@@ -398,7 +394,7 @@ def mwcs(current, reference, freqmin, freqmax, df, tmin, window_length, step,
398394
delta_mcoh = []
399395
time_axis = []
400396

401-
window_length_samples = np.int(window_length * df)
397+
window_length_samples = int(window_length * df)
402398
# try:
403399
# from sf.helper import next_fast_len
404400
# except ImportError:

msnoise/preprocessing.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,16 @@ def preprocess(db, stations, comps, goal_day, params, responses=None):
141141
try:
142142
# print("Reading %s" % file)
143143
# t= time.time()
144-
st = read(file, dytpe=np.float,
144+
st = read(file, dytpe=float,
145145
starttime=UTCDateTime(gd),
146146
endtime=UTCDateTime(gd)+86400,
147147
station=sta,
148148
format=params.archive_format or None)
149149
# print("done in", time.time()-t)
150150
except:
151151
logger.debug("ERROR reading file %s" % file)
152+
import traceback
153+
traceback.print_exc()
152154
# TODO add traceback (optional?)
153155
continue
154156
for tr in st:
@@ -163,7 +165,7 @@ def preprocess(db, stations, comps, goal_day, params, responses=None):
163165
else:
164166
st = tmp
165167
for tr in st:
166-
tr.data = tr.data.astype(np.float)
168+
tr.data = tr.data.astype(float)
167169
tr.stats.network = tr.stats.network.upper()
168170
tr.stats.station = tr.stats.station.upper()
169171
tr.stats.channel = tr.stats.channel.upper()

msnoise/stretch.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44

55
from .api import *
6-
from scipy import asarray as ar
6+
from numpy import asarray as ar
77
from scipy.optimize import curve_fit
88
from scipy.ndimage import map_coordinates
99

0 commit comments

Comments
 (0)