Skip to content

Commit

Permalink
Merge pull request #2 from SRimbaud/master
Browse files Browse the repository at this point in the history
Correcting int division a
  • Loading branch information
jflamant committed Jun 6, 2017
2 parents 4507077 + 1dac60e commit 6fb73c8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@

*.pyc

# Vim ignoring swap files

*~
*.swp
*.swo

15 changes: 8 additions & 7 deletions bispy/timefrequency.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def extractRidges(self, parThresh=4, parMinD=3):

# Extract ridges
print('Extracting ridges')
self.ridges = _extractRidges(self.S0[:self.Nfft / 2, :], parThresh, parMinD)
self.ridges = _extractRidges(self.S0[:self.Nfft // 2, :], parThresh, parMinD)


def plotStokes(self, cmocean=False):
Expand All @@ -259,10 +259,10 @@ def plotStokes(self, cmocean=False):
N = np.size(self.t)
fig, ax = plt.subplots(ncols=3, figsize=(12, 5), sharey=True)

im0 = ax[0].imshow(self.S1n[:self.Nfft / 2, :], origin='lower', interpolation='none', aspect='auto',cmap=cmap, extent=[self.t.min(), self.t.max(), 0, self.f[self.Nfft / 2-1]], vmin=-1, vmax=+1)
im0 = ax[0].imshow(self.S1n[:self.Nfft // 2, :], origin='lower', interpolation='none', aspect='auto',cmap=cmap, extent=[int(self.t.min()), int(self.t.max()), 0, self.f[self.Nfft // 2-1]], vmin=-1, vmax=+1)

im1 = ax[1].imshow(self.S2n[:self.Nfft / 2, :], origin='lower', interpolation='none', aspect='auto',cmap=cmap, extent=[self.t.min(), self.t.max(), 0, self.f[self.Nfft / 2-1]], vmin=-1, vmax=+1)
im2 = ax[2].imshow(self.S3n[:self.Nfft / 2, :], origin='lower', interpolation='none', aspect='auto',cmap=cmap, extent=[self.t.min(), self.t.max(), 0, self.f[self.Nfft / 2-1]], vmin=-1, vmax=+1)
im1 = ax[1].imshow(self.S2n[:self.Nfft // 2, :], origin='lower', interpolation='none', aspect='auto',cmap=cmap, extent=[int(self.t.min()), int(self.t.max()), 0, self.f[self.Nfft // 2-1]], vmin=-1, vmax=+1)
im2 = ax[2].imshow(self.S3n[:self.Nfft // 2, :], origin='lower', interpolation='none', aspect='auto',cmap=cmap, extent=[int(self.t.min()), int(self.t.max()), 0, self.f[self.Nfft // 2-1]], vmin=-1, vmax=+1)

# adjust figure
fig.subplots_adjust(left=0.05, top=0.8, right=0.99, wspace=0.05)
Expand Down Expand Up @@ -340,10 +340,10 @@ def plotRidges(self, quivertdecim=10, cmocean=False):

N = np.size(self.t)
fig, ax = plt.subplots(ncols=3, figsize=(12, 5), sharey=True)
im0 = ax[0].imshow(self.S0[:self.Nfft / 2, :], interpolation='none', origin='lower', aspect='auto',cmap=cmap_S0, extent=[self.t.min(), self.t.max(), 0, self.f[self.Nfft / 2-1]])
im0 = ax[0].imshow(self.S0[:self.Nfft // 2, :], interpolation='none', origin='lower', aspect='auto',cmap=cmap_S0, extent=[int(self.t.min()), int(self.t.max()), 0, self.f[self.Nfft // 2-1]])


im1 = ax[1].quiver(self.t[::self.spacing][::quivertdecim], self.f[:self.Nfft / 2], np.real(ori[:self.Nfft / 2, ::quivertdecim]), (np.imag(ori[:self.Nfft / 2, ::quivertdecim])), theta[:self.Nfft / 2, ::quivertdecim], clim=[-np.pi/2, np.pi/2], cmap=cmap_theta, headaxislength=0,headlength=0.001, pivot='middle',width=0.005, scale=15)
im1 = ax[1].quiver(self.t[::int(self.spacing)][::quivertdecim], self.f[:int(self.Nfft / 2)], np.real(ori[:self.Nfft // 2, ::quivertdecim]), (np.imag(ori[:self.Nfft // 2, ::quivertdecim])), theta[:self.Nfft // 2, ::quivertdecim], clim=[-np.pi/2, np.pi/2], cmap=cmap_theta, headaxislength=0,headlength=0.001, pivot='middle',width=0.005, scale=15)

for r in self.ridges:
points = np.array([self.t[::self.spacing][r[1]], self.f[r[0]]]).T.reshape(-1, 1, 2)
Expand Down Expand Up @@ -383,7 +383,7 @@ def plotRidges(self, quivertdecim=10, cmocean=False):
ax[0].set_ylabel('Frequency [Hz]')

ax[0].set_title('Time-Frequency energy density', y=1.14)

ax[1].set_title('Instantaneous orientation', y=1.14)
ax[2].set_title('Instantaneous ellipticity', y=1.14)

Expand Down Expand Up @@ -736,6 +736,7 @@ def _extractRidges(density, parThresh, parMinD):

freqMask, timeMask = np.where(locMax)

FLAG = False #Avoid undifined FLAG if condition is false.
if len(timeMask) > 1:
FLAG = True
while FLAG:
Expand Down
2 changes: 1 addition & 1 deletion bispy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def quat2euler(q):
S2 = qqj_float[..., 1]
S3 = - qqj_float[..., 3]

a, theta, chi = Stokes2geo(S0, S1, S2, S3)
a, theta, chi, phi = Stokes2geo(S0, S1, S2, S3)

qi = quaternion.x
qk = quaternion.z
Expand Down

0 comments on commit 6fb73c8

Please sign in to comment.