Re: [matplotlib-devel] Bug in eps output of matplotlib

2010-02-09 Thread Michael Droettboom
I believe the bug actually is in matplotlib, and recent ghostscript versions 
fail only because they have become stricter over time.  The TTF-to-Postscript 
font conversion library in matplotlib (ttconv) was hard-coded to use the 
"Standard" Postscript encoding (which defines the set of glyphs available for 
use), and "Standard" doesn't include the "/minus" sign.  This confuses 
ghostscript when it tries to convert a Type 3 Postscript font to a Type 3 PDF 
font.  Since detecting the correct "built-in" encoding to use when converting 
an arbitrary TTF file is rather tricky (and matplotlib can use some pretty 
esoteric Unicode characters when drawing math expressions), my workaround is to 
create a custom encoding for each font, containing only the glyphs actually 
being used.  Postscript has a limitation of 255 glyphs per font in a custom 
encoding, but in practice it should be difficult to hit this.  Surprisingly (to 
me at least), using a wacky arbitrary encoding doesn't break the Find/R!
!
eplace and accessibility functions on the resulting PDF file.

So, this is now fixed in SVN trunk, I believe.  As a workaround for released 
versions of matplotlib, you can set ps.fonttype to 42 which sidesteps the whole 
Type 3 font subsetting/encoding issue.  At least on my machine, I had no 
trouble converting a PS file with Type 42 fonts to a PDF with ps2pdf/gs 8.70.

Thanks for your help tracking this down.

Mike

--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Comparison of mlab.csd and Matlab's cpsd

2010-02-09 Thread Ariel Rokem
Hi everyone,

Mystery solved (I think)! It turns out that matlab has two functions, one
called "hann" and the other called "hanning". They both purport to produce
the hanning window, but they produce two (slightly) different things. Only
one of these (the one given by "hann") actually produces the hanning window
as it is defined in the standard reference on this (Harris 1978. And also
Wikipedia ;D). When using the "hann" function in Matlab in this little
experiment, the difference between the python and the matlab results, is on
the order of %10e-6. I think I am willing to live with that.

The only mystery that remains (I think) is - what is Matlab's "hanning"
supposed to be doing? Are there two different windows: hann and hanning (not
"hamming" - I know that's a different one)?

Cheers,

Ariel


On Mon, Feb 8, 2010 at 9:32 AM, Ariel Rokem  wrote:

> Hi -
>
> the maximal difference in this case is of about 6 (units?), which is an
> approximately 50% difference. This is in one point in the spectrum which has
> a relatively small value - the maximal peaks in the spectra are on the order
> of 1200, so in the grand scheme of things, not that horrible. Other large
> differences are on the order of 4, which is approximately 5% or less of
> those points.
>
> Thanks - Ariel
>
> PS for some reason, matplotlib-devel will not get your email unless you hit
> "reply all", so they have been getting my emails, but not yours. I am not
> sure whether that is what you intended, so I thought I would mention it.
>
>
> On Mon, Feb 8, 2010 at 1:24 AM, Ludwig Schwardt  > wrote:
>
>> Hi,
>>
>> On Mon, Feb 8, 2010 at 5:25 AM, Ariel Rokem  wrote:
>> > I don't think that the cause of the discrepancy is because of the
>> > hamming/hanning window difference. I do set the window in the matlab
>> part to
>> > also be a hanning window of length nfft.
>>
>> I suspected you gave the same window to both, but I was just
>> checking... :-) To find those smaller discrepancies might be a bit
>> harder then, requiring a careful comparison of the various steps
>> involved. Just for interest's sake, how big are the differences we are
>> talking about?
>>
>> Regards,
>> Ludwig
>>
>
>
>
> --
> Ariel Rokem
> Helen Wills Neuroscience Institute
> University of California, Berkeley
> http://argentum.ucbso.berkeley.edu/ariel
>



-- 
Ariel Rokem
Helen Wills Neuroscience Institute
University of California, Berkeley
http://argentum.ucbso.berkeley.edu/ariel
--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Comparison of mlab.csd and Matlab's cpsd

2010-02-09 Thread Ariel Rokem
Hi - mea culpa - as pointed out by a colleague (and documented in the help
document for "hanning" in Matlab), this function produces the same window,
but without the first and last zero-weighted samples.

Cheers -- Ariel

On Tue, Feb 9, 2010 at 4:58 PM, Ariel Rokem  wrote:

> Hi everyone,
>
> Mystery solved (I think)! It turns out that matlab has two functions, one
> called "hann" and the other called "hanning". They both purport to produce
> the hanning window, but they produce two (slightly) different things. Only
> one of these (the one given by "hann") actually produces the hanning window
> as it is defined in the standard reference on this (Harris 1978. And also
> Wikipedia ;D). When using the "hann" function in Matlab in this little
> experiment, the difference between the python and the matlab results, is on
> the order of %10e-6. I think I am willing to live with that.
>
> The only mystery that remains (I think) is - what is Matlab's "hanning"
> supposed to be doing? Are there two different windows: hann and hanning (not
> "hamming" - I know that's a different one)?
>
> Cheers,
>
> Ariel
>
>
> On Mon, Feb 8, 2010 at 9:32 AM, Ariel Rokem  wrote:
>
>> Hi -
>>
>> the maximal difference in this case is of about 6 (units?), which is an
>> approximately 50% difference. This is in one point in the spectrum which has
>> a relatively small value - the maximal peaks in the spectra are on the order
>> of 1200, so in the grand scheme of things, not that horrible. Other large
>> differences are on the order of 4, which is approximately 5% or less of
>> those points.
>>
>> Thanks - Ariel
>>
>> PS for some reason, matplotlib-devel will not get your email unless you
>> hit "reply all", so they have been getting my emails, but not yours. I am
>> not sure whether that is what you intended, so I thought I would mention it.
>>
>>
>>
>> On Mon, Feb 8, 2010 at 1:24 AM, Ludwig Schwardt <
>> ludwig.schwa...@gmail.com> wrote:
>>
>>> Hi,
>>>
>>> On Mon, Feb 8, 2010 at 5:25 AM, Ariel Rokem  wrote:
>>> > I don't think that the cause of the discrepancy is because of the
>>> > hamming/hanning window difference. I do set the window in the matlab
>>> part to
>>> > also be a hanning window of length nfft.
>>>
>>> I suspected you gave the same window to both, but I was just
>>> checking... :-) To find those smaller discrepancies might be a bit
>>> harder then, requiring a careful comparison of the various steps
>>> involved. Just for interest's sake, how big are the differences we are
>>> talking about?
>>>
>>> Regards,
>>> Ludwig
>>>
>>
>>
>>
>> --
>> Ariel Rokem
>> Helen Wills Neuroscience Institute
>> University of California, Berkeley
>> http://argentum.ucbso.berkeley.edu/ariel
>>
>
>
>
> --
> Ariel Rokem
> Helen Wills Neuroscience Institute
> University of California, Berkeley
> http://argentum.ucbso.berkeley.edu/ariel
>



-- 
Ariel Rokem
Helen Wills Neuroscience Institute
University of California, Berkeley
http://argentum.ucbso.berkeley.edu/ariel
--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


[matplotlib-devel] Fwd: [IPython-dev] GUI support: conflicts between IPython 0.11 and Matplotlib/ETS

2010-02-09 Thread Fernando Perez
Hi folks,

the message below is an important discussion on which we'd like
feedback/ideas both from Enthought.traits experts and matplotlib ones.
 It would be great if we could keep things in one list, so it seems
most sensible to hold the discussion in the ipython-dev list, but this
is a heads-up in case one of you is interested but may not monitor
ipython-dev.

Thanks!

f

-- Forwarded message --
From: Brian Granger 
Date: Tue, Feb 9, 2010 at 11:59 PM
Subject: [IPython-dev] GUI support: conflicts between IPython 0.11 and
Matplotlib/ETS
To: IPython Development list 


Hello all,

As many of you know, we have been working hard on IPython 0.11.  One
of the big new features of 0.11 is a refactored integration with GUI
event loops.
We are very excited about this as it is much more stable and add new
capabilities, like being able to enable pylab *after* starting IPython
(it is a magic: %pylab).

BUT, as Fernando and I have started to use the IPython 0.11 alpha for
our daily work, we have found some subtle issue with IPython 0.11 and
the current
versions of matplotlib and Enthought tool suite (traits, chaco,
mayavi).  All of these packages rely on IPython's previous way of
handling GUI
integration.  Because of this, current versions of matplotlib and ets
don't work fully with IPython 0.11.  In some cases, they work OK, but
there are a whole class
of bugs that keep popping up.  We don't want to release IPython 0.11
until these issues are resolved.

All of these bugs are related to a few aspects of creating the main
GUI app objects and starting event loops.  We think we understand the
issues, but we will
need to work with the devs of matplotlib and ets to decide on how we
all want to handle these things.  Here is where we are at...

Current situation
=

Both matplotlib and ets have code that tries to:

* See what GUI toolkit is being used
* Get the global App object if it already exists, if not create it.
* See if the main loop is running, if not possibly start it.

All of this logic makes many assumptions about how IPython affects the
answers to these
questions.  Because IPython's GUI support has changed in significant
ways, current matplotlib
and ets make incorrect decisions about these issues (such as trying to
start the event loop
a second time, creating a second main App ojbect, etc.) under IPython
0.11.  This leads to crashes...

Description of GUI support in 0.11
==

IPython allows GUI event loops to be run in an interactive IPython session.
This is done using Python's PyOS_InputHook hook which Python calls
when the :func:`raw_input` function is called and is waiting for user input.
IPython has versions of this hook for wx, pyqt4 and pygtk.  When the inputhook
is called, it iterates the GUI event loop until a user starts to type
again.  When
the user stops typing, the event loop iterates again.  This is how tk works.

When a GUI program is used interactively within IPython, the event loop of
the GUI should *not* be started. This is because, the PyOS_Inputhook itself
is responsible for iterating the GUI event loop.

IPython has facilities for installing the needed input hook for each GUI
toolkit and for creating the needed main GUI application object. Usually,
these main application objects should be created only once and for some
GUI toolkits, special options have to be passed to the application object
to enable it to function properly in IPython.

What we need to decide
===

We need to answer the following questions:

* Who is responsible for creating the main GUI application object, IPython
  or third parties (matplotlib, enthought.traits, etc.)?

* What is the proper way for third party code to detect if a GUI application
  object has already been created?  If one has been created, how should
  the existing instance be retrieved?

* In a GUI application object has been created, how should third party code
  detect if the GUI event loop is running. It is not sufficient to call the
  relevant function methods in the GUI toolkits (like ``IsMainLoopRunning``)
  because those don't know if the GUI event loop is running through the
  input hook.

* We might need a way for third party code to determine if it is running
  in IPython or not.  Currently, the only way of running GUI code in IPython
  is by using the input hook, but eventually, GUI based versions of IPython
  will allow the GUI event loop in the more traditional manner. We will need
  a way for third party code to distinguish between these two cases.

Thanks for participating in this discussion!

Cheers,

Brian


___
IPython-dev mailing list
ipython-...@scipy.org
http://mail.scipy.org/mailman/listinfo/ipython-dev

--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.