Picon
Gravatar

Re: surface plotting

Joe Harrington wrote:
> Well, I was hoping for a lighter solution, but I gave it a one-hour try.
> It didn't help that when I did the link to the user docs was broken
> (it's fixed now).  I got so far as installing mayavi2 and trying to
> figure it out without the doc, but ran out of time and wasn't able to
> figure out surface plotting my existing numpy array.  This was for use
> in a class and I decided that if I couldn't figure out how to do it in
> an hour I probably couldn't expect the students to do it at all.

Sorry about the mess with installation instructions etc.  I'm trying to 
get some help regarding this but I've been too busy otherwise to do much 
about it -- end of semester here.  I'm hoping to try and get something 
done about it over the next couple of weeks.

One of the easiest ways to get things installed without eggs right now 
is to first install the dependencies -- wxPython 2.6, python-vtk and 
numpy and then grab the tarballs here:

  http://code.enthought.com/downloads/source/ets2.6/

Untar them and build them each

  cd enthought.traits
  ./build.sh
  vi/emacs install.sh
  ./install.sh

for all the tarballs and you should have mayavi installed.  The script 
is broken in that it does not install the mayavi executable though -- 
need to fix that.
(Continue reading)

Picon
Gravatar

Re: surface plotting

fred wrote:
> Joe Harrington a écrit :
>> It would be good to have a cookbook recipe about how to do surface
>> plotting of a 2D numpy array in mayavi2.
>>   
> http://www.scipy.org/Cookbook/MayaVi/Surf
> http://www.scipy.org/Cookbook/MayaVi/mlab

Unfortunately, these still use tvtk's mlab which is lower level and not 
as powerful as mayavi's new mlab.

The best docs for that are here:

  https://svn.enthought.com/enthought/attachment/wiki/MayaVi/mlab.pdf

cheers,
prabhu
lorenzo bolla | 1 Dec 20:46
Picon
Gravatar

Re: scipy 0.6.0 ImportError: cannot import name cscmux

I had the same problem in Linux.
But in Linux there are no .pyd files.

I noticed that there were two shared libraries: sparsetools.so and _sparsetools.so.
The first one was much smaller than the second, so I moved it to a backup directory.

Then, everything worked fine.

hth,
L.


On Nov 18, 2007 11:50 AM, youngsu park <youngsu999 <at> gmail.com> wrote:

Hi. Im Youngsu-park ,in POSTECH in south korea.

I had same problem on scipy importing like:

    from scipy import *

.

So I looked at the scipy/sparse folder,

"C:\Python25\Lib\site-packages\scipy\sparse ".

To find the reason of error, I open the

"C:\Python25\Lib\site-packages\scipy\sparse\sparse.py", file.

From line 21 to 26, there was import statement for "sparsetools"

 

from scipy.sparse.sparsetools import cscmux, csrmux, \

     cootocsr, csrtocoo, cootocsc, csctocoo, csctocsr, csrtocsc, \

     densetocsr, csrtodense, \

     csrmucsr, cscmucsc, \

     csr_plus_csr, csc_plus_csc, csr_minus_csr, csc_minus_csc, \

     csr_elmul_csr, csc_elmul_csc, csr_eldiv_csr, csc_eldiv_csc

 

I change the working directory to "C:\Python25\Lib\site-packages\scipy\sparse ",

import sparestools and use dir function to see the members of sparsetools

 

In [16]: import sparsetoo

 

In [17]: dir(sparsetools)

Out[17]:

['__doc__',  '__file__',  '__name__', '__version__', 'ccootocsc', 'ccscadd', 'ccscextract',

'ccscgetel', 'ccscmucsc', 'ccscmucsr', 'ccscmul', 'ccscmux', 'ccscsetel', 'ccsctocoo',

 'ccsctofull', 'ccsrmucsc', 'ccsrmux', 'cdiatocsc', 'cfulltocsc', 'ctransp', 'dcootocsc',

 'dcscadd', 'dcscextract', 'dcscgetel', 'dcscmucsc', 'dcscmucsr', 'dcscmul', 'dcscmux',

 'dcscsetel', 'dcsctocoo', 'dcsctofull', 'dcsrmucsc', 'dcsrmux', 'ddiatocsc', 'dfulltocsc',

 'dtransp', 'scootocsc', 'scscadd', 'scscextract', 'scscgetel', 'scscmucsc', 'scscmucsr',

 'scscmul', 'scscmux', 'scscsetel', 'scsctocoo', 'scsctofull', 'scsrmucsc', 'scsrmux', 'sdiatocsc',

 'sfulltocsc', 'stransp', 'zcootocsc', 'zcscadd', 'zcscextract', 'zcscgetel', 'zcscmucsc', 'zcscmucsr',

 'zcscmul', 'zcscmux', 'zcscsetel', 'zcsctocoo', 'zcsctofull', 'zcsrmucsc', 'zcsrmux', 'zdiatocsc',

 'zfulltocsc', 'ztransp']

 

But it is not the members of sparsetools.py

I think it is the members of sparsetools.pyd.

 

Move sparsetools.pyd to some backup directory.

Then it will works well.

 

In [21]: from scipy import *

 

In [22]:


_______________________________________________
SciPy-user mailing list
SciPy-user <at> scipy.org
http://projects.scipy.org/mailman/listinfo/scipy-user


_______________________________________________
SciPy-user mailing list
SciPy-user <at> scipy.org
http://projects.scipy.org/mailman/listinfo/scipy-user
Dorian | 1 Dec 21:37
Picon

Algorithm of Viterbi

Hi all,

Is there any tools about the algorithm of Viterbi using scypi ?.
Any link on a clear tutorial will be very helpful.

Thank in advance

_______________________________________________
SciPy-user mailing list
SciPy-user <at> scipy.org
http://projects.scipy.org/mailman/listinfo/scipy-user
Emanuele Zattin | 1 Dec 21:57
Picon
Gravatar

Re: Algorithm of Viterbi

Well... it seems that Wikipedia has some Python code about it. It
shouldn't be too difficult to modify it in order to use Numpy.

Just my 0.02$

On Dec 1, 2007 9:37 PM, Dorian <wizzard028wise <at> gmail.com> wrote:
> Hi all,
>
> Is there any tools about the algorithm of Viterbi using scypi ?.
> Any link on a clear tutorial will be very helpful.
>
> Thank in advance
>
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user <at> scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>
>

--

-- 
Emanuele Zattin
---------------------------------------------------
-I don't have to know an answer. I don't feel frightened by not
knowing things; by being lost in a mysterious universe without any
purpose — which is the way it really is, as far as I can tell,
possibly. It doesn't frighten me.- Richard Feynman
jelle | 1 Dec 23:27
Picon

Re: Algorithm of Viterbi

check out this article, that should the thing your looking for

http://www.biais.org/blog/index.php/?q=viterbi
Dorian | 2 Dec 00:41
Picon

Re: Algorithm of Viterbi

thank you very much

On 01/12/2007, jelle <jelleferinga <at> gmail.com> wrote:
check out this article, that should the thing your looking for

http://www.biais.org/blog/index.php/?q=viterbi

_______________________________________________
SciPy-user mailing list
SciPy-user <at> scipy.org
http://projects.scipy.org/mailman/listinfo/scipy-user

_______________________________________________
SciPy-user mailing list
SciPy-user <at> scipy.org
http://projects.scipy.org/mailman/listinfo/scipy-user
Lorenzo Isella | 2 Dec 16:24
Picon

Re: surface plotting

Dear All,
I refer to the text quoted below. I am interested in data representation 
and 3D plots in particular (something matplotlib is not very suitable for).

>One of the easiest ways to get things installed without eggs right now 
>is to first install the dependencies -- wxPython 2.6, python-vtk and 
>numpy and then grab the tarballs here:

  http://code.enthought.com/downloads/source/ets2.6/
>
>Untar them and build them each

 > cd enthought.traits
 > ./build.sh
 > vi/emacs install.sh
 > ./install.sh

>for all the tarballs and you should have mayavi installed.  The script 
>is broken in that it does not install the mayavi executable though -- 
>need to fix that.

In case it matters, I am running Debian testing on my box.
I tried first using eggs (with little success) and then the tarballs + 
./build.sh + ./install.sh.
Now, I am having 2 problems:
(1) if I try to re-run some old codes of mine(relying on SciPy), I get 
tons of these warnings:
/usr/lib/python2.4/site-packages/scipy/misc/__init__.py:25: 
DeprecationWarning: ScipyTest is now called NumpyTest; please update 
your code
  test = ScipyTest().test
/usr/lib/python2.4/site-packages/scipy/linalg/__init__.py:32: 
DeprecationWarning: ScipyTest is now called NumpyTest; please update 
your code
  test = ScipyTest().test
/usr/lib/python2.4/site-packages/scipy/optimize/__init__.py:17: 
DeprecationWarning: ScipyTest is now called NumpyTest; please update 
your code
  test = ScipyTest().test
/usr/lib/python2.4/site-packages/scipy/ndimage/__init__.py:40: 
DeprecationWarning: ScipyTest is now called NumpyTest; please update 
your code
  test = ScipyTest().test
/usr/lib/python2.4/site-packages/scipy/sparse/__init__.py:9: 
DeprecationWarning: ScipyTest is now called NumpyTest; please update 
your code
  test = ScipyTest().test
/usr/lib/python2.4/site-packages/scipy/io/__init__.py:20: 
DeprecationWarning: ScipyTest is now called NumpyTest; please update 
your code
  test = ScipyTest().test
/usr/lib/python2.4/site-packages/scipy/lib/__init__.py:5: 
DeprecationWarning: ScipyTest is now called NumpyTest; please update 
your code
  test = ScipyTest().test
/usr/lib/python2.4/site-packages/scipy/linsolve/umfpack/__init__.py:7: 
DeprecationWarning: ScipyTest is now called NumpyTest; please update 
your code
  test = ScipyTest().test
/usr/lib/python2.4/site-packages/scipy/linsolve/__init__.py:13: 
DeprecationWarning: ScipyTest is now called NumpyTest; please update 
your code
  test = ScipyTest().test
/usr/lib/python2.4/site-packages/scipy/interpolate/__init__.py:15: 
DeprecationWarning: ScipyTest is now called NumpyTest; please update 
your code
  test = ScipyTest().test
/usr/lib/python2.4/site-packages/scipy/special/__init__.py:22: 
DeprecationWarning: ScipyTest is now called NumpyTest; please update 
your code
  test = ScipyTest().test
/usr/lib/python2.4/site-packages/scipy/stats/__init__.py:15: 
DeprecationWarning: ScipyTest is now called NumpyTest; please update 
your code
  test = ScipyTest().test
/usr/lib/python2.4/site-packages/scipy/fftpack/__init__.py:21: 
DeprecationWarning: ScipyTest is now called NumpyTest; please update 
your code
  test = ScipyTest().test
/usr/lib/python2.4/site-packages/scipy/integrate/__init__.py:16: 
DeprecationWarning: ScipyTest is now called NumpyTest; please update 
your code
  test = ScipyTest().test
/usr/lib/python2.4/site-packages/scipy/signal/__init__.py:17: 
DeprecationWarning: ScipyTest is now called NumpyTest; please update 
your code
  test = ScipyTest().test
/usr/lib/python2.4/site-packages/scipy/maxentropy/__init__.py:12: 
DeprecationWarning: ScipyTest is now called NumpyTest; please update 
your code
  test = ScipyTest().test

Basically, ScipyTest is now, in some sense, NumpyTest. Other than that, 
the codes seem to run fine, but I hope I have not harmed my system. Does 
it have anything to do with the different versions of Python I have 
installed? Should I be worried to end up with a broken Python? That 
would be a disaster for me. What is giving rise to this new warning? Any 
suggestions here are welcome.
(2)This is less critical to me: when I try running the code snippet on
 http://www.scipy.org/Cookbook/MayaVi/mlab

import scipy

# prepare some interesting function:
def f(x, y):
    return 3.0*scipy.sin(x*y+1e-4)/(x*y+1e-4)

x = scipy.arange(-7., 7.05, 0.1)
y = scipy.arange(-5., 5.05, 0.1)

# 3D visualization of f:
from enthought.tvtk.tools import mlab
fig = mlab.figure()
s = mlab.SurfRegular(x, y, f)
fig.add(s)

this is what I get:

/usr/lib/python2.4/site-packages/scipy/misc/__init__.py:25: 
DeprecationWarning: ScipyTest is now called NumpyTest; please update 
your code
  test = ScipyTest().test

(python:13574): Gtk-CRITICAL **: gtk_widget_set_colormap: assertion 
`!GTK_WIDGET_REALIZED (widget)' failed

and no window opens. Any idea of what is going on? BTW, I actually tried 
replacing  ScipyTest with NumpyTest  in 
/usr/lib/python2.4/site-packages/scipy/misc/__init__.py:25, but then the 
code crashed badly (can give more info if needed). So, one error and the 
same warning as before. The other example I want to discuss is
(http://www.scipy.org/Cookbook/MayaVi/Surf)

import numpy
def f(x, y):
return numpy.sin(x*y)/(x*y)
x = numpy.arange(-7., 7.05, 0.1)
y = numpy.arange(-5., 5.05, 0.05)
from enthought.tvtk.tools import mlab
s = mlab.SurfRegular(x, y, f)
from enthought.mayavi.sources.vtk_data_source import VTKDataSource
d = VTKDataSource()
d.data = s.data
mayavi.add_source(d)
from enthought.mayavi.filters.warp_scalar import WarpScalar
w = WarpScalar()
mayavi.add_filter(w)
from enthought.mayavi.modules.outline import Outline
from enthought.mayavi.modules.surface import Surface
o = Outline()
s = Surface()
mayavi.add_module(o)
mayavi.add_module(s)

but again,  this is what I get:

/usr/lib/python2.4/site-packages/scipy/misc/__init__.py:25: 
DeprecationWarning: ScipyTest is now called NumpyTest; please update 
your code
  test = ScipyTest().test
So far so good
Traceback (most recent call last):
  File "3D-enthought.py", line 13, in ?
    mayavi.add_source(d)
NameError: name 'mayavi' is not defined

So, what is going on here? Mayavi is actually installed on my system...

Sorry for the long post. My main interest is point (1), i.e. to be sure 
that my python installation is still OK (and know what to do in case it 
is not). As to point (2), in the end of the day, these modules will make 
it into debian packages, won't they? So at some point installing them 
should be straightforward (at least for me; I am not very good at 
handling source and installing myself).
Many thanks

Lorenzo
Gael Varoquaux | 2 Dec 17:40
Favicon
Gravatar

Re: surface plotting

On Sun, Dec 02, 2007 at 04:24:50PM +0100, Lorenzo Isella wrote:
> I refer to the text quoted below. I am interested in data representation 
> and 3D plots in particular (something matplotlib is not very suitable for).

Sure. Tell us a bit more about your usecase. Do you want to produce
figures for print/publication, do you want to interact with your data, or
do you want simply to do some 3D plotting in a program of yours. You can
do all this with Mayavi, but the solutions will depend a bit of your usecase.

>The other example I want to discuss is
> (http://www.scipy.org/Cookbook/MayaVi/Surf)

> import numpy
> def f(x, y):
> return numpy.sin(x*y)/(x*y)
> x = numpy.arange(-7., 7.05, 0.1)
> y = numpy.arange(-5., 5.05, 0.05)
> from enthought.tvtk.tools import mlab
> s = mlab.SurfRegular(x, y, f)
> from enthought.mayavi.sources.vtk_data_source import VTKDataSource
> d = VTKDataSource()
> d.data = s.data
> mayavi.add_source(d)
> from enthought.mayavi.filters.warp_scalar import WarpScalar
> w = WarpScalar()
> mayavi.add_filter(w)
> from enthought.mayavi.modules.outline import Outline
> from enthought.mayavi.modules.surface import Surface
> o = Outline()
> s = Surface()
> mayavi.add_module(o)
> mayavi.add_module(s)

> but again,  this is what I get:

> /usr/lib/python2.4/site-packages/scipy/misc/__init__.py:25: 
> DeprecationWarning: ScipyTest is now called NumpyTest; please update 
> your code
>   test = ScipyTest().test
> So far so good
> Traceback (most recent call last):
>   File "3D-enthought.py", line 13, in ?
>     mayavi.add_source(d)
> NameError: name 'mayavi' is not defined

> So, what is going on here? Mayavi is actually installed on my system...

This code has to be run through mayavi. It is suited only for interactive
visualisation or producing figures, and not to run as part of a Python
program. You have to run it in mayavi, either by running "mayavi2 -n -x
script.py", loading it through the menu (File -> Open File), and pressing
Ctrl+R, or entering "execfile('script.py') in the python shell.

> Sorry for the long post. 

No problem, that's what mailing lists are for.

> My main interest is point (1), i.e. to be sure that my python
> installation is still OK (and know what to do in case it is not). 

I think it is OK. What happened is that scipy got updated, and these are
just harmless, albeit annoying, warnings.

> As to point (2), in the end of the day, these modules will make 
> it into debian packages, won't they? 

Yes, we are working on them. I had to finish my PhD thesis, so I was
lagging behind on my work on packaging and Co. I am mostly done with
that (!!), so things will start to move a bit faster soon.

> So at some point installing them should be straightforward (at least
> for me; I am not very good at handling source and installing myself).

Yes, we are working on that. We know it is very important and will focus
effort on ease of instal.

Cheers,

Gaël
Gael Varoquaux | 2 Dec 17:49
Favicon
Gravatar

Re: surface plotting

On Sat, Dec 01, 2007 at 10:24:42PM +0530, Prabhu Ramachandran wrote:
> Unfortunately, these still use tvtk's mlab which is lower level and not 
> as powerful as mayavi's new mlab.

> The best docs for that are here:

>   https://svn.enthought.com/enthought/attachment/wiki/MayaVi/mlab.pdf

Quickly, you can have a feeling of how to plot surface using mlab by
folliwing these steps:

run "ipython -wthread"

execute the following python code:

+++++++++++++++++++++++++++++++++++++++
In [1]: from enthought.mayavi.tools import mlab as M
Set Envisage to use the workbench UI: True
Set Envisage to use the workbench UI: True

In [2]: from scipy import *

In [3]: X, Y = mgrid[-1:1:50j, -1:1:50j]

In [4]: Z = cos(4*(X**2+Y**2))

In [5]: M.surf(X, Y, Z)
+++++++++++++++++++++++++++++++++++++++

This will bring up a Mayavi2 window with the surface plotted. The mlab
API is similar to matplotlib's pylab, so you should feel quite familiar
with it. It is still young and I haven't had time to put as much work as
I would like in it. Documentation is lacking, but the docstrings are
quite good. Just reading "help(M)" in the example above should hopefully
give you an idea of the possbilities. The docs pointed to by Prabhu
should also be helpful.

HTH,

Gaël

Gmane