fourier demo

To the wxpython / matplotlib community:

I wanted to share the enclosed "Fourier Demo" GUI, which is a reimplementation of one of the very first MATLAB GUIs that I worked on at MathWorks in 1993 (right when Handle Graphics was introduced in MATLAB 4). It presents you with two waveforms - a Fourier transform pair - and allows you to manipulate some parameters (via clicking the waveforms and dragging, and controls) and shows how the waveforms are related.

I was very happy about how easily it came together and the performance of the resulting GUI. In particular the matplotlib events and interaction with wx is quite nice, especially the 'hitlist' of matplotlib figures.

Note this is some of my first wx GUI programming so if you see anything that could be handled with a better pattern / class / etc, I am very open to such suggestions!

Sincerely,
   Tom K.

sigdemo.py (7.93 KB)

Very nice demo. Some feedback for you.

When I dragged the curve in the time domain window, sometimes I get :

... line 160, in mouseMotion
    self.f0.set(1./(1./f0Init+(1./f0Init*(x-x0)/x0)))
ZeroDivisionError: float division

Regards,

Fahri

···

On Sun, Jan 11, 2009 at 9:36 AM, Tom Krauss <tpk@kraussfamily.org> wrote:

To the wxpython / matplotlib community:

I wanted to share the enclosed "Fourier Demo" GUI, which is a
reimplementation of one of the very first MATLAB GUIs that I worked on at
MathWorks in 1993 (right when Handle Graphics was introduced in MATLAB 4).
It presents you with two waveforms - a Fourier transform pair - and allows
you to manipulate some parameters (via clicking the waveforms and dragging,
and controls) and shows how the waveforms are related.

I was very happy about how easily it came together and the performance of
the resulting GUI. In particular the matplotlib events and interaction with
wx is quite nice, especially the 'hitlist' of matplotlib figures.

Note this is some of my first wx GUI programming so if you see anything that
could be handled with a better pattern / class / etc, I am very open to such
suggestions!

Sincerely,
Tom K.

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

thanks Tom,

this is really a very beautiful example,
so much functionality with so few lines of (still readable) code,
and even not forgotten the tiny details, like the nicely formatted formulas in the figures.

Although MatPlotLib is not part of wxPython (but OGL isn't either),
I would strongly suggest to add this example to the wxPython demos.

I think the example might also be interesting for the following lists:
  matplotlib-users@lists.sourceforge.net
  scipy-user@scipy.org

And I guess the great java applets shown here
  http://www.jhu.edu/~signals/index.html
can be implemented in the same way ?

Please show us more of these great examples.

cheers,
Stef

Tom Krauss wrote:

···

To the wxpython / matplotlib community:

I wanted to share the enclosed "Fourier Demo" GUI, which is a reimplementation of one of the very first MATLAB GUIs that I worked on at MathWorks in 1993 (right when Handle Graphics was introduced in MATLAB 4). It presents you with two waveforms - a Fourier transform pair - and allows you to manipulate some parameters (via clicking the waveforms and dragging, and controls) and shows how the waveforms are related.

I was very happy about how easily it came together and the performance of the resulting GUI. In particular the matplotlib events and interaction with wx is quite nice, especially the 'hitlist' of matplotlib figures.

Note this is some of my first wx GUI programming so if you see anything that could be handled with a better pattern / class / etc, I am very open to such suggestions!

Sincerely,
  Tom K.
------------------------------------------------------------------------

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

Fahri - Thanks for the feedback.
Here's a patch for a newer version, that avoids this problem.

--- a/sigdemo.py Sun Jan 11 08:12:36 2009 -0600
+++ b/sigdemo.py Sun Jan 11 16:48:47 2009 -0600
@@ -144,7 +144,7 @@
             self.state = 'time'
         else:
             self.state = ''
- self.mouseInfo = (evt.xdata, evt.ydata, self.f0.value,
self.A.value)
+ self.mouseInfo = (evt.xdata, evt.ydata, max(self.f0.value, .1),
self.A.value)

     def mouseMotion(self, evt):
         if self.state == '':
@@ -157,7 +157,8 @@
         if self.state == 'frequency':
             self.f0.set(f0Init+(f0Init*(x-x0)/x0))
         elif self.state == 'time':
- self.f0.set(1./(1./f0Init+(1./f0Init*(x-x0)/x0)))
+ if (x-x0)/x0 != -1.:
+ self.f0.set(1./(1./f0Init+(1./f0Init*(x-x0)/x0)))
                     
     def mouseUp(self, evt):
         self.state = ''

Fahreddın Basegmez wrote:

···

Very nice demo. Some feedback for you.

When I dragged the curve in the time domain window, sometimes I get :

... line 160, in mouseMotion
    self.f0.set(1./(1./f0Init+(1./f0Init*(x-x0)/x0)))
ZeroDivisionError: float division

Regards,

Fahri

--
View this message in context: http://www.nabble.com/fourier-demo-tp21399817p21407146.html
Sent from the wxPython-users mailing list archive at Nabble.com.

Hi Stef, thanks for the kind words, I'm glad you like the demo!

I'd be happy to help adding it to the wxPython demos, but I am not sure how
to go about that. It might make sense under a "matplotlib" tab.

As far as those other signal processing demos - very cool, thanks for
sharing! I am not planning on doing anything further like that, my purpose
was to write something to learn wxPython programming better especially with
embedded matplotlib plots. I was thinking about maybe trying something with
images next where the image data responds to the mouse.

However I am also quite interested in contributing to open source since
lately (especially last 2+ years) I've been benefitting tremendously from it
in my work. I guess I wanted to share my simple application because, if I
had had something like this available it would have been helpful, and maybe
now my bit of work can help others. The demo actually builds on some of the
work I saw on embedded matplotlib graphics (that was my starting point for a
wx.Window that contains both a Figure and a canvas) but goes a bit farther
than the stuff I found.

Also, thanks for the suggestions about cross posting, I was planning on
doing so to the matplotlib user's list - I'll try to post the (corrected,
latest) sigdemo.py now.

Regards,
  Tom

Stef Mientki-2 wrote:

···

thanks Tom,

this is really a very beautiful example,
so much functionality with so few lines of (still readable) code,
and even not forgotten the tiny details, like the nicely formatted
formulas in the figures.

Although MatPlotLib is not part of wxPython (but OGL isn't either),
I would strongly suggest to add this example to the wxPython demos.

I think the example might also be interesting for the following lists:
  matplotlib-users@lists.sourceforge.net
  scipy-user@scipy.org

And I guess the great java applets shown here
  http://www.jhu.edu/~signals/index.html
can be implemented in the same way ?

Please show us more of these great examples.

cheers,
Stef

--
View this message in context: http://www.nabble.com/fourier-demo-tp21399817p21407381.html
Sent from the wxPython-users mailing list archive at Nabble.com.

Tom,

Hi Stef, thanks for the kind words, I'm glad you like the demo!

I'd be happy to help adding it to the wxPython demos, but I am not sure how
to go about that. It might make sense under a "matplotlib" tab.
  
I'm sure Robin, Andrea G. or Chris B. (oddly enough, they're all guys) can give you some pointers on how to get it included in the demo.

Mike

···

As far as those other signal processing demos - very cool, thanks for
sharing! I am not planning on doing anything further like that, my purpose
was to write something to learn wxPython programming better especially with
embedded matplotlib plots. I was thinking about maybe trying something with
images next where the image data responds to the mouse.

However I am also quite interested in contributing to open source since
lately (especially last 2+ years) I've been benefitting tremendously from it
in my work. I guess I wanted to share my simple application because, if I
had had something like this available it would have been helpful, and maybe
now my bit of work can help others. The demo actually builds on some of the
work I saw on embedded matplotlib graphics (that was my starting point for a
wx.Window that contains both a Figure and a canvas) but goes a bit farther
than the stuff I found.

Also, thanks for the suggestions about cross posting, I was planning on
doing so to the matplotlib user's list - I'll try to post the (corrected,
latest) sigdemo.py now.

Regards,
  Tom

Stef Mientki-2 wrote:
  

thanks Tom,

this is really a very beautiful example,
so much functionality with so few lines of (still readable) code,
and even not forgotten the tiny details, like the nicely formatted formulas in the figures.

Although MatPlotLib is not part of wxPython (but OGL isn't either),
I would strongly suggest to add this example to the wxPython demos.

I think the example might also be interesting for the following lists:
  matplotlib-users@lists.sourceforge.net
  scipy-user@scipy.org

And I guess the great java applets shown here
  http://www.jhu.edu/~signals/index.html
can be implemented in the same way ?

Please show us more of these great examples.

cheers,
Stef

Mike Driscoll wrote:

Tom,

Hi Stef, thanks for the kind words, I'm glad you like the demo!

I'd be happy to help adding it to the wxPython demos, but I am not sure how
to go about that. It might make sense under a "matplotlib" tab.
  
I'm sure Robin, Andrea G. or Chris B. (oddly enough, they're all guys) can give you some pointers on how to get it included in the demo.

Mike

Oops...just found this page on the wxPython website: http://wxpython.org/contribute.php

That should get you going on getting your demo ready for inclusion if they decide they want it.

···

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org
Python Extension Building Network: http://www.pythonlibrary.org

Hi All,

Tom,

Hi Stef, thanks for the kind words, I'm glad you like the demo!

I'd be happy to help adding it to the wxPython demos, but I am not sure
how
to go about that. It might make sense under a "matplotlib" tab.

I'm sure Robin, Andrea G. or Chris B. (oddly enough, they're all guys) can
give you some pointers on how to get it included in the demo.

It is a very nice demo indeed, although I am not sure it should be
included in the main wxPython demo. Obviously I have no voice
whatsoever on what should and should not be added to the demo (or to
wxPython itself, these decisions remain always with Robin), but my
impression is that the correct place for your nice demo is Matplotlib
rather than wxPython.

Just my 2c.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

···

On Mon, Jan 12, 2009 at 3:42 PM, Mike Driscoll wrote:

Tom K. wrote:

Hi Stef, thanks for the kind words, I'm glad you like the demo!

I'd be happy to help adding it to the wxPython demos, but I am not sure how
to go about that. It might make sense under a "matplotlib" tab.

In this case it might be better to put it on the wiki since it depends on matplotlib. Putting it in the wiki will also give you an opportunity to give more information and to teach the reader how to do what you did.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin Dunn wrote:

Tom K. wrote:

Hi Stef, thanks for the kind words, I'm glad you like the demo!

I'd be happy to help adding it to the wxPython demos, but I am not sure how
to go about that. It might make sense under a "matplotlib" tab.

In this case it might be better to put it on the wiki since it depends on matplotlib. Putting it in the wiki will also give you an opportunity to give more information and to teach the reader how to do what you did.

Well if you say so ....
... but then I wonder, why there's an opengl demo in the wxPython demo ?

Even with opengl installed it complains about can't find opengl :wink:

cheers,
Stef

Stef Mientki wrote:

Robin Dunn wrote:

Tom K. wrote:

Hi Stef, thanks for the kind words, I'm glad you like the demo!

I'd be happy to help adding it to the wxPython demos, but I am not sure how
to go about that. It might make sense under a "matplotlib" tab.

In this case it might be better to put it on the wiki since it depends on matplotlib. Putting it in the wiki will also give you an opportunity to give more information and to teach the reader how to do what you did.

Well if you say so ....
... but then I wonder, why there's an opengl demo in the wxPython demo ?

Because wx provides a GLCanvas class for hosting OpenGL drawings. OTOH wx does not provide anything special for integrating with matplotlib, that comes from matplotlib itself.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Folks, thanks for the discussion. I'll try to put it on the wxPyWiki as soon
as I get a chance.

Regards,
  Tom

Robin Dunn wrote:

···

Stef Mientki wrote:

Robin Dunn wrote:

Tom K. wrote:

Hi Stef, thanks for the kind words, I'm glad you like the demo!

I'd be happy to help adding it to the wxPython demos, but I am not
sure how
to go about that. It might make sense under a "matplotlib" tab.

In this case it might be better to put it on the wiki since it depends
on matplotlib. Putting it in the wiki will also give you an
opportunity to give more information and to teach the reader how to do
what you did.

Well if you say so ....
... but then I wonder, why there's an opengl demo in the wxPython demo ?

Because wx provides a GLCanvas class for hosting OpenGL drawings. OTOH
wx does not provide anything special for integrating with matplotlib,
that comes from matplotlib itself.

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

--
View this message in context: http://www.nabble.com/fourier-demo-tp21399817p21449193.html
Sent from the wxPython-users mailing list archive at Nabble.com.