Skip to content
Open
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
17 changes: 8 additions & 9 deletions bowpy/filter/fk.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,6 @@ def fk_filter(
slopes,
deltaslope,
peakpick=None,
mindist=dist,
smoothing=smoothpicks,
interactive=slopepicking,
)
Expand Down Expand Up @@ -908,7 +907,7 @@ def _fk_extract_polygon(
"""
# Shift 0|0 f-k to center, for easier handling
dsfk = np.fft.fftshift(data.conj().transpose())
dsfk_tmp = dsfk[0 : dsfk.shape[0] / 2]
dsfk_tmp = dsfk[0 : dsfk.shape[0] // 2]

# Define polygon by user-input.
# If eval_mean is true, select area where to calculate the mean value
Expand All @@ -930,10 +929,10 @@ def _fk_extract_polygon(
data_fk = np.zeros(dsfk.shape).astype("complex")

# top half of domain.
data_fk[0 : dsfk.shape[0] / 2] = dsfk_tmp
data_fk[0 : dsfk.shape[0] // 2] = dsfk_tmp

# Bottom half of domain, exploiting symmetry and shift properties.
data_fk[dsfk.shape[0] / 2 :] = np.roll(
data_fk[dsfk.shape[0] // 2 :] = np.roll(
np.roll(np.flipud(np.fliplr(dsfk_tmp)), 1).transpose(), 1
).transpose()

Expand All @@ -960,7 +959,7 @@ def _fk_eliminate_polygon(
"""
# Shift 0|0 f-k to center, for easier handling
dsfk = np.fft.fftshift(data.conj().transpose())
dsfk_tmp = dsfk[0 : dsfk.shape[0] / 2]
dsfk_tmp = dsfk[0 : dsfk.shape[0] // 2]

# Define polygon by user-input.
# If eval_mean is true, select area where to calculate the mean value
Expand All @@ -982,10 +981,10 @@ def _fk_eliminate_polygon(
data_fk = np.zeros(dsfk.shape).astype("complex")

# top half of domain.
data_fk[0 : dsfk.shape[0] / 2] = dsfk_tmp
data_fk[0 : dsfk.shape[0] // 2] = dsfk_tmp

# Bottom half of domain, exploiting symmetry and shift properties.
data_fk[dsfk.shape[0] / 2 :] = np.roll(
data_fk[dsfk.shape[0] // 2 :] = np.roll(
np.roll(np.flipud(np.fliplr(dsfk_tmp)), 1).transpose(), 1
).transpose()

Expand Down Expand Up @@ -1023,15 +1022,15 @@ def _fk_ls_filter_eliminate_phase_sp(ArrayData, y_dist=False, radius=None, maxk=
type snes: int
"""
# Define freq Array
freq = np.zeros((len(ArrayData), len(ArrayData[0]) / 2 + 1)) + 1j
freq = np.zeros((len(ArrayData), len(ArrayData[0]) // 2 + 1)) + 1j

for i in range(len(ArrayData)):
freq_new = np.fft.rfftn(ArrayData[i])
freq[i] = freq_new

# Define k Array
freqT = freq.conj().transpose()
knum = np.zeros((len(freqT), len(freqT[0]) / 2 + 1))
knum = np.zeros((len(freqT), len(freqT[0]) // 2 + 1))

# calc best range
N = len(freqT[0])
Expand Down
16 changes: 8 additions & 8 deletions bowpy/util/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,15 +531,15 @@ def line_cut(array, shape):
elif name in ["butterworth", "Butterworth", "taper", "Taper"] and isinstance(
length, int
):
fil_lh = create_filter(name, array.shape[0] / 2, length, kwarg)
fil_lh = create_filter(name, array.shape[0] // 2, length, kwarg)

elif name in ["taper", "Taper"] and isinstance(length, int):
fil_lh = create_filter(name, array.shape[0] / 2, length, kwarg)
fil_lh = create_filter(name, array.shape[0] // 2, length, kwarg)

fil_rh = np.flipud(fil_lh)[::-1][0:][::-1]
fil = np.zeros(2 * fil_lh.size)
fil[: fil.size / 2] = fil_lh
fil[fil.size / 2 :] = fil_rh
fil[: fil.size // 2] = fil_lh
fil[fil.size // 2 :] = fil_rh

new_array = array.transpose() * fil
new_array = new_array.transpose()
Expand Down Expand Up @@ -582,16 +582,16 @@ def line_set_zero(array, shape):
elif name in ["butterworth", "Butterworth", "taper", "Taper"] and isinstance(
length, int
):
fil_lh = create_filter(name, array.shape[0] / 2, length, kwarg)
fil_lh = create_filter(name, array.shape[0] // 2, length, kwarg)

elif name in ["taper", "Taper"] and isinstance(length, int):
fil_lh = create_filter(name, array.shape[0] / 2, length, kwarg)
fil_lh = create_filter(name, array.shape[0] // 2, length, kwarg)
# fil_lh = -1. * fil_lh + 1.

fil_rh = np.flipud(fil_lh)[::-1][1:][::-1]
fil = np.zeros(2 * fil_lh.size)
fil[: fil.size / 2] = fil_lh
fil[fil.size / 2 + 1 :] = fil_rh
fil[: fil.size // 2] = fil_lh
fil[fil.size // 2 + 1 :] = fil_rh
newfil = np.ones(fil.shape)
newfil = newfil - fil

Expand Down
28 changes: 14 additions & 14 deletions bowpy/util/fkutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,9 +468,9 @@ def makeMask(fkdata, slope, shape, rth=0.4, expl_cutoff=False):
pnorm = 1 / 2.0 * (float(M.shape[0] + 1) / float(2.0 * M.shape[1]))

prange = slope * pnorm
Mask = np.zeros((M.shape[0], 2.0 * M.shape[1]))
maskshape = np.zeros((M.shape[0], 2.0 * M.shape[1]))
W = np.zeros((M.shape[0], 2.0 * M.shape[1]))
Mask = np.zeros((M.shape[0], 2 * M.shape[1]))
maskshape = np.zeros((M.shape[0], 2 * M.shape[1]))
W = np.zeros((M.shape[0], 2 * M.shape[1]))
name = shape[0]
arg = shape[1]

Expand All @@ -482,16 +482,16 @@ def makeMask(fkdata, slope, shape, rth=0.4, expl_cutoff=False):

if cutoff < 1:
cutoff = 1
maskshape_tmp = create_filter(name, Mask.shape[0] / 2, cutoff, arg)
maskshape_tmp = create_filter(name, Mask.shape[0] // 2, cutoff, arg)
maskshape_lh = (
np.tile(maskshape_tmp, Mask.shape[1])
.reshape(Mask.shape[1], maskshape_tmp.size)
.transpose()
)
maskshape_rh = np.flipud(maskshape_lh)

maskshape[: maskshape.shape[0] / 2, :] = maskshape_lh
maskshape[maskshape.shape[0] / 2 :, :] = maskshape_rh
maskshape[: maskshape.shape[0] // 2, :] = maskshape_lh
maskshape[maskshape.shape[0] // 2 :, :] = maskshape_rh

for m in prange:
if m == 0.0:
Expand All @@ -511,7 +511,7 @@ def makeMask(fkdata, slope, shape, rth=0.4, expl_cutoff=False):
Mask[:, f] = np.roll(Mask[:, f], int(f * m))

W += Mask
Mask = np.zeros((M.shape[0], 2.0 * M.shape[1]))
Mask = np.zeros((M.shape[0], 2 * M.shape[1]))

# Convolving each frequency slice of the mask with a boxcar
# of size L. Widens the the maskfunction along k-axis.
Expand All @@ -535,12 +535,12 @@ def makeMask(fkdata, slope, shape, rth=0.4, expl_cutoff=False):
Wr[np.where(Wr > rth)] = 1.0
Wr[np.where(Wr < rth)] = 0.0

Wlhs = np.roll(Wr[:, 0 : Wr.shape[1] / 2 - 1], shift=1, axis=0)
Wrhs = Wr[:, 1 : Wr.shape[1] / 2 + 1]
Wlhs = np.roll(Wr[:, 0 : Wr.shape[1] // 2 - 1], shift=1, axis=0)
Wrhs = Wr[:, 1 : Wr.shape[1] // 2 + 1]
Wrhs = np.roll(np.flipud(np.fliplr(Wrhs)), shift=0, axis=0)

Wr[:, 0 : Wr.shape[1] / 2 - 1] = Wlhs
Wr[:, Wr.shape[1] / 2 :] = Wrhs
Wr[:, 0 : Wr.shape[1] // 2 - 1] = Wlhs
Wr[:, Wr.shape[1] // 2 :] = Wrhs
return Wr


Expand Down Expand Up @@ -1276,7 +1276,7 @@ def plotfk(
np.log(
abs(
np.fft.fftshift(
data[:, : data.shape[1] / 2].transpose(), axes=1
data[:, : data.shape[1] // 2].transpose(), axes=1
)
)
)
Expand All @@ -1289,7 +1289,7 @@ def plotfk(
else:
im = ax.imshow(
np.flipud(
abs(np.fft.fftshift(data[:, : data.shape[1] / 2].transpose(), axes=1))
abs(np.fft.fftshift(data[:, : data.shape[1] // 2].transpose(), axes=1))
),
aspect="auto",
extent=(-0.5, 0.5, 0, 0.5),
Expand Down Expand Up @@ -1637,7 +1637,7 @@ def slope_distribution(

pmin = prange[0]
pmax = prange[1]
N = abs(pmax - pmin) / pdelta + 1
N = int(abs(pmax - pmin) / pdelta + 1)
MD = np.zeros(N)
srange = np.linspace(pmin, pmax, N)

Expand Down
2 changes: 1 addition & 1 deletion bowpy/util/picker.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def get_polygon(
else:
xs.append(xmin)

ys = np.linspace(ymin, ymax, no_of_vert / 2)
ys = np.linspace(ymin, ymax, no_of_vert // 2)
ys = np.append(ys, ys[::-1]).tolist()

poly = Polygon(list(zip(xs, ys)), animated=True, closed=False, fill=False)
Expand Down