Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Corrected default values of xextent in specgram(). Fixes Bug #7666. #7692

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

Merged
merged 2 commits into from
Dec 29, 2016
Merged

Corrected default values of xextent in specgram(). Fixes Bug #7666. #7692

merged 2 commits into from
Dec 29, 2016

Conversation

DietBru
Copy link
Contributor

@DietBru DietBru commented Dec 27, 2016

Let's the time axis start from the midpoint of the first segment instead at 0. Details are in the bug report #7666.

Todo:

  • Deal with failing image comparison tests.
  • Pad the sides

@tacaswell
Copy link
Member

Should these be padded out to be the left and right edges of the first and last segments so that the mid points of the pixels are the midpoint of the time bins?

@tacaswell tacaswell added this to the 2.1 (next point release) milestone Dec 27, 2016
@DietBru
Copy link
Contributor Author

DietBru commented Dec 27, 2016

@tacaswell, I'm not quite sure, if I understand what you mean by padding: The length in of the spectrogram is always shorter then the signal (by nfft-1 samples in my example). With the fix, the point in time is exactly at the midpoint of the segment (i.e., window function).

@tacaswell
Copy link
Member

The extent kwarg sets where the edges of the image will be placed. If t is the midpoints, then this starts the first pixel at the mid point of the first time window and the last pixel ends at the midpoint of the last bin. I think the correct behavior should be that each pixel starts and stops on the edges of the time window represents (or is at least centered on the time window if there is overlap).

@DietBru
Copy link
Contributor Author

DietBru commented Dec 27, 2016

Ah, now I understand:
specgram_nov_correct
specgram_nov_default
Never noticed that, because I usually try to maximize the overlap.

@codecov-io
Copy link

codecov-io commented Dec 27, 2016

Current coverage is 62.07% (diff: 100%)

Merging #7692 into master will increase coverage by <.01%

@@             master      #7692   diff @@
==========================================
  Files           174        174          
  Lines         56021      56022     +1   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits          34773      34776     +3   
+ Misses        21248      21246     -2   
  Partials          0          0          

Powered by Codecov. Last update ab98852...c3a8574

@DietBru
Copy link
Contributor Author

DietBru commented Dec 28, 2016

Padding Fixed:
specgram_nov0
specgram_nov255

@tacaswell
Copy link
Member

Thanks, LGTM to me!

This is another case where we would have asked you to squash and re-base (to only have one set of the regenerated images in the repository history), but in general you do not have to squash down to a single commit.

@@ -7228,7 +7229,9 @@ def specgram(self, x, NFFT=None, Fs=None, Fc=None, detrend=None,
Z = np.flipud(Z)

if xextent is None:
xextent = 0, np.max(t)
# padding is needed for first and last segment:
pad_xextnt = (NFFT-noverlap) / Fs / 2
Copy link
Member

Choose a reason for hiding this comment

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

pad_xextent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@QuLogic QuLogic merged commit 32fd303 into matplotlib:master Dec 29, 2016
@tacaswell
Copy link
Member

Thanks @vollbier 🎉

I think this is your first contribution to mpl, hopefully there will be many more!

@DietBru
Copy link
Contributor Author

DietBru commented Dec 29, 2016

I hope so too.

@QuLogic
Copy link
Member

QuLogic commented Dec 31, 2016

@tacaswell added this to the 2.1 (next point release) milestone 4 days ago

#7666 says 2.0.1?

@tacaswell
Copy link
Member

Bumped the issue to 2.1, I think this change is too big to put into 2.0 (at least on top of the rc). I am very open to be convinced otherwise.

@DietBru
Copy link
Contributor Author

DietBru commented Jan 2, 2017

@tacaswell I have no idea, how such changes disturb matplotlib's release cycles. From the user's point of view, I would tend to include it: I stumbled upon this issue while comparing spectrograms to Wigner-Ville distributions for certain signals. It lead me at first to the wrong conclusion, that spectrograms give biased estimates, which can be a quite serious roadblock for further investigations.

@tacaswell tacaswell modified the milestones: 2.0 (style change major release), 2.1 (next point release) Jan 2, 2017
tacaswell pushed a commit that referenced this pull request Jan 2, 2017
Corrected default values of xextent in specgram(). Fixes Bug #7666.

Conflicts:
	lib/matplotlib/axes/_axes.py
	   kept backported version, overlapping changes do to other cleanups
@tacaswell
Copy link
Member

@vollbier sold.

backported as v2.x 6afa9ce

@DietBru DietBru deleted the specgram_default_params branch January 2, 2017 17:34
@DietBru DietBru restored the specgram_default_params branch January 4, 2017 20:15
@DietBru DietBru deleted the specgram_default_params branch January 4, 2017 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants