From dlrt2 at ast.cam.ac.uk Mon Mar 1 06:46:42 2010 From: dlrt2 at ast.cam.ac.uk (David Trethewey) Date: Mon, 01 Mar 2010 11:46:42 +0000 Subject: [SciPy-User] Error on importing scikits.learn In-Reply-To: <4B8BA8B7.9040305@cam.ac.uk> References: <4B8BA8B7.9040305@cam.ac.uk> Message-ID: <4B8BA922.6010900@ast.cam.ac.uk> I get the following error message when attempting to import the expectation maximisation (em) module from scikits.learn : > > >>> import scipy > >>> import numpy > >>> from scikits.learn.machine import em > Traceback (most recent call last): > File "", line 1, in > File "scikits/learn/machine/em/__init__.py", line 8, in > from online_em import OnGMM as _OnGMM > File "scikits/learn/machine/em/online_em.py", line 164, in > import _rawden > ImportError: No module named _rawden > > Does anyone know what this _rawden module is and why might it not be > found? > > David Trethewey > Institute of Astronomy, Cambridge, UK > > From dlrt2 at ast.cam.ac.uk Mon Mar 1 06:51:14 2010 From: dlrt2 at ast.cam.ac.uk (David Trethewey) Date: Mon, 01 Mar 2010 11:51:14 +0000 Subject: [SciPy-User] Error on importing scikits.learn In-Reply-To: <4B8BA922.6010900@ast.cam.ac.uk> References: <4B8BA8B7.9040305@cam.ac.uk> <4B8BA922.6010900@ast.cam.ac.uk> Message-ID: <4B8BAA32.3000004@ast.cam.ac.uk> I have traced it back to an error in compiling scikits.learn itself: building 'scikits.learn.machine.em._rawden' extension compiling C sources C compiler: gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC compile options: '-I/usr/lib/python2.6/dist-packages/numpy/core/include -I/usr/include/python2.6 -c' gcc: scikits/learn/machine/em/src/pure_den.c scikits/learn/machine/em/src/pure_den.c:7:20: error: Python.h: No such file or directory David David Trethewey wrote: > I get the following error message when attempting to import the > expectation maximisation (em) module from scikits.learn : >> >> >>> import scipy >> >>> import numpy >> >>> from scikits.learn.machine import em >> Traceback (most recent call last): >> File "", line 1, in >> File "scikits/learn/machine/em/__init__.py", line 8, in >> from online_em import OnGMM as _OnGMM >> File "scikits/learn/machine/em/online_em.py", line 164, in >> import _rawden >> ImportError: No module named _rawden >> >> Does anyone know what this _rawden module is and why might it not be >> found? >> >> David Trethewey >> Institute of Astronomy, Cambridge, UK >> >> > > From helge.reikeras at gmail.com Mon Mar 1 06:55:01 2010 From: helge.reikeras at gmail.com (Helge Reikeras) Date: Mon, 01 Mar 2010 13:55:01 +0200 Subject: [SciPy-User] Error on importing scikits.learn In-Reply-To: <4B8BAA32.3000004@ast.cam.ac.uk> References: <4B8BA8B7.9040305@cam.ac.uk> <4B8BA922.6010900@ast.cam.ac.uk> <4B8BAA32.3000004@ast.cam.ac.uk> Message-ID: On Mon, 01 Mar 2010 13:51:14 +0200, David Trethewey wrote: > > compile options: '-I/usr/lib/python2.6/dist-packages/numpy/core/include > -I/usr/include/python2.6 -c' > gcc: scikits/learn/machine/em/src/pure_den.c > scikits/learn/machine/em/src/pure_den.c:7:20: error: Python.h: No such > file or directory This is because you don't have the Python header files installed. You need to install these somehow. E.g. if you are running Ubuntu you do "sudo apt-get install python-dev". -- Helge Reikeras http://www.google.com/profiles/helge.reikeras From cimrman3 at ntc.zcu.cz Mon Mar 1 12:20:36 2010 From: cimrman3 at ntc.zcu.cz (Robert Cimrman) Date: Mon, 01 Mar 2010 18:20:36 +0100 Subject: [SciPy-User] ANN: SfePy 2010.1 Message-ID: <4B8BF764.5080305@ntc.zcu.cz> I am pleased to announce release 2010.1 of SfePy. Description ----------- SfePy (simple finite elements in Python) is a software for solving systems of coupled partial differential equations by the finite element method. The code is based on NumPy and SciPy packages. It is distributed under the new BSD license. Mailing lists, issue tracking, git repository: http://sfepy.org Home page: http://sfepy.kme.zcu.cz Documentation: http://docs.sfepy.org/doc Contributors to this release: Vladim?r Luke?, Logan Sorenson. Highlights of this release -------------------------- - new sphinx-based documentation - refactoring of base functions (polynomial spaces) and element geometry description - interpolation between different meshes - terms for describing perfusion and active fibres in the total Lagrangian formulation (applicable, for example, to active muscle tissue models) Major improvements ------------------ Apart from many bug-fixes, let us mention: - data probing: - automatic refinement of probe points, speed-up - postprocessing and visualization: - VTK source construction for any format supported by MeshIO classes: - this means displaying meshes in formats Mayavi knows nothing about - graphical logging: - support logging to a text file, vertical line plot, allow several Log instances - new examples: - application of the theory of homogenization to elasticity - perfusion, active fibres - new tests and many new terms For more information on this release, see http://sfepy.googlecode.com/svn/web/releases/2010.1_RELEASE_NOTES.txt (full release notes, rather long). Best regards, Robert Cimrman From nwagner at iam.uni-stuttgart.de Mon Mar 1 15:52:43 2010 From: nwagner at iam.uni-stuttgart.de (Nils Wagner) Date: Mon, 01 Mar 2010 21:52:43 +0100 Subject: [SciPy-User] scipy.io.wavfile versus audiolab Message-ID: Hi all, what are the differences between audiolab and scipy.io.wavfile ? Nils From Chris.Barker at noaa.gov Mon Mar 1 17:15:29 2010 From: Chris.Barker at noaa.gov (Christopher Barker) Date: Mon, 01 Mar 2010 14:15:29 -0800 Subject: [SciPy-User] Google Summer of Code... Message-ID: <4B8C3C81.7000509@noaa.gov> Hi folks, Are we going to try to get some sciPy project in GSoC under the Python umbrella this year? Or might it be worth applying to be a mentoring organization? Has anyone started thinking about it? -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chris.Barker at noaa.gov From josef.pktd at gmail.com Mon Mar 1 17:35:32 2010 From: josef.pktd at gmail.com (josef.pktd at gmail.com) Date: Mon, 1 Mar 2010 17:35:32 -0500 Subject: [SciPy-User] Google Summer of Code... In-Reply-To: <4B8C3C81.7000509@noaa.gov> References: <4B8C3C81.7000509@noaa.gov> Message-ID: <1cd32cbb1003011435u725d37e5ne3c98475f3cfa8a@mail.gmail.com> On Mon, Mar 1, 2010 at 5:15 PM, Christopher Barker wrote: > Hi folks, > > Are we going to try to get some sciPy project in GSoC under the Python > umbrella this year? Or might it be worth applying to be a mentoring > organization? > > Has anyone started thinking about it? I sure hope we do, and one project is stats. Who is organizing gsoc for scipy/numpy? Josef > > -Chris > > > > > > -- > Christopher Barker, Ph.D. > Oceanographer > > Emergency Response Division > NOAA/NOS/OR&R ? ? ? ? ? ?(206) 526-6959 ? voice > 7600 Sand Point Way NE ? (206) 526-6329 ? fax > Seattle, WA ?98115 ? ? ? (206) 526-6317 ? main reception > > Chris.Barker at noaa.gov > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > From robert.kern at gmail.com Mon Mar 1 17:43:34 2010 From: robert.kern at gmail.com (Robert Kern) Date: Mon, 1 Mar 2010 16:43:34 -0600 Subject: [SciPy-User] Google Summer of Code... In-Reply-To: <1cd32cbb1003011435u725d37e5ne3c98475f3cfa8a@mail.gmail.com> References: <4B8C3C81.7000509@noaa.gov> <1cd32cbb1003011435u725d37e5ne3c98475f3cfa8a@mail.gmail.com> Message-ID: <3d375d731003011443h1a5c0b02h837f5af3f5348037@mail.gmail.com> On Mon, Mar 1, 2010 at 16:35, wrote: > On Mon, Mar 1, 2010 at 5:15 PM, Christopher Barker > wrote: >> Hi folks, >> >> Are we going to try to get some sciPy project in GSoC under the Python >> umbrella this year? Or might it be worth applying to be a mentoring >> organization? >> >> Has anyone started thinking about it? > > I sure hope we do, and one project is stats. > > Who is organizing gsoc for scipy/numpy? You, apparently. Congratulations! More seriously, I don't think there is going to be any organization on our side, per se. Like every other year, scipy-relevant projects will most likely be taken care of by the PSF acting as an umbrella organization. People willing to mentor should contact the PSF coordinator. By all means, use our mailing lists and Wiki to talk about possible projects and connect students to mentors, but it's mostly going to be up to the volunteer mentors to work with the PSF and your students to get the project proposals submitted and selected. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From jsseabold at gmail.com Mon Mar 1 17:59:46 2010 From: jsseabold at gmail.com (Skipper Seabold) Date: Mon, 1 Mar 2010 17:59:46 -0500 Subject: [SciPy-User] Google Summer of Code... In-Reply-To: <3d375d731003011443h1a5c0b02h837f5af3f5348037@mail.gmail.com> References: <4B8C3C81.7000509@noaa.gov> <1cd32cbb1003011435u725d37e5ne3c98475f3cfa8a@mail.gmail.com> <3d375d731003011443h1a5c0b02h837f5af3f5348037@mail.gmail.com> Message-ID: On Mon, Mar 1, 2010 at 5:43 PM, Robert Kern wrote: > On Mon, Mar 1, 2010 at 16:35, ? wrote: >> On Mon, Mar 1, 2010 at 5:15 PM, Christopher Barker >> wrote: >>> Hi folks, >>> >>> Are we going to try to get some sciPy project in GSoC under the Python >>> umbrella this year? Or might it be worth applying to be a mentoring >>> organization? >>> >>> Has anyone started thinking about it? >> >> I sure hope we do, and one project is stats. >> >> Who is organizing gsoc for scipy/numpy? > > You, apparently. Congratulations! > > More seriously, I don't think there is going to be any organization on > our side, per se. Like every other year, scipy-relevant projects will > most likely be taken care of by the PSF acting as an umbrella > organization. People willing to mentor should contact the PSF > coordinator. By all means, use our mailing lists and Wiki to talk > about possible projects and connect students to mentors, but it's > mostly going to be up to the volunteer mentors to work with the PSF > and your students to get the project proposals submitted and selected. > One thing I would suggest (I'll be able to pitch in in the next few days) is cleaning up this with the progress made last summer (anything from 2008?): http://projects.scipy.org/scipy/wiki/SummerOfCode I would also encourage anyone who has ideas to edit the wiki here to reflect the current project wishlist (especially if you're willing to mentor): http://projects.scipy.org/scipy/wiki/SummerofCodeIdeas IMHO, the more ideas there are, the more chance of grabbing interested and diverse sets of students provided people are willing to mentor. Also, should we put a more prominent link to the first page somewhere? Maybe on the developer page? I'm not even sure how to get there except through googling. Once this is cleaned up a bit perhaps we should advertise a little? Just a thought. Skipper From millman at berkeley.edu Mon Mar 1 18:01:18 2010 From: millman at berkeley.edu (Jarrod Millman) Date: Mon, 1 Mar 2010 15:01:18 -0800 Subject: [SciPy-User] Google Summer of Code... In-Reply-To: <4B8C3C81.7000509@noaa.gov> References: <4B8C3C81.7000509@noaa.gov> Message-ID: On Mon, Mar 1, 2010 at 2:15 PM, Christopher Barker wrote: > Are we going to try to get some sciPy project in GSoC under the Python > umbrella this year? Or might it be worth applying to be a mentoring > organization? We will definitely be going under the PSF umbrella. In the past, I've discussed whether we should apply as a mentoring organization with Chris DiBona and he has repeatedly strongly encouraged me not to do that. He much prefers us remaining under the PSF umbrella. Moreover, even if Google was interested in us being our own mentoring organization, I don't see any reason we should pursue it. It is a fair bit of additional administrative work for potentially very little gain. If we were set up as our own mentoring organization, I am fairly certain there is no chance we would get any additional reserved slots. As far as I remember, the PSF has always given us as many (or more) scipy-related slots as we request based on the applications that come in and our pool of potential mentors. If you are interested in mentoring this year, please register for these lists: http://mail.python.org/mailman/listinfo/soc2010-general http://mail.python.org/mailman/listinfo/soc2010-mentors Feel free to add ideas or edit the existing ones here: http://projects.scipy.org/scipy/wiki/SummerofCodeIdeas Thanks, -- Jarrod Millman Helen Wills Neuroscience Institute 10 Giannini Hall, UC Berkeley http://cirl.berkeley.edu/ From dwf at cs.toronto.edu Mon Mar 1 18:32:06 2010 From: dwf at cs.toronto.edu (David Warde-Farley) Date: Mon, 1 Mar 2010 18:32:06 -0500 Subject: [SciPy-User] Google Summer of Code... In-Reply-To: References: <4B8C3C81.7000509@noaa.gov> <1cd32cbb1003011435u725d37e5ne3c98475f3cfa8a@mail.gmail.com> <3d375d731003011443h1a5c0b02h837f5af3f5348037@mail.gmail.com> Message-ID: On 1-Mar-10, at 5:59 PM, Skipper Seabold wrote: > I would also encourage anyone who has ideas to edit the wiki here to > reflect the current project wishlist (especially if you're willing to > mentor): http://projects.scipy.org/scipy/wiki/SummerofCodeIdeas IMHO, > the more ideas there are, the more chance of grabbing interested and > diverse sets of students provided people are willing to mentor. I just reorganized the page a bit, to separate out the stuff that is already going on, like statsmodels, fwrap and the Py3k/datetime stuff, from things that have been listed for a while but never really picked up on. David From david at silveregg.co.jp Mon Mar 1 19:52:08 2010 From: david at silveregg.co.jp (David Cournapeau) Date: Tue, 02 Mar 2010 09:52:08 +0900 Subject: [SciPy-User] scipy.io.wavfile versus audiolab In-Reply-To: References: Message-ID: <4B8C6138.8090308@silveregg.co.jp> Nils Wagner wrote: > Hi all, > > what are the differences between audiolab and > scipy.io.wavfile ? For audiolab: - more features - is likely to be faster, since it uses libsndfile which is coded in C - handles more file formats (libsndfile is by far the best library for audio file IO and handles a lot of software-specific details). For scipy.io.wavfile: - pure python and no need for 3rd party library License-wise, audiolab is LGPL (because libsndfile is) whereas scipy.io.wavfile is BSD as the rest of scipy. cheers, David From massimodisasha at yahoo.it Mon Mar 1 20:17:16 2010 From: massimodisasha at yahoo.it (Massimo Di Stefano) Date: Tue, 2 Mar 2010 02:17:16 +0100 Subject: [SciPy-User] helmert implementation (7 parameters - geometric transformation) Message-ID: Hi All, i'm tring to implement a function to perform a geometric trasformation between a set of points in 2 different reference systems it is a 7 parameters trasformation (helmert) , based on last square method it use as input 2 set of x,y,z coordinates in 2 different reference systems and give as output 7 parameters needed to performs transformation from one reference system to the other one. http://en.wikipedia.org/wiki/Helmert_transformation this function is used in geodesy to "reproject" coordinates between 2 different Datum i wrote it as : import numpy as np from scipy import linalg def helmert(p1, p2): L = np.loadtxt(p1) A = np.zeros((3*L.shape[0],7),float) A[ ::3, 0] = 1.0 A[1::3, 1] = 1.0 A[2::3, 2] = 1.0 A[ ::3, 3] = L[:,0] A[1::3, 3] = L[:,1] A[2::3, 3] = L[:,2] A[1::3, 4] = L[:,2] A[2::3, 4] = -L[:,1] A[ ::3, 5] = -L[:,2] A[2::3, 5] = L[:,0] A[ ::3, 6] = L[:,1] A[1::3, 6] = -L[:,0] G = np.loadtxt(p2) Y = np.zeros((3*G.shape[0],1),float) Y[ ::3, 0] = G[:,0] - L[:,0] Y[1::3, 0] = G[:,1] - L[:,1] Y[2::3, 0] = G[:,2] - L[:,2] N = np.dot(A.T.conj(), A) T = np.dot(A.T.conj(), Y) C = np.dot(linalg.inv(N), T) print C from a pdf i find online it has numerical examples and i get different results :'( p1 : 4402553.334 727053.937 4542823.474 4399375.347 703845.876 4549215.105 4412911.150 701094.435 4536518.139 p2 : 4402553.569 727053.737 4542823.332 4399375.518 703845.639 4549214.880 4412911.336 701094.214 4536517.955 pdf results : x0 -9.256 m y0 -23.701 m z0 16.792 m Rx -0.0001990982 rad Ry 0.0001778762 rad Rz 0.00015 rad ? 0.00000046 my results : [[ -9.91564629e+00] [ -2.36172028e+01] [ 1.57283853e+01] [ -2.68063331e-07] [ 3.04330048e-06] [ -2.76148185e-06] [ -2.31598150e-06]] anyone here can give it a try ? the results seems wrong but i haveb't yet find a solution. thanks to ALL! regards, Massimo. From charlesr.harris at gmail.com Mon Mar 1 23:08:20 2010 From: charlesr.harris at gmail.com (Charles R Harris) Date: Mon, 1 Mar 2010 21:08:20 -0700 Subject: [SciPy-User] helmert implementation (7 parameters - geometric transformation) In-Reply-To: References: Message-ID: On Mon, Mar 1, 2010 at 6:17 PM, Massimo Di Stefano wrote: > Hi All, > > i'm tring to implement a function to perform a geometric trasformation > between a set of points in 2 different reference systems > > it is a 7 parameters trasformation (helmert) , based on last square method > it use as input 2 set of x,y,z coordinates in 2 different reference systems > and give as output 7 parameters needed to performs transformation > from one reference system to the other one. > > http://en.wikipedia.org/wiki/Helmert_transformation > > this function is used in geodesy to "reproject" coordinates between 2 > different Datum > > i wrote it as : > > import numpy as np > from scipy import linalg > > def helmert(p1, p2): > L = np.loadtxt(p1) > A = np.zeros((3*L.shape[0],7),float) > A[ ::3, 0] = 1.0 > A[1::3, 1] = 1.0 > A[2::3, 2] = 1.0 > A[ ::3, 3] = L[:,0] > A[1::3, 3] = L[:,1] > A[2::3, 3] = L[:,2] > A[1::3, 4] = L[:,2] > A[2::3, 4] = -L[:,1] > A[ ::3, 5] = -L[:,2] > A[2::3, 5] = L[:,0] > A[ ::3, 6] = L[:,1] > A[1::3, 6] = -L[:,0] > G = np.loadtxt(p2) > Y = np.zeros((3*G.shape[0],1),float) > Y[ ::3, 0] = G[:,0] - L[:,0] > Y[1::3, 0] = G[:,1] - L[:,1] > Y[2::3, 0] = G[:,2] - L[:,2] > N = np.dot(A.T.conj(), A) > T = np.dot(A.T.conj(), Y) > C = np.dot(linalg.inv(N), T) > print C > > > from a pdf i find online > it has numerical examples > and i get different results :'( > > > p1 : > > 4402553.334 727053.937 4542823.474 > 4399375.347 703845.876 4549215.105 > 4412911.150 701094.435 4536518.139 > > > p2 : > > 4402553.569 727053.737 4542823.332 > 4399375.518 703845.639 4549214.880 > 4412911.336 701094.214 4536517.955 > > > pdf results : > > x0 -9.256 m > y0 -23.701 m > z0 16.792 m > Rx -0.0001990982 rad > Ry 0.0001778762 rad > Rz 0.00015 rad > ? 0.00000046 > > > my results : > > [[ -9.91564629e+00] > [ -2.36172028e+01] > [ 1.57283853e+01] > [ -2.68063331e-07] > [ 3.04330048e-06] > [ -2.76148185e-06] > [ -2.31598150e-06]] > > > > anyone here can give it a try ? > the results seems wrong but > i haveb't yet find a solution. > > thanks to ALL! > > regards, > > Massimo. > > > > > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > -------------- next part -------------- An HTML attachment was scrubbed... URL: From charlesr.harris at gmail.com Tue Mar 2 01:05:05 2010 From: charlesr.harris at gmail.com (Charles R Harris) Date: Mon, 1 Mar 2010 23:05:05 -0700 Subject: [SciPy-User] helmert implementation (7 parameters - geometric transformation) In-Reply-To: References: Message-ID: On Mon, Mar 1, 2010 at 6:17 PM, Massimo Di Stefano wrote: > Hi All, > > i'm tring to implement a function to perform a geometric trasformation > between a set of points in 2 different reference systems > > it is a 7 parameters trasformation (helmert) , based on last square method > it use as input 2 set of x,y,z coordinates in 2 different reference systems > and give as output 7 parameters needed to performs transformation > from one reference system to the other one. > > http://en.wikipedia.org/wiki/Helmert_transformation > > this function is used in geodesy to "reproject" coordinates between 2 > different Datum > > i wrote it as : > > import numpy as np > from scipy import linalg > > def helmert(p1, p2): > L = np.loadtxt(p1) > A = np.zeros((3*L.shape[0],7),float) > A[ ::3, 0] = 1.0 > A[1::3, 1] = 1.0 > A[2::3, 2] = 1.0 > A[ ::3, 3] = L[:,0] > A[1::3, 3] = L[:,1] > A[2::3, 3] = L[:,2] > A[1::3, 4] = L[:,2] > A[2::3, 4] = -L[:,1] > A[ ::3, 5] = -L[:,2] > A[2::3, 5] = L[:,0] > A[ ::3, 6] = L[:,1] > A[1::3, 6] = -L[:,0] > G = np.loadtxt(p2) > Y = np.zeros((3*G.shape[0],1),float) > Y[ ::3, 0] = G[:,0] - L[:,0] > Y[1::3, 0] = G[:,1] - L[:,1] > Y[2::3, 0] = G[:,2] - L[:,2] > N = np.dot(A.T.conj(), A) > T = np.dot(A.T.conj(), Y) > C = np.dot(linalg.inv(N), T) > print C > > > from a pdf i find online > it has numerical examples > and i get different results :'( > > > p1 : > > 4402553.334 727053.937 4542823.474 > 4399375.347 703845.876 4549215.105 > 4412911.150 701094.435 4536518.139 > > > p2 : > > 4402553.569 727053.737 4542823.332 > 4399375.518 703845.639 4549214.880 > 4412911.336 701094.214 4536517.955 > > > pdf results : > > x0 -9.256 m > y0 -23.701 m > z0 16.792 m > Rx -0.0001990982 rad > Ry 0.0001778762 rad > Rz 0.00015 rad > ? 0.00000046 > > The angles here look like degrees, not radians. Also, the last factor is pretty definitely wrong. It is given directly as the square root of the ratio of the variance of the two sets of vectors around their means minus 1. For instance sqrt(pt2.var(0).sum()/pt1.var(0).sum()) - 1 > > my results : > > [[ -9.91564629e+00] > [ -2.36172028e+01] > [ 1.57283853e+01] > [ -2.68063331e-07] > [ 3.04330048e-06] > [ -2.76148185e-06] > [ -2.31598150e-06]] > > > And my result agrees with neither ;) BTW, are you going from pt2 -> pt1 or vice versa? Chuck -------------- next part -------------- An HTML attachment was scrubbed... URL: From charlesr.harris at gmail.com Tue Mar 2 01:18:34 2010 From: charlesr.harris at gmail.com (Charles R Harris) Date: Mon, 1 Mar 2010 23:18:34 -0700 Subject: [SciPy-User] helmert implementation (7 parameters - geometric transformation) In-Reply-To: References: Message-ID: 2010/3/1 Charles R Harris > > > On Mon, Mar 1, 2010 at 6:17 PM, Massimo Di Stefano < > massimodisasha at yahoo.it> wrote: > >> Hi All, >> >> i'm tring to implement a function to perform a geometric trasformation >> between a set of points in 2 different reference systems >> >> it is a 7 parameters trasformation (helmert) , based on last square method >> it use as input 2 set of x,y,z coordinates in 2 different reference >> systems >> and give as output 7 parameters needed to performs transformation >> from one reference system to the other one. >> >> http://en.wikipedia.org/wiki/Helmert_transformation >> >> this function is used in geodesy to "reproject" coordinates between 2 >> different Datum >> >> i wrote it as : >> >> import numpy as np >> from scipy import linalg >> >> def helmert(p1, p2): >> L = np.loadtxt(p1) >> A = np.zeros((3*L.shape[0],7),float) >> A[ ::3, 0] = 1.0 >> A[1::3, 1] = 1.0 >> A[2::3, 2] = 1.0 >> A[ ::3, 3] = L[:,0] >> A[1::3, 3] = L[:,1] >> A[2::3, 3] = L[:,2] >> A[1::3, 4] = L[:,2] >> A[2::3, 4] = -L[:,1] >> A[ ::3, 5] = -L[:,2] >> A[2::3, 5] = L[:,0] >> A[ ::3, 6] = L[:,1] >> A[1::3, 6] = -L[:,0] >> G = np.loadtxt(p2) >> Y = np.zeros((3*G.shape[0],1),float) >> Y[ ::3, 0] = G[:,0] - L[:,0] >> Y[1::3, 0] = G[:,1] - L[:,1] >> Y[2::3, 0] = G[:,2] - L[:,2] >> N = np.dot(A.T.conj(), A) >> T = np.dot(A.T.conj(), Y) >> C = np.dot(linalg.inv(N), T) >> print C >> >> >> from a pdf i find online >> it has numerical examples >> and i get different results :'( >> >> >> p1 : >> >> 4402553.334 727053.937 4542823.474 >> 4399375.347 703845.876 4549215.105 >> 4412911.150 701094.435 4536518.139 >> >> >> p2 : >> >> 4402553.569 727053.737 4542823.332 >> 4399375.518 703845.639 4549214.880 >> 4412911.336 701094.214 4536517.955 >> >> >> pdf results : >> >> x0 -9.256 m >> y0 -23.701 m >> z0 16.792 m >> Rx -0.0001990982 rad >> Ry 0.0001778762 rad >> Rz 0.00015 rad >> ? 0.00000046 >> >> > The angles here look like degrees, not radians. Also, the last factor is > pretty definitely wrong. It is given directly as the square root of the > ratio of the variance of the two sets of vectors around their means minus 1. > For instance > > sqrt(pt2.var(0).sum()/pt1.var(0).sum()) - 1 > > >> >> my results : >> >> [[ -9.91564629e+00] >> [ -2.36172028e+01] >> [ 1.57283853e+01] >> [ -2.68063331e-07] >> [ 3.04330048e-06] >> [ -2.76148185e-06] >> [ -2.31598150e-06]] >> >> >> > And my result agrees with neither ;) BTW, are you going from pt2 -> pt1 or > vice versa? > > Are you sure the data you gave is correct? Lengths don't seem to be preserved under rotation. Chuck -------------- next part -------------- An HTML attachment was scrubbed... URL: From dlrt2 at ast.cam.ac.uk Tue Mar 2 06:02:09 2010 From: dlrt2 at ast.cam.ac.uk (David Trethewey) Date: Tue, 02 Mar 2010 11:02:09 +0000 Subject: [SciPy-User] scikits.learn installation In-Reply-To: References: Message-ID: <4B8CF031.6030207@ast.cam.ac.uk> I installed the python headers and libboost. It now compiles without error but still when I actually try to import the em module I get the same error message; >>>> import scipy >>>> import numpy >>>> from scikits.learn.machine import em >>>> > Traceback (most recent call last): > File "", line 1, in > File "scikits/learn/machine/em/__init__.py", line 8, in > from online_em import OnGMM as _OnGMM > File "scikits/learn/machine/em/online_em.py", line 164, in > import _rawden > ImportError: No module named _rawden > > > David Trethewey > Institute of Astronomy, Cambridge, UK > > > scipy-user-request at scipy.org wrote: > Send SciPy-User mailing list submissions to > scipy-user at scipy.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.scipy.org/mailman/listinfo/scipy-user > or, via email, send a message with subject or body 'help' to > scipy-user-request at scipy.org > > You can reach the person managing the list at > scipy-user-owner at scipy.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of SciPy-User digest..." > > > Today's Topics: > > 1. Re: Error on importing scikits.learn (David Trethewey) > 2. Re: Error on importing scikits.learn (David Trethewey) > 3. Re: Error on importing scikits.learn (Helge Reikeras) > 4. ANN: SfePy 2010.1 (Robert Cimrman) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Mon, 01 Mar 2010 11:46:42 +0000 > From: David Trethewey > Subject: Re: [SciPy-User] Error on importing scikits.learn > To: scipy-user at scipy.org > Message-ID: <4B8BA922.6010900 at ast.cam.ac.uk> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > I get the following error message when attempting to import the > expectation maximisation (em) module from scikits.learn : > >>>>> import scipy >>>>> import numpy >>>>> from scikits.learn.machine import em >>>>> >> Traceback (most recent call last): >> File "", line 1, in >> File "scikits/learn/machine/em/__init__.py", line 8, in >> from online_em import OnGMM as _OnGMM >> File "scikits/learn/machine/em/online_em.py", line 164, in >> import _rawden >> ImportError: No module named _rawden >> >> Does anyone know what this _rawden module is and why might it not be >> found? >> >> David Trethewey >> Institute of Astronomy, Cambridge, UK >> >> >> > > > > ------------------------------ > > Message: 2 > Date: Mon, 01 Mar 2010 11:51:14 +0000 > From: David Trethewey > Subject: Re: [SciPy-User] Error on importing scikits.learn > To: scipy-user at scipy.org > Message-ID: <4B8BAA32.3000004 at ast.cam.ac.uk> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > I have traced it back to an error in compiling scikits.learn itself: > > building 'scikits.learn.machine.em._rawden' extension > compiling C sources > C compiler: gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 > -Wall -Wstrict-prototypes -fPIC > > compile options: '-I/usr/lib/python2.6/dist-packages/numpy/core/include > -I/usr/include/python2.6 -c' > gcc: scikits/learn/machine/em/src/pure_den.c > scikits/learn/machine/em/src/pure_den.c:7:20: error: Python.h: No such > file or directory > > David > > David Trethewey wrote: > >> I get the following error message when attempting to import the >> expectation maximisation (em) module from scikits.learn : >> >>>>>> import scipy >>>>>> import numpy >>>>>> from scikits.learn.machine import em >>>>>> >>> Traceback (most recent call last): >>> File "", line 1, in >>> File "scikits/learn/machine/em/__init__.py", line 8, in >>> from online_em import OnGMM as _OnGMM >>> File "scikits/learn/machine/em/online_em.py", line 164, in >>> import _rawden >>> ImportError: No module named _rawden >>> >>> Does anyone know what this _rawden module is and why might it not be >>> found? >>> >>> David Trethewey >>> Institute of Astronomy, Cambridge, UK >>> >>> >>> >> > > > > ------------------------------ > > Message: 3 > Date: Mon, 01 Mar 2010 13:55:01 +0200 > From: "Helge Reikeras" > Subject: Re: [SciPy-User] Error on importing scikits.learn > To: "SciPy Users List" > Message-ID: > Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes > > On Mon, 01 Mar 2010 13:51:14 +0200, David Trethewey > wrote: > > >> compile options: '-I/usr/lib/python2.6/dist-packages/numpy/core/include >> -I/usr/include/python2.6 -c' >> gcc: scikits/learn/machine/em/src/pure_den.c >> scikits/learn/machine/em/src/pure_den.c:7:20: error: Python.h: No such >> file or directory >> > > This is because you don't have the Python header files installed. You need > to install these somehow. E.g. if you are running Ubuntu you do "sudo > apt-get install python-dev". > > From pitam at deepspace.ucsb.edu Tue Mar 2 06:21:25 2010 From: pitam at deepspace.ucsb.edu (Pitam Mitra) Date: Tue, 02 Mar 2010 03:21:25 -0800 Subject: [SciPy-User] segfaults with weave.inline Message-ID: Hi, I am creating a new median filter for an astronomy application. Due to speed issues, I decided to code it with weave.inline. However, I have run into segfaults and I have no clue what to do next. I am sorry if this is the wrong section to post this - I searched the site, I could not find any forum. :( Any help is appreciated!! Here is the output: *** glibc detected *** python: free(): invalid next size (fast): 0x09746358 *** ======= Backtrace: ========= /lib/libc.so.6[0x428751] /usr/lib/python2.6/site-packages/numpy/core/multiarray.so(+0x3643c)[0x8db43c] /usr/lib/libpython2.6.so.1.0[0x3669924] /usr/lib/libpython2.6.so.1.0[0x3656559] /usr/lib/libpython2.6.so.1.0(PyEval_EvalFrameEx+0x5359)[0x36c8fc9] /usr/lib/libpython2.6.so.1.0(PyEval_EvalCodeEx+0x7aa)[0x36c9e4a] /usr/lib/libpython2.6.so.1.0(PyEval_EvalCode+0x64)[0x36c9fb4] /usr/lib/libpython2.6.so.1.0[0x36e525c] /usr/lib/libpython2.6.so.1.0(PyRun_FileExFlags+0x93)[0x36e5323] /usr/lib/libpython2.6.so.1.0(PyRun_SimpleFileExFlags+0xe1)[0x36e68c1] /usr/lib/libpython2.6.so.1.0(PyRun_AnyFileExFlags+0x82)[0x36e7162] /usr/lib/libpython2.6.so.1.0(Py_Main+0xb95)[0x36f3bd5] python(main+0x28)[0x80485c8] /lib/libc.so.6(__libc_start_main+0xe6)[0x3d0bb6] python[0x8048501] Then there is a huge memory map. The full output can be seen here:http://www.pastebay.com/88049 and the code here: http://www.pastebay.com/88050 Regards Pitam From josef.pktd at gmail.com Tue Mar 2 06:45:08 2010 From: josef.pktd at gmail.com (josef.pktd at gmail.com) Date: Tue, 2 Mar 2010 06:45:08 -0500 Subject: [SciPy-User] scikits.learn installation In-Reply-To: <4B8CF031.6030207@ast.cam.ac.uk> References: <4B8CF031.6030207@ast.cam.ac.uk> Message-ID: <1cd32cbb1003020345k7d51d85ah5fd703139a20afbc@mail.gmail.com> On Tue, Mar 2, 2010 at 6:02 AM, David Trethewey wrote: > I installed the python headers and libboost. It now compiles without > error but still when I actually try to import the em module I get the > same error message; >>>>> import scipy >>>>> import numpy >>>>> from scikits.learn.machine import em >>>>> >> Traceback (most recent call last): >> ?File "", line 1, in >> ?File "scikits/learn/machine/em/__init__.py", line 8, in >> ? ?from online_em import OnGMM as _OnGMM >> ?File "scikits/learn/machine/em/online_em.py", line 164, in >> ? ?import _rawden >> ImportError: No module named _rawden You could search the source and build directories for *.pyd . It happened to me in the pre-release version that the pyd files didn't get copied correctly to the install directories. Josef >> >> >> David Trethewey >> Institute of Astronomy, Cambridge, UK >> >> >> > > > > scipy-user-request at scipy.org wrote: >> Send SciPy-User mailing list submissions to >> ? ? ? scipy-user at scipy.org >> >> To subscribe or unsubscribe via the World Wide Web, visit >> ? ? ? http://mail.scipy.org/mailman/listinfo/scipy-user >> or, via email, send a message with subject or body 'help' to >> ? ? ? scipy-user-request at scipy.org >> >> You can reach the person managing the list at >> ? ? ? scipy-user-owner at scipy.org >> >> When replying, please edit your Subject line so it is more specific >> than "Re: Contents of SciPy-User digest..." >> >> >> Today's Topics: >> >> ? ?1. Re: Error on importing scikits.learn (David Trethewey) >> ? ?2. Re: Error on importing scikits.learn (David Trethewey) >> ? ?3. Re: Error on importing scikits.learn (Helge Reikeras) >> ? ?4. ANN: SfePy 2010.1 (Robert Cimrman) >> >> >> ---------------------------------------------------------------------- >> >> Message: 1 >> Date: Mon, 01 Mar 2010 11:46:42 +0000 >> From: David Trethewey >> Subject: Re: [SciPy-User] Error on importing scikits.learn >> To: scipy-user at scipy.org >> Message-ID: <4B8BA922.6010900 at ast.cam.ac.uk> >> Content-Type: text/plain; charset=ISO-8859-1; format=flowed >> >> I get the following error message when attempting to import the >> expectation maximisation (em) module from scikits.learn : >> >>>>>> import scipy >>>>>> import numpy >>>>>> from scikits.learn.machine import em >>>>>> >>> Traceback (most recent call last): >>> ?File "", line 1, in >>> ?File "scikits/learn/machine/em/__init__.py", line 8, in >>> ? ?from online_em import OnGMM as _OnGMM >>> ?File "scikits/learn/machine/em/online_em.py", line 164, in >>> ? ?import _rawden >>> ImportError: No module named _rawden >>> >>> Does anyone know what this _rawden module is and why might it not be >>> found? >>> >>> David Trethewey >>> Institute of Astronomy, Cambridge, UK >>> >>> >>> >> >> >> >> ------------------------------ >> >> Message: 2 >> Date: Mon, 01 Mar 2010 11:51:14 +0000 >> From: David Trethewey >> Subject: Re: [SciPy-User] Error on importing scikits.learn >> To: scipy-user at scipy.org >> Message-ID: <4B8BAA32.3000004 at ast.cam.ac.uk> >> Content-Type: text/plain; charset=ISO-8859-1; format=flowed >> >> I have traced it back to an error in compiling scikits.learn itself: >> >> building 'scikits.learn.machine.em._rawden' extension >> compiling C sources >> C compiler: gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 >> -Wall -Wstrict-prototypes -fPIC >> >> compile options: '-I/usr/lib/python2.6/dist-packages/numpy/core/include >> -I/usr/include/python2.6 -c' >> gcc: scikits/learn/machine/em/src/pure_den.c >> scikits/learn/machine/em/src/pure_den.c:7:20: error: Python.h: No such >> file or directory >> >> David >> >> David Trethewey wrote: >> >>> I get the following error message when attempting to import the >>> expectation maximisation (em) module from scikits.learn : >>> >>>>>>> import scipy >>>>>>> import numpy >>>>>>> from scikits.learn.machine import em >>>>>>> >>>> Traceback (most recent call last): >>>> ?File "", line 1, in >>>> ?File "scikits/learn/machine/em/__init__.py", line 8, in >>>> ? ?from online_em import OnGMM as _OnGMM >>>> ?File "scikits/learn/machine/em/online_em.py", line 164, in >>>> ? ?import _rawden >>>> ImportError: No module named _rawden >>>> >>>> Does anyone know what this _rawden module is and why might it not be >>>> found? >>>> >>>> David Trethewey >>>> Institute of Astronomy, Cambridge, UK >>>> >>>> >>>> >>> >> >> >> >> ------------------------------ >> >> Message: 3 >> Date: Mon, 01 Mar 2010 13:55:01 +0200 >> From: "Helge Reikeras" >> Subject: Re: [SciPy-User] Error on importing scikits.learn >> To: "SciPy Users List" >> Message-ID: >> Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes >> >> On Mon, 01 Mar 2010 13:51:14 +0200, David Trethewey >> wrote: >> >> >>> compile options: '-I/usr/lib/python2.6/dist-packages/numpy/core/include >>> -I/usr/include/python2.6 -c' >>> gcc: scikits/learn/machine/em/src/pure_den.c >>> scikits/learn/machine/em/src/pure_den.c:7:20: error: Python.h: No such >>> file or directory >>> >> >> This is because you don't have the Python header files installed. You need >> to install these somehow. E.g. if you are running Ubuntu you do "sudo >> apt-get install python-dev". >> >> > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > From pav+sp at iki.fi Tue Mar 2 06:47:31 2010 From: pav+sp at iki.fi (Pauli Virtanen) Date: Tue, 2 Mar 2010 11:47:31 +0000 (UTC) Subject: [SciPy-User] segfaults with weave.inline References: Message-ID: Tue, 02 Mar 2010 03:21:25 -0800, Pitam Mitra wrote: > I am creating a new median filter for an astronomy application. Due to > speed issues, I decided to code it with weave.inline. However, I have > run into segfaults and I have no clue what to do next. You initialize zone_vector = array(()) but then the weave.inline code proceeds to write to positions zone_vector(0) ... zone_vector(n_pixels+1) which are out of bounds. weave.inline probably does not do bounds checking, so you get a segfault instead of bounds error. The fix is to make zone_vector large enough. -- Pauli Virtanen From dlrt2 at ast.cam.ac.uk Tue Mar 2 07:02:44 2010 From: dlrt2 at ast.cam.ac.uk (David Trethewey) Date: Tue, 02 Mar 2010 12:02:44 +0000 Subject: [SciPy-User] scikits.learn installation In-Reply-To: References: Message-ID: <4B8CFE64.6070706@ast.cam.ac.uk> Problem is sorted now, thanks for your help. David > > Message: 5 > Date: Tue, 2 Mar 2010 06:45:08 -0500 > From: josef.pktd at gmail.com > Subject: Re: [SciPy-User] scikits.learn installation > To: SciPy Users List > Message-ID: > <1cd32cbb1003020345k7d51d85ah5fd703139a20afbc at mail.gmail.com> > Content-Type: text/plain; charset=ISO-8859-1 > > On Tue, Mar 2, 2010 at 6:02 AM, David Trethewey wrote: > >> I installed the python headers and libboost. It now compiles without >> error but still when I actually try to import the em module I get the >> same error message; >> >>>>>> import scipy >>>>>> import numpy >>>>>> from scikits.learn.machine import em >>>>>> >>>>>> >>> Traceback (most recent call last): >>> ?File "", line 1, in >>> ?File "scikits/learn/machine/em/__init__.py", line 8, in >>> ? ?from online_em import OnGMM as _OnGMM >>> ?File "scikits/learn/machine/em/online_em.py", line 164, in >>> ? ?import _rawden >>> ImportError: No module named _rawden >>> > > You could search the source and build directories for *.pyd . > It happened to me in the pre-release version that the pyd files didn't > get copied correctly to the install directories. > > Josef > > >>> David Trethewey >>> Institute of Astronomy, Cambridge, UK >>> >>> >>> >>> >> >> scipy-user-request at scipy.org wrote: >> >>> Send SciPy-User mailing list submissions to >>> ? ? ? scipy-user at scipy.org >>> >>> To subscribe or unsubscribe via the World Wide Web, visit >>> ? ? ? http://mail.scipy.org/mailman/listinfo/scipy-user >>> or, via email, send a message with subject or body 'help' to >>> ? ? ? scipy-user-request at scipy.org >>> >>> You can reach the person managing the list at >>> ? ? ? scipy-user-owner at scipy.org >>> >>> When replying, please edit your Subject line so it is more specific >>> than "Re: Contents of SciPy-User digest..." >>> >>> >>> Today's Topics: >>> >>> ? ?1. Re: Error on importing scikits.learn (David Trethewey) >>> ? ?2. Re: Error on importing scikits.learn (David Trethewey) >>> ? ?3. Re: Error on importing scikits.learn (Helge Reikeras) >>> ? ?4. ANN: SfePy 2010.1 (Robert Cimrman) >>> >>> >>> ---------------------------------------------------------------------- >>> >>> Message: 1 >>> Date: Mon, 01 Mar 2010 11:46:42 +0000 >>> From: David Trethewey >>> Subject: Re: [SciPy-User] Error on importing scikits.learn >>> To: scipy-user at scipy.org >>> Message-ID: <4B8BA922.6010900 at ast.cam.ac.uk> >>> Content-Type: text/plain; charset=ISO-8859-1; format=flowed >>> >>> I get the following error message when attempting to import the >>> expectation maximisation (em) module from scikits.learn : >>> >>> >>>>>>> import scipy >>>>>>> import numpy >>>>>>> from scikits.learn.machine import em >>>>>>> >>>>>>> >>>> Traceback (most recent call last): >>>> ?File "", line 1, in >>>> ?File "scikits/learn/machine/em/__init__.py", line 8, in >>>> ? ?from online_em import OnGMM as _OnGMM >>>> ?File "scikits/learn/machine/em/online_em.py", line 164, in >>>> ? ?import _rawden >>>> ImportError: No module named _rawden >>>> >>>> Does anyone know what this _rawden module is and why might it not be >>>> found? >>>> >>>> David Trethewey >>>> Institute of Astronomy, Cambridge, UK >>>> >>>> >>>> >>>> >>> >>> ------------------------------ >>> >>> Message: 2 >>> Date: Mon, 01 Mar 2010 11:51:14 +0000 >>> From: David Trethewey >>> Subject: Re: [SciPy-User] Error on importing scikits.learn >>> To: scipy-user at scipy.org >>> Message-ID: <4B8BAA32.3000004 at ast.cam.ac.uk> >>> Content-Type: text/plain; charset=ISO-8859-1; format=flowed >>> >>> I have traced it back to an error in compiling scikits.learn itself: >>> >>> building 'scikits.learn.machine.em._rawden' extension >>> compiling C sources >>> C compiler: gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 >>> -Wall -Wstrict-prototypes -fPIC >>> >>> compile options: '-I/usr/lib/python2.6/dist-packages/numpy/core/include >>> -I/usr/include/python2.6 -c' >>> gcc: scikits/learn/machine/em/src/pure_den.c >>> scikits/learn/machine/em/src/pure_den.c:7:20: error: Python.h: No such >>> file or directory >>> >>> David >>> >>> David Trethewey wrote: >>> >>> >>>> I get the following error message when attempting to import the >>>> expectation maximisation (em) module from scikits.learn : >>>> >>>> >>>>>>>> import scipy >>>>>>>> import numpy >>>>>>>> from scikits.learn.machine import em >>>>>>>> >>>>>>>> >>>>> Traceback (most recent call last): >>>>> ?File "", line 1, in >>>>> ?File "scikits/learn/machine/em/__init__.py", line 8, in >>>>> ? ?from online_em import OnGMM as _OnGMM >>>>> ?File "scikits/learn/machine/em/online_em.py", line 164, in >>>>> ? ?import _rawden >>>>> ImportError: No module named _rawden >>>>> >>>>> Does anyone know what this _rawden module is and why might it not be >>>>> found? >>>>> >>>>> David Trethewey >>>>> Institute of Astronomy, Cambridge, UK >>>>> >>>>> >>>>> >>>>> >>> >>> ------------------------------ >>> >>> Message: 3 >>> Date: Mon, 01 Mar 2010 13:55:01 +0200 >>> From: "Helge Reikeras" >>> Subject: Re: [SciPy-User] Error on importing scikits.learn >>> To: "SciPy Users List" >>> Message-ID: >>> Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes >>> >>> On Mon, 01 Mar 2010 13:51:14 +0200, David Trethewey >>> wrote: >>> >>> >>> >>>> compile options: '-I/usr/lib/python2.6/dist-packages/numpy/core/include >>>> -I/usr/include/python2.6 -c' >>>> gcc: scikits/learn/machine/em/src/pure_den.c >>>> scikits/learn/machine/em/src/pure_den.c:7:20: error: Python.h: No such >>>> file or directory >>>> >>>> >>> This is because you don't have the Python header files installed. You need >>> to install these somehow. E.g. if you are running Ubuntu you do "sudo >>> apt-get install python-dev". >>> >>> >>> >> _______________________________________________ >> SciPy-User mailing list >> SciPy-User at scipy.org >> http://mail.scipy.org/mailman/listinfo/scipy-user >> >> > > > ------------------------------ > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > > > End of SciPy-User Digest, Vol 79, Issue 3 > ***************************************** > From ewald.zietsman at gmail.com Tue Mar 2 07:03:12 2010 From: ewald.zietsman at gmail.com (Ewald Zietsman) Date: Tue, 2 Mar 2010 14:03:12 +0200 Subject: [SciPy-User] helmert implementation (7 parameters - geometric transformation) Message-ID: Hi, I see your coordinates are very big numbers. These can lead to an ill-conditioned (AtA) matrix which can lead to a wrong inverse. Try using cholesky decomposition instead of using linalg.inv. The method is outlined here http://en.wikipedia.org/wiki/Cholesky_decomposition and numpy has routines for doing just this. The other option is to subtract the centre-of-mass from your coordinates i.e. P1 -> P1x - P1xave, P1y - P1yave etc. Do the same for P2. Calculate the transformation again. The shifts should now be zero but your rotations and scale should be statistically independent and correct. The difference between the two coordinate systems' centres of mass gives the shifts. Transformations far away from the origin rarely behaves well. Good luck. >> >>> Hi All, >>> >>> i'm tring to implement a function to perform a geometric trasformation >>> between a set of points in 2 different reference systems >>> >>> it is a 7 parameters trasformation (helmert) , based on last square method >>> it use as input 2 set of x,y,z coordinates in 2 different reference >>> systems >>> and give as output 7 parameters needed to performs transformation >>> from one reference system to the other one. >>> >>> http://en.wikipedia.org/wiki/Helmert_transformation >>> >>> this function is used in geodesy to "reproject" coordinates between 2 >>> different Datum >>> >>> i wrote it as : >>> >>> import numpy as np >>> from scipy import linalg >>> >>> def helmert(p1, p2): >>> ? ?L = np.loadtxt(p1) >>> ? ?A = np.zeros((3*L.shape[0],7),float) >>> ? ?A[ ::3, 0] = 1.0 >>> ? ?A[1::3, 1] = 1.0 >>> ? ?A[2::3, 2] = 1.0 >>> ? ?A[ ::3, 3] = L[:,0] >>> ? ?A[1::3, 3] = L[:,1] >>> ? ?A[2::3, 3] = L[:,2] >>> ? ?A[1::3, 4] = L[:,2] >>> ? ?A[2::3, 4] = -L[:,1] >>> ? ?A[ ::3, 5] = -L[:,2] >>> ? ?A[2::3, 5] = L[:,0] >>> ? ?A[ ::3, 6] = L[:,1] >>> ? ?A[1::3, 6] = -L[:,0] >>> ? ?G = np.loadtxt(p2) >>> ? ?Y = np.zeros((3*G.shape[0],1),float) >>> ? ?Y[ ::3, 0] = G[:,0] - L[:,0] >>> ? ?Y[1::3, 0] = G[:,1] - L[:,1] >>> ? ?Y[2::3, 0] = G[:,2] - L[:,2] >>> ? ?N = np.dot(A.T.conj(), A) >>> ? ?T = np.dot(A.T.conj(), Y) >>> ? ?C = np.dot(linalg.inv(N), T) >>> ? ?print C >>> >>> >>> from a pdf i find online >>> it has numerical examples >>> and i get different results :'( >>> >>> >>> p1 : >>> >>> 4402553.334 727053.937 4542823.474 >>> 4399375.347 703845.876 4549215.105 >>> 4412911.150 701094.435 4536518.139 >>> >>> >>> p2 : >>> >>> 4402553.569 727053.737 4542823.332 >>> 4399375.518 703845.639 4549214.880 >>> 4412911.336 701094.214 4536517.955 >>> >>> >>> pdf results : >>> >>> x0 ? ?-9.256 m >>> y0 ? ?-23.701 m >>> z0 ? ?16.792 m >>> Rx ? ?-0.0001990982 rad >>> Ry ? ?0.0001778762 rad >>> Rz ? ?0.00015 rad >>> ? ? ? ?0.00000046 >>> >>> >> The angles here look like degrees, not radians. Also, the last factor is >> pretty definitely wrong. It is given directly as the square root of the >> ratio of the variance of the two sets of vectors around their means minus 1. >> For instance >> >> sqrt(pt2.var(0).sum()/pt1.var(0).sum()) - 1 >> >> >>> >>> my results : >>> >>> [[ -9.91564629e+00] >>> ?[ -2.36172028e+01] >>> ?[ ?1.57283853e+01] >>> ?[ -2.68063331e-07] >>> ?[ ?3.04330048e-06] >>> ?[ -2.76148185e-06] >>> ?[ -2.31598150e-06]] >>> >>> >>> >> And my result agrees with neither ;) BTW, are you going from pt2 -> pt1 or >> vice versa? >> From dlrt2 at ast.cam.ac.uk Tue Mar 2 07:04:00 2010 From: dlrt2 at ast.cam.ac.uk (David Trethewey) Date: Tue, 02 Mar 2010 12:04:00 +0000 Subject: [SciPy-User] scikits.learn installation In-Reply-To: <4B8CFE99.20600@cam.ac.uk> References: <4B8CFE99.20600@cam.ac.uk> Message-ID: <4B8CFEB0.3030905@ast.cam.ac.uk> Problem is sorted now, thanks for your help. From spons at utm.csic.es Tue Mar 2 11:07:11 2010 From: spons at utm.csic.es (Sergi Pons Freixes) Date: Tue, 2 Mar 2010 17:07:11 +0100 Subject: [SciPy-User] Crash with Report from scikits.timeseries Message-ID: <2d88eb101003020807j62100bach77a413262f8c911b@mail.gmail.com> Hi All, When creating a simple report, I get an error which I'm not able to find out the cause: #Load the modules: In [1]: import scikits.timeseries as ts In [2]: import scikits.timeseries.lib.reportlib as rl #Load data: In [3]: labels = ["Temp", "S", "O2(%)", "dinophyceae", "diatoms", "chlorophyceae", "resta", "pseudonitzschia", "prymnesiophyceae(cocolitoforal)", "dinophysis", "alexandrium_minutum", "alexandrium_catenella", "dinophysis_caudata", "dinophysis_rotundata", "dinophysis_sacculus", "event"] In [4]: cols = [0] + range(3,19) In [5]: len(labels) Out[5]: 16 In [6]: len(cols) Out[6]: 17 In [7]: tmp = ts.tsfromtxt("AS.txt", freq='D', delimiter='\t', skip_header=1, usecols=cols, datecols=0, missing_values='nan' ) In [8]: tmp.data.shape Out[8]: (711,) #Create Report In [9]: report = rl.Report(tmp) In [10]: report() --------------------------------------------------------------------------- IndexError Traceback (most recent call last) /home/sergi/Dropbox/doctorat/dades_alfacs/ in () /usr/local/lib/python2.6/dist-packages/scikits.timeseries-0.91.3-py2.6-linux-i686.egg/scikits/timeseries/lib/reportlib.pyc in __call__(self, *tseries, **kwargs) 344 [datefmt_func(d)] + \ 345 [fmt_func[i](ser.series[d - _sd]) \ --> 346 for i, ser in enumerate(tseries)] 347 ) 348 /usr/lib/python2.6/dist-packages/numpy/ma/core.pyc in __getitem__(self, indx) 2576 # msg = "Masked arrays must be filled before they can be used as indices!" 2577 # raise IndexError, msg -> 2578 dout = ndarray.__getitem__(ndarray.view(self, ndarray), indx) 2579 # We could directly use ndarray.__getitem__ on self... 2580 # But then we would have to modify __array_finalize__ to prevent the IndexError: index out of bounds Is there something wrong with my data (even it is loaded with no errors). Regards, Sergi -- Sergi Pons Freixes Ph.D. Student Marine Technology Unit Centre Mediterrani d'Investigacions Marines i Ambientals (CMIMA-CSIC) Pg. Mar?tim Barceloneta, 37-49 E-08003 Barcelona (Spain) Ph. +34 93 230 95 00 (ext. 1510) Fax. +34 93 230 95 55 spons at utm.csic.es http://www.utm.csic.es From guilherme at gpfreitas.com Tue Mar 2 14:14:43 2010 From: guilherme at gpfreitas.com (Guilherme P. de Freitas) Date: Tue, 2 Mar 2010 11:14:43 -0800 Subject: [SciPy-User] Lagrange Multipliers in optimize.slsqp In-Reply-To: References: <1cd32cbb1002260555k3b72a50bsc2e606c9f0e68265@mail.gmail.com> Message-ID: Hi everyone, > Ah, this should be enough then to return the multipliers. See if > it gives what you'd expect? Then you can file an enhancement ticket > if you want the multipliers back. > > Index: slsqp.py > =================================================================== > --- slsqp.py (revision 6242) > +++ slsqp.py (working copy) > @@ -371,5 +371,6 @@ > return [list(x), > float(fx), > int(majiter), > - int(mode), > + list(w[:m]), > + int(mode), > exit_modes[int(mode)] ] > > Skipper > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > Thanks! That seems to give the right multipliers back. I'll file the ticket. Best, Guilherme -- Guilherme P. de Freitas http://www.gpfreitas.com From nwagner at iam.uni-stuttgart.de Tue Mar 2 14:31:04 2010 From: nwagner at iam.uni-stuttgart.de (Nils Wagner) Date: Tue, 02 Mar 2010 20:31:04 +0100 Subject: [SciPy-User] scipy.io.wavfile.read Message-ID: Hi all, I tried to read a *.wav file using scipy.io.wavfile.read from scipy.io import wavfile from pylab import plot, show samplerate, data = wavfile.read('BagPipes.wav') It failed with /home/nwagner/local/lib64/python2.6/site-packages/pytz/__init__.py:29: UserWarning: Module pkg_resources was already imported from /home/nwagner/local/lib64/python2.6/site-packages/setuptools-0.6c9-py2.6.egg/pkg_resources.py, but /home/nwagner/local/lib64/python2.6/site-packages/distribute-0.6.4-py2.6.egg is being added to sys.path from pkg_resources import resource_stream /home/nwagner/local/lib64/python2.6/site-packages/pytz/__init__.py:29: UserWarning: Module site was already imported from /usr/lib64/python2.6/site.pyc, but /home/nwagner/local/lib64/python2.6/site-packages/distribute-0.6.4-py2.6.egg is being added to sys.path from pkg_resources import resource_stream /home/nwagner/local/lib64/python2.6/site-packages/scipy/io/wavfile.py:20: WavFileWarning: Unfamiliar format bytes warnings.warn("Unfamiliar format bytes", WavFileWarning) /home/nwagner/local/lib64/python2.6/site-packages/scipy/io/wavfile.py:92: WavFileWarning: chunk not understood warnings.warn("chunk not understood", WavFileWarning) Traceback (most recent call last): File "read_wav.py", line 9, in samplerate, data = wavfile.read('BagPipes.wav') File "/home/nwagner/local/lib64/python2.6/site-packages/scipy/io/wavfile.py", line 90, in read data = _read_data_chunk(fid, noc, bits) File "/home/nwagner/local/lib64/python2.6/site-packages/scipy/io/wavfile.py", line 43, in _read_data_chunk data = numpy.fromfile(fid, dtype=dtype, count=size//bytes) ZeroDivisionError: integer division or modulo by zero Any idea ? The example file is available at http://www.ilovewavs.com/Effects/Music/Music.htm Cheers, Nils From jason-sage at creativetrax.com Tue Mar 2 14:45:30 2010 From: jason-sage at creativetrax.com (Jason Grout) Date: Tue, 02 Mar 2010 13:45:30 -0600 Subject: [SciPy-User] splmake gone from documentation Message-ID: <4B8D6ADA.9020508@creativetrax.com> I'm teaching a numerical analysis class and we are talking about different kinds of splines. I notice in some old scipy documentation that splmake is a nice function for making different kinds of splines (i.e., clamped, free, not_a_knot, etc.). However, I can't find splmake in the reference documentation at http://docs.scipy.org/doc/ in either the 0.7 or 0.8dev docs. I see splmake in my 0.7.0 installation, though (in the interpolate/interpolate.py file). Is the function splmake deprecated? I also notice that it is called (in the code) in the interp1d class init function, but it's impossible to specify the type (e.g., a clamped spline). Is there a reason why the kind argument is not passed to splmake? Thanks, Jason -- Jason Grout From guilherme at gpfreitas.com Tue Mar 2 14:57:17 2010 From: guilherme at gpfreitas.com (Guilherme P. de Freitas) Date: Tue, 2 Mar 2010 11:57:17 -0800 Subject: [SciPy-User] Lagrange Multipliers in optimize.slsqp In-Reply-To: References: <1cd32cbb1002260555k3b72a50bsc2e606c9f0e68265@mail.gmail.com> Message-ID: Just one note on this: the multipliers don't seem very accurate. On a *very* simple problem, the multiplier was correct only up to the 2nd decimal digit. Here is the problem: minimize - [ log(x) + log(y) ] subject to x + y = 8 The solution is at (4, 4) and the multiplier of the single equality constraint should be 1/4. The routine returns 0.2526. I thought this could be because I was not providing the derivatives, but that is not the case: when I provided the derivatives of both the objective function ('fprime') and the constraints ('fprime_eqcons'), I also got multipliers that were correct only up to the second decimal digit. Here is the full code if you want to verify it by yourself (first apply the modifications to slsqp.py as suggested by Skipper Seabold): import numpy as np from scipy.optimize import fmin_slsqp def u(x): return -np.sum(np.log(x)) def du(x): return -1.0/x def c(x): return np.sum(x) - 8 def dc(x): return np.ones((1, np.size(x))) initguess = np.array([1, 8]) sol = fmin_slsqp(func=u, x0=initguess, fprime=du, eqcons=[c], fprime_eqcons=dc, full_output=1, iprint=2, acc=1.0e-14) print(sol) keys = ('xopt', 'fopt', 'its', 'multipliers', 'exitmode', 'exitmsg') answer = dict(zip(keys, sol)) for key in answer: print(key, answer[key]) On Tue, Mar 2, 2010 at 11:14 AM, Guilherme P. de Freitas wrote: > Hi everyone, > >> Ah, this should be enough then to return the multipliers. ?See if >> it gives what you'd expect? ?Then you can file an enhancement ticket >> if you want the multipliers back. >> >> Index: slsqp.py >> =================================================================== >> --- slsqp.py ? ?(revision 6242) >> +++ slsqp.py ? ?(working copy) >> @@ -371,5 +371,6 @@ >> ? ? ? ? return [list(x), >> ? ? ? ? ? ? ? ? float(fx), >> ? ? ? ? ? ? ? ? int(majiter), >> - ? ? ? ? ? ? ? ?int(mode), >> + ? ? ? ? ? ? ? ?list(w[:m]), >> + ? ? ? ? ? ? ? ?int(mode), >> ? ? ? ? ? ? ? ? exit_modes[int(mode)] ] >> >> Skipper >> _______________________________________________ >> SciPy-User mailing list >> SciPy-User at scipy.org >> http://mail.scipy.org/mailman/listinfo/scipy-user >> > > Thanks! That seems to give the right multipliers back. I'll file the ticket. > > Best, > > Guilherme > > > -- > Guilherme P. de Freitas > http://www.gpfreitas.com > -- Guilherme P. de Freitas http://www.gpfreitas.com From d.l.goldsmith at gmail.com Tue Mar 2 15:42:20 2010 From: d.l.goldsmith at gmail.com (David Goldsmith) Date: Tue, 2 Mar 2010 12:42:20 -0800 Subject: [SciPy-User] splmake gone from documentation In-Reply-To: <4B8D6ADA.9020508@creativetrax.com> References: <4B8D6ADA.9020508@creativetrax.com> Message-ID: <45d1ab481003021242t523bd7b1ya4492d6947b1fa48@mail.gmail.com> On Tue, Mar 2, 2010 at 11:45 AM, Jason Grout wrote: > I'm teaching a numerical analysis class and we are talking about > different kinds of splines. I notice in some old scipy documentation > that splmake is a nice function for making different kinds of splines > (i.e., clamped, free, not_a_knot, etc.). However, I can't find splmake > in the reference documentation at http://docs.scipy.org/doc/ in either > the 0.7 or 0.8dev docs. I see splmake in my 0.7.0 installation, though > (in the interpolate/interpolate.py file). > It also appears in the scipy doc editor: http://docs.scipy.org/scipy/docs/scipy.interpolate.interpolate.splmake/ though with a pretty deficient docstring (perhaps you'd be willing to fix that?) ;-) I confirmed that it doesn't appear online at: http://docs.scipy.org/doc/scipy/reference/interpolate.html but I can't say why; perhaps because it's "buried" in module interpolate.interpolate? (The latter also being absent from the above online reference page.) > Is the function splmake deprecated? I also notice that it is called (in > the code) in the interp1d class init function, This suggests to me that the sub-package designer(s) considered splmake to be a "pseudo-private" method, primarily to be used internally within the sub-package and too low level for general use, but that would certainly beg your next question. > but it's impossible to > specify the type (e.g., a clamped spline). Is there a reason why the > kind argument is not passed to splmake? > Definitely someone else will have to answer that, sorry. :-( (Not that my answers above are all that useful...) DG > > Thanks, > > Jason > > -- > Jason Grout > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > -------------- next part -------------- An HTML attachment was scrubbed... URL: From timmichelsen at gmx-topmail.de Tue Mar 2 16:56:35 2010 From: timmichelsen at gmx-topmail.de (Tim Michelsen) Date: Tue, 02 Mar 2010 22:56:35 +0100 Subject: [SciPy-User] calculating intersection points in probability curves Message-ID: Hello, I am performing a curve fit and also showing a distribution histogram envelope in my plot. In order to help the reader to evaluate the result I would like to draw certain boundaries (vertical and horizontal lines). While I am aware on how to draw such lines with matplotlib, I would like to know whether there are some functions in scipy or matplotlib which help me to retrieve the coordinates a) at which two curves intersect b) at which a distribution reaches a certain value? Example: How do I get the y-axis value which is reached by the green curve in http://matplotlib.sourceforge.net/_images/histogram_demo_extended_021.png at a x-axis value of in 175? I could proably use a solver from numpy like http://docs.scipy.org/doc/numpy/reference/generated/numpy.linalg.solve.html#numpy.linalg.solve but if I plot a distribution, the equation of the envelove is unknown at the first place. I'd appreciate your help or pointers to examples. Thanks a lot in advance, Timmie From jason-sage at creativetrax.com Tue Mar 2 17:01:52 2010 From: jason-sage at creativetrax.com (Jason Grout) Date: Tue, 02 Mar 2010 16:01:52 -0600 Subject: [SciPy-User] splmake gone from documentation In-Reply-To: <4B8D6ADA.9020508@creativetrax.com> References: <4B8D6ADA.9020508@creativetrax.com> Message-ID: <4B8D8AD0.2030202@creativetrax.com> On 03/02/2010 01:45 PM, Jason Grout wrote: > I'm teaching a numerical analysis class and we are talking about > different kinds of splines. I notice in some old scipy documentation > that splmake is a nice function for making different kinds of splines > (i.e., clamped, free, not_a_knot, etc.). However, I can't find splmake > in the reference documentation at http://docs.scipy.org/doc/ in either > the 0.7 or 0.8dev docs. I see splmake in my 0.7.0 installation, though > (in the interpolate/interpolate.py file). > > Is the function splmake deprecated? I also notice that it is called (in > the code) in the interp1d class init function, but it's impossible to > specify the type (e.g., a clamped spline). Is there a reason why the > kind argument is not passed to splmake? > Digging a bit more, it seems that the splmake function is somewhat inoperable; that would explain why it's not in the docs. Apparently it looks for a '_find_%s'%kind function (e.g., _find_clamped function), which should specify the right conditions for a clamped spline. However, this and similar functions look like: def _find_clamped(xk, yk, order, conds, B): raise NotImplementedError return _find_user(xk, yk, order, conds, B) So a user just gets a NotImplementedError whenever trying to create pretty much any kind of spline using the kind argument of splmake. On the other hand, there is a function _get_spline3_Bb that appears to have some of the conditions specified (i.e., there is a switch statement, and there are some conditions for 'clamped', for example, but I haven't checked if these conditions are correct). However, _get_spline3_Bb is not called from anything. I don't know what to make of that! Thanks for your help and time, Jason -- Jason Grout From d.l.goldsmith at gmail.com Tue Mar 2 18:04:01 2010 From: d.l.goldsmith at gmail.com (David Goldsmith) Date: Tue, 2 Mar 2010 15:04:01 -0800 Subject: [SciPy-User] splmake gone from documentation In-Reply-To: <4B8D8AD0.2030202@creativetrax.com> References: <4B8D6ADA.9020508@creativetrax.com> <4B8D8AD0.2030202@creativetrax.com> Message-ID: <45d1ab481003021504w3cac3379sed371816be0e4ded@mail.gmail.com> On Tue, Mar 2, 2010 at 2:01 PM, Jason Grout wrote: > On 03/02/2010 01:45 PM, Jason Grout wrote: > > I'm teaching a numerical analysis class and we are talking about > > different kinds of splines. I notice in some old scipy documentation > > that splmake is a nice function for making different kinds of splines > > (i.e., clamped, free, not_a_knot, etc.). However, I can't find splmake > > in the reference documentation at http://docs.scipy.org/doc/ in either > > the 0.7 or 0.8dev docs. I see splmake in my 0.7.0 installation, though > > (in the interpolate/interpolate.py file). > > > > Is the function splmake deprecated? I also notice that it is called (in > > the code) in the interp1d class init function, but it's impossible to > > specify the type (e.g., a clamped spline). Is there a reason why the > > kind argument is not passed to splmake? > > > > > Digging a bit more, it seems that the splmake function is somewhat > inoperable; that would explain why it's not in the docs. Apparently it > looks for a '_find_%s'%kind function (e.g., _find_clamped function), > which should specify the right conditions for a clamped spline. > However, this and similar functions look like: > > def _find_clamped(xk, yk, order, conds, B): > raise NotImplementedError > return _find_user(xk, yk, order, conds, B) > > So a user just gets a NotImplementedError whenever trying to create > pretty much any kind of spline using the kind argument of splmake. > > On the other hand, there is a function _get_spline3_Bb that appears to > have some of the conditions specified (i.e., there is a switch > statement, and there are some conditions for 'clamped', for example, but > I haven't checked if these conditions are correct). However, > _get_spline3_Bb is not called from anything. I don't know what to make > of that! > > Thanks for your help and time, > > Jason > This is pretty embarrassing: it should either be implemented or cleared out, IMO. I searched the scipy tickets for interpolate NotImplementedError and got no hits (plenty of hits for interpolate and NotImplementedError, though) so I'm turning this into a ticket; if I'm wrong about it being a "bug," someone will just mark it "Will not fix" (and presumably explain why.) DG -------------- next part -------------- An HTML attachment was scrubbed... URL: From d.l.goldsmith at gmail.com Tue Mar 2 18:16:43 2010 From: d.l.goldsmith at gmail.com (David Goldsmith) Date: Tue, 2 Mar 2010 15:16:43 -0800 Subject: [SciPy-User] splmake gone from documentation In-Reply-To: <45d1ab481003021504w3cac3379sed371816be0e4ded@mail.gmail.com> References: <4B8D6ADA.9020508@creativetrax.com> <4B8D8AD0.2030202@creativetrax.com> <45d1ab481003021504w3cac3379sed371816be0e4ded@mail.gmail.com> Message-ID: <45d1ab481003021516t79aa4fe7j21608653f04797f8@mail.gmail.com> On Tue, Mar 2, 2010 at 3:04 PM, David Goldsmith wrote: > On Tue, Mar 2, 2010 at 2:01 PM, Jason Grout wrote: > >> On 03/02/2010 01:45 PM, Jason Grout wrote: >> > I'm teaching a numerical analysis class and we are talking about >> > different kinds of splines. I notice in some old scipy documentation >> > that splmake is a nice function for making different kinds of splines >> > (i.e., clamped, free, not_a_knot, etc.). However, I can't find splmake >> > in the reference documentation at http://docs.scipy.org/doc/ in either >> > the 0.7 or 0.8dev docs. I see splmake in my 0.7.0 installation, though >> > (in the interpolate/interpolate.py file). >> > >> > Is the function splmake deprecated? I also notice that it is called (in >> > the code) in the interp1d class init function, but it's impossible to >> > specify the type (e.g., a clamped spline). Is there a reason why the >> > kind argument is not passed to splmake? >> > >> >> Digging a bit more, it seems that the splmake function is somewhat >> inoperable; that would explain why it's not in the docs. Apparently it >> looks for a '_find_%s'%kind function (e.g., _find_clamped function), >> which should specify the right conditions for a clamped spline. >> However, this and similar functions look like: >> >> def _find_clamped(xk, yk, order, conds, B): >> raise NotImplementedError >> return _find_user(xk, yk, order, conds, B) >> >> So a user just gets a NotImplementedError whenever trying to create >> pretty much any kind of spline using the kind argument of splmake. >> >> On the other hand, there is a function _get_spline3_Bb that appears to >> have some of the conditions specified (i.e., there is a switch >> statement, and there are some conditions for 'clamped', for example, but >> I haven't checked if these conditions are correct). However, >> _get_spline3_Bb is not called from anything. I don't know what to make >> of that! >> >> Thanks for your help and time, >> >> Jason >> > > This is pretty embarrassing: it should either be implemented or cleared > out, IMO. I searched the scipy tickets for interpolate NotImplementedError > and got no hits (plenty of hits for interpolate and NotImplementedError, > though) so I'm turning this into a ticket; if I'm wrong about it being a > "bug," someone will just mark it "Will not fix" (and presumably explain > why.) > > DG > Ticket filed. DG -------------- next part -------------- An HTML attachment was scrubbed... URL: From massimodisasha at yahoo.it Tue Mar 2 18:29:42 2010 From: massimodisasha at yahoo.it (Massimo Di Stefano) Date: Wed, 3 Mar 2010 00:29:42 +0100 Subject: [SciPy-User] helmert implementation (7 parameters - geometric transformation) In-Reply-To: References: Message-ID: <9C573176-8F0F-485E-A9EA-0F04F9E8ECFE@yahoo.it> Hi, from here : http://docs.scipy.org/doc/numpy/reference/generated/numpy.linalg.cholesky.html seems it is applicable only on a square matrix. is that true ? reading this pdf : http://geomatica.como.polimi.it/corsi/misure_geodetiche/MG_03SistRif2.pdf scroll to the page : 15 i can see it isn't a common system : Y = AX but it is : Y = AX + B + V the points are : p1: 4402553.569 727053.737 4542823.332 4399375.518 703845.639 4549214.880 4412911.336 701094.214 4536517.955 p2 : 4402553.334 727053.937 4542823.474 4399375.347 703845.876 4549215.105 4412911.150 701094.435 4536518.139 tring to rewrite the code i did : L = np.loadtxt(p1) A = np.zeros((3*L.shape[0],7),float) A[ ::3, 0] = 1.0 A[1::3, 1] = 1.0 A[2::3, 2] = 1.0 A[1::3, 3] = L[:,2] A[2::3, 3] = -L[:,1] A[ ::3, 4] = -L[:,2] A[2::3, 4] = L[:,0] A[ ::3, 5] = L[:,1] A[1::3, 5] = -L[:,0] A[ ::3, 6] = L[:,0] A[1::3, 6] = L[:,1] A[2::3, 6] = L[:,2] G = np.loadtxt(p2) V = np.zeros((3*G.shape[0],1),float) V[ ::3, 0] = G[:,0] - L[:,0] V[1::3, 0] = G[:,1] - L[:,1] V[2::3, 0] = G[:,2] - L[:,2] i used the code in the previouse mail : N = np.dot(A.T.conj(), A) T = np.dot(A.T.conj(), Y) C = np.dot(linalg.inv(N), T) to solve a system like : Y = AX how can i change the code to solve : Y = AX + B + V instead ? the results in the dpf are : x0 -9.256 m y0 -23.701 m z0 16.792 m Rx -0.0001990982 rad Ry 0.0001778762 rad Rz 0.00015 rad ? 0.00000046 any suggestion, also on how to apply a decomposition can give me a great help! Il giorno 02/mar/2010, alle ore 19.00, scipy-user-request at scipy.org ha scritto: > Hi, > > I see your coordinates are very big numbers. These can lead to an > ill-conditioned (AtA) matrix which can lead to a wrong inverse. Try > using cholesky decomposition instead of using linalg.inv. The method > is outlined here http://en.wikipedia.org/wiki/Cholesky_decomposition > and numpy has routines for doing just this. The other option is to > subtract the centre-of-mass from your coordinates i.e. P1 -> P1x - > P1xave, P1y - P1yave etc. Do the same for P2. Calculate the > transformation again. The shifts should now be zero but your rotations > and scale should be statistically independent and correct. The > difference between the two coordinate systems' centres of mass gives > the shifts. Transformations far away from the origin rarely behaves > well. > > Good luck. -------------- next part -------------- An HTML attachment was scrubbed... URL: From charlesr.harris at gmail.com Tue Mar 2 20:02:31 2010 From: charlesr.harris at gmail.com (Charles R Harris) Date: Tue, 2 Mar 2010 18:02:31 -0700 Subject: [SciPy-User] helmert implementation (7 parameters - geometric transformation) In-Reply-To: <9C573176-8F0F-485E-A9EA-0F04F9E8ECFE@yahoo.it> References: <9C573176-8F0F-485E-A9EA-0F04F9E8ECFE@yahoo.it> Message-ID: On Tue, Mar 2, 2010 at 4:29 PM, Massimo Di Stefano wrote: > Hi, > > from here : > > > http://docs.scipy.org/doc/numpy/reference/generated/numpy.linalg.cholesky.html > > seems it is applicable only on a square matrix. > is that true ? > > reading this pdf : > > http://geomatica.como.polimi.it/corsi/misure_geodetiche/MG_03SistRif2.pdf > > scroll to the page : 15 > > i can see it isn't a common system : Y = AX > but it is : Y = AX + B + V > > > the points are : > > > > p1: > 4402553.569 727053.737 4542823.332 > 4399375.518 703845.639 4549214.880 > 4412911.336 701094.214 4536517.955 > > > p2 : > 4402553.334 727053.937 4542823.474 > 4399375.347 703845.876 4549215.105 > 4412911.150 701094.435 4536518.139 > > > > > tring to rewrite the code i did : > > L = np.loadtxt(p1) > > A = np.zeros((3*L.shape[0],7),float) > A[ ::3, 0] = 1.0 > A[1::3, 1] = 1.0 > A[2::3, 2] = 1.0 > A[1::3, 3] = L[:,2] > A[2::3, 3] = -L[:,1] > A[ ::3, 4] = -L[:,2] > A[2::3, 4] = L[:,0] > A[ ::3, 5] = L[:,1] > A[1::3, 5] = -L[:,0] > A[ ::3, 6] = L[:,0] > A[1::3, 6] = L[:,1] > A[2::3, 6] = L[:,2] > > G = np.loadtxt(p2) > > V = np.zeros((3*G.shape[0],1),float) > V[ ::3, 0] = G[:,0] - L[:,0] > V[1::3, 0] = G[:,1] - L[:,1] > V[2::3, 0] = G[:,2] - L[:,2] > > > i used the code in the previouse mail : > > N = np.dot(A.T.conj(), A) > T = np.dot(A.T.conj(), Y) > C = np.dot(linalg.inv(N), T) > > to solve a system like : > > Y = AX > > how can i change the code to solve : > > Y = AX + B + V > > instead ? > > the results in the dpf are : > > *x**0 -9.256 m * > ***y**0 -23.701 m * > ***z**0 16.792 m* > ***R**x -0.0001990982 rad * > ***R**y 0.0001778762 rad * > ***R**z 0.00015 rad * > **? 0.00000046 > > any suggestion, also on how to apply a decomposition can give me a great > help! > > I've attached a script for the computation. Two things of note: the angles in the pdf results are in degrees, the value of ? is pretty much in the noise (the condition number of the matrix is 10^10), and the fit you get with my version differs from the data by about 7mm. Note that the Helmert parameters result from a linearization of the rotation matrix, see Gauss-Newton for more about linearization and least squares, but in this case I think the limiting factor is the accuracy of the coordinates, not the linearization. Chuck -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: helmert.py Type: text/x-python Size: 876 bytes Desc: not available URL: From david at silveregg.co.jp Tue Mar 2 20:24:38 2010 From: david at silveregg.co.jp (David Cournapeau) Date: Wed, 03 Mar 2010 10:24:38 +0900 Subject: [SciPy-User] scipy.io.wavfile.read In-Reply-To: References: Message-ID: <4B8DBA56.5090207@silveregg.co.jp> Nils Wagner wrote: > Hi all, > > I tried to read a *.wav file using > > scipy.io.wavfile.read > > from scipy.io import wavfile > from pylab import plot, show > samplerate, data = wavfile.read('BagPipes.wav') > This file uses ADPCM encoding (a form of compression based on non linear encoding of each sample), which is most likely not supported by scipy.io.wavfile. Your two options are to convert this to a "normal" wav file with linear encoding, or to use audiolab which supports those files (because libsndile does). cheeers, David From jason-sage at creativetrax.com Tue Mar 2 20:42:58 2010 From: jason-sage at creativetrax.com (Jason Grout) Date: Tue, 02 Mar 2010 19:42:58 -0600 Subject: [SciPy-User] splmake gone from documentation In-Reply-To: <45d1ab481003021516t79aa4fe7j21608653f04797f8@mail.gmail.com> References: <4B8D6ADA.9020508@creativetrax.com> <4B8D8AD0.2030202@creativetrax.com> <45d1ab481003021504w3cac3379sed371816be0e4ded@mail.gmail.com> <45d1ab481003021516t79aa4fe7j21608653f04797f8@mail.gmail.com> Message-ID: <4B8DBEA2.2020003@creativetrax.com> On 03/02/2010 05:16 PM, David Goldsmith wrote: > On Tue, Mar 2, 2010 at 3:04 PM, David Goldsmith > > wrote: > > On Tue, Mar 2, 2010 at 2:01 PM, Jason Grout > > > wrote: > > On 03/02/2010 01:45 PM, Jason Grout wrote: > > I'm teaching a numerical analysis class and we are talking about > > different kinds of splines. I notice in some old scipy > documentation > > that splmake is a nice function for making different kinds > of splines > > (i.e., clamped, free, not_a_knot, etc.). However, I can't > find splmake > > in the reference documentation at http://docs.scipy.org/doc/ > in either > > the 0.7 or 0.8dev docs. I see splmake in my 0.7.0 > installation, though > > (in the interpolate/interpolate.py file). > > > > Is the function splmake deprecated? I also notice that it > is called (in > > the code) in the interp1d class init function, but it's > impossible to > > specify the type (e.g., a clamped spline). Is there a > reason why the > > kind argument is not passed to splmake? > > > > Digging a bit more, it seems that the splmake function is somewhat > inoperable; that would explain why it's not in the docs. > Apparently it > looks for a '_find_%s'%kind function (e.g., _find_clamped > function), > which should specify the right conditions for a clamped spline. > However, this and similar functions look like: > > def _find_clamped(xk, yk, order, conds, B): > raise NotImplementedError > return _find_user(xk, yk, order, conds, B) > > So a user just gets a NotImplementedError whenever trying to > create > pretty much any kind of spline using the kind argument of splmake. > > On the other hand, there is a function _get_spline3_Bb that > appears to > have some of the conditions specified (i.e., there is a switch > statement, and there are some conditions for 'clamped', for > example, but > I haven't checked if these conditions are correct). However, > _get_spline3_Bb is not called from anything. I don't know > what to make > of that! > > Thanks for your help and time, > > Jason > > > This is pretty embarrassing: it should either be implemented or > cleared out, IMO. I searched the scipy tickets for interpolate > NotImplementedError and got no hits (plenty of hits for > interpolate and NotImplementedError, though) so I'm turning this > into a ticket; if I'm wrong about it being a "bug," someone will > just mark it "Will not fix" (and presumably explain why.) > > DG > > > Ticket filed. Tracking this down a bit more through the revision history (using someone's git repository, since it's much easier for me to deal with git than svn...) This commit commented out the call to the spline3_Bb function (the call was then lines 597-600 in the splmake function) oliphant, 5/27/07 5:58 AM, Fix up recently added interpolation so that it is more general and scales to higher orders by using the B-spline representation of a piece-wise polynomial curve. Implemented the deBoor algorithm multiple times. Then the next commit to interpolate.py: oliphant, 5/30/07 4:49 AM, Set-up interpolate structure to support more than just smoothest condition. deleted the commented call to spline3_Bb and replaced it with a call to the find_* functions, and introduced a lot of find_* functions that were the stubs that we see today (basically, none of the options are implemented). The spline3_Bb function was left in, but nothing calls it. Travis, I'm curious about the rationale behind these changes. Were you planning on copying the code from spline3_Bb into the various stub _find_* functions, or was there something that made it difficult to do that? Thanks, Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: From pitam at deepspace.ucsb.edu Tue Mar 2 21:00:22 2010 From: pitam at deepspace.ucsb.edu (pitam) Date: Tue, 02 Mar 2010 18:00:22 -0800 Subject: [SciPy-User] segfaults with weave.inline Message-ID: <1267581622.9204.8.camel@zephyr.deepspace.ucsb.edu> Hi, I did some more testing on this. The zone_vector() had a wrong comment on it. Its really small, it is 8*(number of elements in the star shaped pattern - that is zone_outer_radius - zone_inner_radius) I added some extra lines to see where the thing breaks - it does the median filter to the full image. After the last pixel, it breaks. This is about the same time where the C code should end. Hence, my guess is there is a memory leak. IS there any way to check this? Pitam Mitra Deepspace Group, UCSB Physics. From pitam at deepspace.ucsb.edu Tue Mar 2 23:08:08 2010 From: pitam at deepspace.ucsb.edu (pitam) Date: Tue, 02 Mar 2010 20:08:08 -0800 Subject: [SciPy-User] segfaults with weave.inline Message-ID: <1267589288.9204.11.camel@zephyr.deepspace.ucsb.edu> I did some more research on this. My code uses blitz array, where the original array was a numeric array of numpy. This is where the fault is at. I need to convert the blitz array back to a numeric numpy array. How do I do this, any Ideas?? Original post: http://mail.scipy.org/pipermail/scipy-user/2010-March/024478.html Follow-ups: http://mail.scipy.org/pipermail/scipy-user/2010-March/024498.html Pitam Mitra Deepspace Group UCSB Physics From sebastian.walter at gmail.com Wed Mar 3 04:14:39 2010 From: sebastian.walter at gmail.com (Sebastian Walter) Date: Wed, 3 Mar 2010 10:14:39 +0100 Subject: [SciPy-User] Google Summer of Code... In-Reply-To: References: <4B8C3C81.7000509@noaa.gov> <1cd32cbb1003011435u725d37e5ne3c98475f3cfa8a@mail.gmail.com> <3d375d731003011443h1a5c0b02h837f5af3f5348037@mail.gmail.com> Message-ID: I could mentor an algorithmic differentiation (AD) project, but I'm still not quite sure how to proceed. Should I write up a proposal on the wiki and after that propose the project on the http://mail.python.org/mailman/listinfo/soc2010-mentors mailing list? I have already created a package that I believe would be a very good addition to scipy/numpy (preferably numpy) when it is mature enough. It is hosted on http://github.com/b45ch1/taylorpoly The package is not an AD tool but makes it very easy to create AD tools using those algorithms. An illustrative example how to do (forward mode) AD is given in: http://github.com/b45ch1/taylorpoly/blob/master/examples/utps_for_algorithmic_differentiation.py What is missing up to now are differentiated algorithms for tan, atan, asin, sinh, etc. (in Taylor arithmetic) as well as the core algorithms for reverse mode AD. Implementing those algorithms should be doable in 4 months. Also, since the task is to implement many small algorithms, this project is unlikely to fail completely. The worst that can happen is that not as many algorithms get implemented as one could wish for. Could anyone give feedback if that project is ok? best regards, Sebastian On Tue, Mar 2, 2010 at 12:32 AM, David Warde-Farley wrote: > On 1-Mar-10, at 5:59 PM, Skipper Seabold wrote: > >> I would also encourage anyone who has ideas to edit the wiki here to >> reflect the current project wishlist (especially if you're willing to >> mentor): http://projects.scipy.org/scipy/wiki/SummerofCodeIdeas ?IMHO, >> the more ideas there are, the more chance of grabbing interested and >> diverse sets of students provided people are willing to mentor. > > I just reorganized the page a bit, to separate out the stuff that is > already going on, like statsmodels, fwrap and the Py3k/datetime stuff, > from things that have been listed for a while but never really picked > up on. > > David > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > From nwagner at iam.uni-stuttgart.de Wed Mar 3 04:47:28 2010 From: nwagner at iam.uni-stuttgart.de (Nils Wagner) Date: Wed, 03 Mar 2010 10:47:28 +0100 Subject: [SciPy-User] scipy.io.wavfile.read In-Reply-To: <4B8DBA56.5090207@silveregg.co.jp> References: <4B8DBA56.5090207@silveregg.co.jp> Message-ID: On Wed, 03 Mar 2010 10:24:38 +0900 David Cournapeau wrote: > Nils Wagner wrote: >> Hi all, >> >> I tried to read a *.wav file using >> >> scipy.io.wavfile.read >> >> from scipy.io import wavfile >> from pylab import plot, show >> samplerate, data = wavfile.read('BagPipes.wav') >> > > This file uses ADPCM encoding (a form of compression >based on non linear > encoding of each sample), which is most likely not >supported by > scipy.io.wavfile. Your two options are to convert this >to a "normal" wav > file with linear encoding, or to use audiolab which >supports those files > (because libsndile does). > Is it possible to improve the message returned by wavfile.read in case of special encodings ? Nils From pav+sp at iki.fi Wed Mar 3 10:22:07 2010 From: pav+sp at iki.fi (Pauli Virtanen) Date: Wed, 3 Mar 2010 15:22:07 +0000 (UTC) Subject: [SciPy-User] helmert implementation (7 parameters - geometric transformation) References: <9C573176-8F0F-485E-A9EA-0F04F9E8ECFE@yahoo.it> Message-ID: Wed, 03 Mar 2010 00:29:42 +0100, Massimo Di Stefano wrote: > from here : > > http://docs.scipy.org/doc/numpy/reference/generated/ > numpy.linalg.cholesky.html > > seems it is applicable only on a square matrix. is that true ? Cholesky decomposition works only on Hermitian matrices -- so being square is one requirement. Also, if you are going to do least-squares fitting, use linalg.lstsq; it does the same thing as (A^T A)^-1 A^T b, but should be numerically more stable. -- Pauli Virtanen From pav+sp at iki.fi Wed Mar 3 10:36:59 2010 From: pav+sp at iki.fi (Pauli Virtanen) Date: Wed, 3 Mar 2010 15:36:59 +0000 (UTC) Subject: [SciPy-User] segfaults with weave.inline References: <1267589288.9204.11.camel@zephyr.deepspace.ucsb.edu> Message-ID: Tue, 02 Mar 2010 20:08:08 -0800, pitam wrote: > I did some more research on this. > > My code uses blitz array, where the original array was a numeric array > of numpy. This is where the fault is at. I need to convert the blitz > array back to a numeric numpy array. How do I do this, any Ideas?? As said, to my understanding, 1. zone_vector is modified *in-place*, you don't need to convert it back. 2. Instead, you have to allocate the numpy array big enough to hold *all* of the data 3. Blitz does not check array bounds 4. Writing out of array bounds does not necessarily result to a segmentation fault immediately, it can manifest later. So, you should replace zone_vector = array(()) with zone_vector = zeros((size_of_zone_vector,)) Did you try this? If yes, does it fix the problem? Best regards, -- Pauli Virtanen From nwagner at iam.uni-stuttgart.de Wed Mar 3 12:06:14 2010 From: nwagner at iam.uni-stuttgart.de (Nils Wagner) Date: Wed, 03 Mar 2010 18:06:14 +0100 Subject: [SciPy-User] scikits.audiolab NameError Message-ID: Hi all, I installed audiolab via git clone git://github.com/cournape/audiolab.git python setup.py install --prefix=$HOME/local How can I fix the backend problem wrt. alsa ? python -i test_sndfile.py /data/home/nwagner/local/lib/python2.5/site-packages/scikits.audiolab-0.11.0.dev-py2.5-linux-x86_64.egg/scikits/audiolab/soundio/play.py:48: UserWarning: Could not import alsa backend; most probably, you did not have alsa headers when building audiolab warnings.warn("Could not import alsa backend; most probably, " Traceback (most recent call last): File "test_sndfile.py", line 332, in NumpyTest().run() NameError: name 'NumpyTest' is not defined AFAIK, NumpyTest is obsolete. Am I missing something ? Nils From agile.aspect at gmail.com Wed Mar 3 13:01:22 2010 From: agile.aspect at gmail.com (Agile Aspect) Date: Wed, 3 Mar 2010 10:01:22 -0800 Subject: [SciPy-User] scikits.audiolab NameError In-Reply-To: References: Message-ID: On Wed, Mar 3, 2010 at 9:06 AM, Nils Wagner wrote: > Hi all, > > I installed audiolab via > > git clone git://github.com/cournape/audiolab.git > python setup.py install --prefix=$HOME/local > > How can I fix the backend problem wrt. alsa ? > > > python -i test_sndfile.py > /data/home/nwagner/local/lib/python2.5/site-packages/scikits.audiolab-0.11.0.dev-py2.5-linux-x86_64.egg/scikits/audiolab/soundio/play.py:48: > UserWarning: Could not import alsa backend; most probably, > you did not have alsa headers when building audiolab > ? warnings.warn("Could not import alsa backend; most > probably, " > Traceback (most recent call last): > ? File "test_sndfile.py", line 332, in > ? ? NumpyTest().run() > NameError: name 'NumpyTest' is not defined > > > AFAIK, NumpyTest is obsolete. Am I missing something ? > > Nils > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > On CentOS/Fedora yum install alsa\* -- Enjoy global warming while it lasts. From nwagner at iam.uni-stuttgart.de Wed Mar 3 14:01:55 2010 From: nwagner at iam.uni-stuttgart.de (Nils Wagner) Date: Wed, 03 Mar 2010 20:01:55 +0100 Subject: [SciPy-User] scikits.audiolab NameError In-Reply-To: References: Message-ID: On Wed, 3 Mar 2010 10:01:22 -0800 Agile Aspect wrote: > On Wed, Mar 3, 2010 at 9:06 AM, Nils Wagner > wrote: >> Hi all, >> >> I installed audiolab via >> >> git clone git://github.com/cournape/audiolab.git >> python setup.py install --prefix=$HOME/local >> >> How can I fix the backend problem wrt. alsa ? >> >> >> python -i test_sndfile.py >> /data/home/nwagner/local/lib/python2.5/site-packages/scikits.audiolab-0.11.0.dev-py2.5-linux-x86_64.egg/scikits/audiolab/soundio/play.py:48: >> UserWarning: Could not import alsa backend; most >>probably, >> you did not have alsa headers when building audiolab >> ? warnings.warn("Could not import alsa backend; most >> probably, " >> Traceback (most recent call last): >> ? File "test_sndfile.py", line 332, in >> ? ? NumpyTest().run() >> NameError: name 'NumpyTest' is not defined >> >> >> AFAIK, NumpyTest is obsolete. Am I missing something ? >> >> Nils >> _______________________________________________ >> SciPy-User mailing list >> SciPy-User at scipy.org >> http://mail.scipy.org/mailman/listinfo/scipy-user >> > > On CentOS/Fedora > > yum install alsa\* > alsa is already installed... header file are available in /usr/include/alsa the library libasound.a is in /usr/lib64 I haven't a clue what is going on here. Nils From PHobson at Geosyntec.com Wed Mar 3 14:09:37 2010 From: PHobson at Geosyntec.com (PHobson at Geosyntec.com) Date: Wed, 3 Mar 2010 14:09:37 -0500 Subject: [SciPy-User] Scipy's probplot compared to R's qqplot Message-ID: Hey folks, I've taken more of an interest in statistics and Scipy lately and decided to compare the scipy.stats.probplot() function to R's qqplot(). For a given dataset, the results are slightly different. Here's a link to the script I wrote to do the comparison. http://dpaste.com/167464/ Basically, it does the following: -Uses numpy to generate some fake, noramlly distributed data -Uses both R and Scipy to compute the values needed for quantile/probability plot -Computes linear regressions on the quantile data with both R and Scipy. -prints some output to compare the two My initial conclusions: 1) R's lm(y~x) and scipy.stats.linregress(x,y) yield the same slope and intercept of a linear model. (good) 2) R and Scipy compute the quantiles of a dataset in slightly different manners (??) Any clue as to why the discrepancy in #2 occurs? Would you consider it a big deal? I'm using: Python v2.6.2 (XP) and v2.6.4 (Karmic and Snow Leopard) Scipy v0.7.1 Numpy v1.4.0 R v2.10.0 Rpy2 v2.0.8 Thanks, -Paul H. From josef.pktd at gmail.com Wed Mar 3 14:36:39 2010 From: josef.pktd at gmail.com (josef.pktd at gmail.com) Date: Wed, 3 Mar 2010 14:36:39 -0500 Subject: [SciPy-User] Scipy's probplot compared to R's qqplot In-Reply-To: References: Message-ID: <1cd32cbb1003031136w3f7dfcc8qdba53be55fef3cd5@mail.gmail.com> On Wed, Mar 3, 2010 at 2:09 PM, wrote: > Hey folks, > > I've taken more of an interest in statistics and Scipy lately and decided to compare the scipy.stats.probplot() function to R's qqplot(). For a given dataset, the results are slightly different. > > Here's a link to the script I wrote to do the comparison. > http://dpaste.com/167464/ > > Basically, it does the following: > -Uses numpy to generate some fake, noramlly distributed data > -Uses both R and Scipy to compute the values needed for quantile/probability plot > -Computes linear regressions on the quantile data with both R and Scipy. > -prints some output to compare the two > > My initial conclusions: > 1) R's lm(y~x) and scipy.stats.linregress(x,y) yield the same slope and intercept of a linear model. (good) > 2) R and Scipy compute the quantiles of a dataset in slightly different manners (??) > > Any clue as to why the discrepancy in #2 occurs? Would you consider it a big deal? I would consider any significant deviation a big deal, unless we know that there are differences in the definitions or underlying assumptions. I'm not sure what's going on since I never looked at the details of probplot. However, when I plot the quantiles >>> plt.plot(np.sort(qR)) >>> plt.plot(qS[0]) >>> plt.show() then the graph looks almost the same except for the first and last point. qS[0]-np.sort(qR) differs in the second decimal, except for first and last observation. My guess would be that there are some differences for example in the continuity correction, or similar. The boundary points, however, look suspicious. Thanks for checking this, Josef I'm using: > Python v2.6.2 (XP) and v2.6.4 (Karmic and Snow Leopard) > Scipy v0.7.1 > Numpy v1.4.0 > R v2.10.0 > Rpy2 v2.0.8 > > Thanks, > -Paul H. > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > From robert.kern at gmail.com Wed Mar 3 14:38:21 2010 From: robert.kern at gmail.com (Robert Kern) Date: Wed, 3 Mar 2010 13:38:21 -0600 Subject: [SciPy-User] Scipy's probplot compared to R's qqplot In-Reply-To: References: Message-ID: <3d375d731003031138p42db6a4dg3ad5285ee34436c4@mail.gmail.com> On Wed, Mar 3, 2010 at 13:09, wrote: > Hey folks, > > I've taken more of an interest in statistics and Scipy lately and decided to compare the scipy.stats.probplot() function to R's qqplot(). For a given dataset, the results are slightly different. > > Here's a link to the script I wrote to do the comparison. > http://dpaste.com/167464/ > > Basically, it does the following: > -Uses numpy to generate some fake, noramlly distributed data > -Uses both R and Scipy to compute the values needed for quantile/probability plot > -Computes linear regressions on the quantile data with both R and Scipy. > -prints some output to compare the two > > My initial conclusions: > 1) R's lm(y~x) and scipy.stats.linregress(x,y) yield the same slope and intercept of a linear model. (good) > 2) R and Scipy compute the quantiles of a dataset in slightly different manners (??) > > Any clue as to why the discrepancy in #2 occurs? There are several, slightly different but mostly reasonable ways of computing quantiles. > Would you consider it a big deal? Probably not, but I'm happy to entertain arguments to the contrary if you would care to explain how R is computing the quantiles. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From PHobson at Geosyntec.com Wed Mar 3 14:49:53 2010 From: PHobson at Geosyntec.com (PHobson at Geosyntec.com) Date: Wed, 3 Mar 2010 14:49:53 -0500 Subject: [SciPy-User] Scipy's probplot compared to R's qqplot In-Reply-To: <1cd32cbb1003031136w3f7dfcc8qdba53be55fef3cd5@mail.gmail.com> References: <1cd32cbb1003031136w3f7dfcc8qdba53be55fef3cd5@mail.gmail.com> Message-ID: > On Wed, Mar 3, 2010 at 2:09 PM, wrote: > > Hey folks, > > > > I've taken more of an interest in statistics and Scipy lately and > decided to compare the scipy.stats.probplot() function to R's qqplot(). > For a given dataset, the results are slightly different. > > > > Here's a link to the script I wrote to do the comparison. > > http://dpaste.com/167464/ > > > > Basically, it does the following: > > -Uses numpy to generate some fake, noramlly distributed data > > -Uses both R and Scipy to compute the values needed for > quantile/probability plot > > -Computes linear regressions on the quantile data with both R and > Scipy. > > -prints some output to compare the two > > > > My initial conclusions: > > 1) R's lm(y~x) and scipy.stats.linregress(x,y) yield the same slope and > intercept of a linear model. (good) > > 2) R and Scipy compute the quantiles of a dataset in slightly different > manners (??) > > > > Any clue as to why the discrepancy in #2 occurs? Would you consider it > a big deal? > From: scipy-user-bounces at scipy.org [mailto:scipy-user-bounces at scipy.org] > On Behalf Of josef.pktd at gmail.com > I would consider any significant deviation a big deal, unless we know > that there are differences in the definitions or underlying > assumptions. > > I'm not sure what's going on since I never looked at the details of > probplot. However, when I plot the quantiles > >>> plt.plot(np.sort(qR)) > >>> plt.plot(qS[0]) > >>> plt.show() > > then the graph looks almost the same except for the first and last point. Yes. When I plotted them, I could not visually distinguish them (see attached). I forgot to mention that. > qS[0]-np.sort(qR) > > differs in the second decimal, except for first and last observation. > My guess would be that there are some differences for example in the > continuity correction, or similar. > > The boundary points, however, look suspicious. Thanks for looking further into this. When I saw that the slopes and intercepts were different, I immediately inspected just the max and min values (laziness, sorry). If I find some time next week, I'll dig around in the source and see if I can't figure out what's happening at those points. -Paul H. -------------- next part -------------- A non-text attachment was scrubbed... Name: prob_plot_test.png Type: image/png Size: 23775 bytes Desc: prob_plot_test.png URL: From josef.pktd at gmail.com Wed Mar 3 15:08:00 2010 From: josef.pktd at gmail.com (josef.pktd at gmail.com) Date: Wed, 3 Mar 2010 15:08:00 -0500 Subject: [SciPy-User] Scipy's probplot compared to R's qqplot In-Reply-To: References: <1cd32cbb1003031136w3f7dfcc8qdba53be55fef3cd5@mail.gmail.com> Message-ID: <1cd32cbb1003031208j7dc059a3y47288da1c2d39feb@mail.gmail.com> On Wed, Mar 3, 2010 at 2:49 PM, wrote: >> On Wed, Mar 3, 2010 at 2:09 PM, ? wrote: >> > Hey folks, >> > >> > I've taken more of an interest in statistics and Scipy lately and >> decided to compare the scipy.stats.probplot() function to R's qqplot(). >> For a given dataset, the results are slightly different. >> > >> > Here's a link to the script I wrote to do the comparison. >> > http://dpaste.com/167464/ >> > >> > Basically, it does the following: >> > -Uses numpy to generate some fake, noramlly distributed data >> > -Uses both R and Scipy to compute the values needed for >> quantile/probability plot >> > -Computes linear regressions on the quantile data with both R and >> Scipy. >> > -prints some output to compare the two >> > >> > My initial conclusions: >> > 1) R's lm(y~x) and scipy.stats.linregress(x,y) yield the same slope and >> intercept of a linear model. (good) >> > 2) R and Scipy compute the quantiles of a dataset in slightly different >> manners (??) >> > >> > Any clue as to why the discrepancy in #2 occurs? Would you consider it >> a big deal? > > >> From: scipy-user-bounces at scipy.org [mailto:scipy-user-bounces at scipy.org] >> On Behalf Of josef.pktd at gmail.com >> I would consider any significant deviation a big deal, unless we know >> that there are differences in the definitions or underlying >> assumptions. >> >> I'm not sure what's going on since I never looked at the details of >> probplot. However, when I plot the quantiles >> >>> plt.plot(np.sort(qR)) >> >>> plt.plot(qS[0]) >> >>> plt.show() >> >> then the graph looks almost the same except for the first and last point. > > Yes. When I plotted them, I could not visually distinguish them (see attached). I forgot to mention that. > >> qS[0]-np.sort(qR) >> >> differs in the second decimal, except for first and last observation. >> My guess would be that there are some differences for example in the >> continuity correction, or similar. >> >> The boundary points, however, look suspicious. > > Thanks for looking ?further into this. When I saw that the slopes and intercepts were different, I immediately inspected just the max and min values (laziness, sorry). If I find some time next week, I'll dig around in the source and see if I can't figure out what's happening at those points. my prime candidate for the 2nd decimal differences, are differences in the correction Ui[1:-1] = (i-0.3175)/(N+0.365) There are several conventions, David Huard posted a list of them attached to a ticket (?), for empirical cdf. There might be another correction for boundary points that is different. Ui[-1] = 0.5**(1.0/N) Ui[0] = 1-Ui[-1] But for graphical inspection, R and scipy look close enough. Josef > -Paul H. > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > > From PHobson at Geosyntec.com Wed Mar 3 15:15:05 2010 From: PHobson at Geosyntec.com (PHobson at Geosyntec.com) Date: Wed, 3 Mar 2010 15:15:05 -0500 Subject: [SciPy-User] Scipy's probplot compared to R's qqplot In-Reply-To: <3d375d731003031138p42db6a4dg3ad5285ee34436c4@mail.gmail.com> References: <3d375d731003031138p42db6a4dg3ad5285ee34436c4@mail.gmail.com> Message-ID: > On Wed, Mar 3, 2010 at 13:09, wrote: > > 2) R and Scipy compute the quantiles of a dataset in slightly different > > manners (??) > > > > Any clue as to why the discrepancy in #2 occurs? > From: scipy-user-bounces at scipy.org [mailto:scipy-user-bounces at scipy.org] > On Behalf Of Robert Kern > There are several, slightly different but mostly reasonable ways of > computing quantiles. Good to know. Thanks. > > Would you consider it a big deal? > Probably not, but I'm happy to entertain arguments to the contrary if > you would care to explain how R is computing the quantiles. After reading Josef's response, I'm only concerned with the min/max values. R, like you, mentions that several methods are available to compute quantiles. By default, it uses what it calls Type 7: """ All sample quantiles are defined as weighted averages of consecutive order statistics. Sample quantiles of type i are defined by: Q[i](p) = (1 - gamma) x[j] + gamma x[j+1], where 1 <= i <= 9, (j-m)/n <= p < (j-m+1)/n, x[j] is the jth order statistic, n is the sample size, the value of gamma is a function of j = floor(np + m) and g = np + m - j, and m is a constant determined by the sample quantile type. [snip] *Continuous sample quantile types 4 through 9* For types 4 through 9, Q[i](p) is a continuous function of p, with gamma = g and m given below. The sample quantiles can be obtained equivalently by linear interpolation between the points (p[k],x[k]) where x[k] is the kth order statistic. Specific expressions for p[k] are given below. [snip] Type 7 m = 1-p. p[k] = (k - 1) / (n - 1). In this case, p[k] = mode[F(x[k])]. This is used by S. """ I haven't really had time to look into Scipy's method yet. I'll dig a little deeper as soon as I get the chance. Thanks for the insight, -Paul H. From robert.kern at gmail.com Wed Mar 3 16:15:14 2010 From: robert.kern at gmail.com (Robert Kern) Date: Wed, 3 Mar 2010 15:15:14 -0600 Subject: [SciPy-User] scipy.interpolate.rbf sensitive to input noise ? In-Reply-To: <1cd32cbb1002230959u46a4da49ie6e7220d5964a381@mail.gmail.com> References: <1cd32cbb1002220608l3da7f92aue8d415d945d9e33b@mail.gmail.com> <43bfdeb3-9d1a-4307-a0ce-96b6639c217e@o3g2000yqb.googlegroups.com> <1cd32cbb1002220845o3ad94ba8g599f25ec170c6106@mail.gmail.com> <1cd32cbb1002220927h229e578bhe18737d803fddc76@mail.gmail.com> <1c841a64-786d-4069-9f88-fcaae5a0d063@t42g2000vbt.googlegroups.com> <3d375d731002230946m75c7cacbk4a45e8e3db518d54@mail.gmail.com> <1cd32cbb1002230957w35b7119ay7270bbbc1892ce25@mail.gmail.com> <1cd32cbb1002230959u46a4da49ie6e7220d5964a381@mail.gmail.com> Message-ID: <3d375d731003031315p7bc93005ibd7fed09c2ccbd41@mail.gmail.com> On Tue, Feb 23, 2010 at 11:59, wrote: > On Tue, Feb 23, 2010 at 12:57 PM, ? wrote: >> On Tue, Feb 23, 2010 at 12:46 PM, Robert Kern wrote: >>> On Tue, Feb 23, 2010 at 11:43, denis wrote: >>>> Robert, Josef, >>>> ?thanks much for taking the time to look at RBF some more. >>>> Summary, correct me: >>>> ? ?A - smooth*I in rbf.py is a sign error (ticket ?) >>> >>> Not necessarily. It seems to work well in at least some cases. Find a >>> reference that says otherwise if you want it changed. >> >> chapter 2 page 16, for gaussian process. As I said I don't know about >> the other methods >> > > http://docs.google.com/viewer?a=v&q=cache:qs8AaAxO6nkJ:www.gaussianprocess.org/gpml/chapters/RW2.pdf+gaussian+process+noise+Ridge&hl=en&gl=ca&pid=bl&srcid=ADGEESj4j8osT6cOIc65r3OaeAtQO_dzgZD4YxSAEkFTeRZajBcROJpJJ9zTlMSrD2OaK1iOJYgy8QqH_Nr0rNxf41faNihCdIzWyVOYxtCFIR7H8mdQZAKFoeaRkFamQlCKhp_s1FOI&sig=AHIEtbQK35MLfnZAySw3lF-dR_mNcSaP3w > > google links are very short, missed a part I've found a couple of things on RBFs specifically that agree. However, the original source on which our implementation is based does subtract. He may have a source that uses a negative sign. http://www.mathworks.co.uk/matlabcentral/fileexchange/10056-scattered-data-interpolation-and-approximation-using-radial-base-functions Playing around, it seems to me that some of the radial functions create smoother approximations with large positive values (with the current implementation) while others create smoother approximations with large negative values. It's possible that it's just a convention as to which sign you use. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From josef.pktd at gmail.com Wed Mar 3 16:31:26 2010 From: josef.pktd at gmail.com (josef.pktd at gmail.com) Date: Wed, 3 Mar 2010 16:31:26 -0500 Subject: [SciPy-User] scipy.interpolate.rbf sensitive to input noise ? In-Reply-To: <3d375d731003031315p7bc93005ibd7fed09c2ccbd41@mail.gmail.com> References: <1cd32cbb1002220608l3da7f92aue8d415d945d9e33b@mail.gmail.com> <43bfdeb3-9d1a-4307-a0ce-96b6639c217e@o3g2000yqb.googlegroups.com> <1cd32cbb1002220845o3ad94ba8g599f25ec170c6106@mail.gmail.com> <1cd32cbb1002220927h229e578bhe18737d803fddc76@mail.gmail.com> <1c841a64-786d-4069-9f88-fcaae5a0d063@t42g2000vbt.googlegroups.com> <3d375d731002230946m75c7cacbk4a45e8e3db518d54@mail.gmail.com> <1cd32cbb1002230957w35b7119ay7270bbbc1892ce25@mail.gmail.com> <1cd32cbb1002230959u46a4da49ie6e7220d5964a381@mail.gmail.com> <3d375d731003031315p7bc93005ibd7fed09c2ccbd41@mail.gmail.com> Message-ID: <1cd32cbb1003031331m7d8142eje2e352a00f1bdfb1@mail.gmail.com> On Wed, Mar 3, 2010 at 4:15 PM, Robert Kern wrote: > On Tue, Feb 23, 2010 at 11:59, ? wrote: >> On Tue, Feb 23, 2010 at 12:57 PM, ? wrote: >>> On Tue, Feb 23, 2010 at 12:46 PM, Robert Kern wrote: >>>> On Tue, Feb 23, 2010 at 11:43, denis wrote: >>>>> Robert, Josef, >>>>> ?thanks much for taking the time to look at RBF some more. >>>>> Summary, correct me: >>>>> ? ?A - smooth*I in rbf.py is a sign error (ticket ?) >>>> >>>> Not necessarily. It seems to work well in at least some cases. Find a >>>> reference that says otherwise if you want it changed. >>> >>> chapter 2 page 16, for gaussian process. As I said I don't know about >>> the other methods >>> >> >> http://docs.google.com/viewer?a=v&q=cache:qs8AaAxO6nkJ:www.gaussianprocess.org/gpml/chapters/RW2.pdf+gaussian+process+noise+Ridge&hl=en&gl=ca&pid=bl&srcid=ADGEESj4j8osT6cOIc65r3OaeAtQO_dzgZD4YxSAEkFTeRZajBcROJpJJ9zTlMSrD2OaK1iOJYgy8QqH_Nr0rNxf41faNihCdIzWyVOYxtCFIR7H8mdQZAKFoeaRkFamQlCKhp_s1FOI&sig=AHIEtbQK35MLfnZAySw3lF-dR_mNcSaP3w >> >> google links are very short, missed a part > > I've found a couple of things on RBFs specifically that agree. > However, the original source on which our implementation is based does > subtract. He may have a source that uses a negative sign. > > http://www.mathworks.co.uk/matlabcentral/fileexchange/10056-scattered-data-interpolation-and-approximation-using-radial-base-functions > > Playing around, it seems to me that some of the radial functions > create smoother approximations with large positive values (with the > current implementation) while others create smoother approximations > with large negative values. It's possible that it's just a convention > as to which sign you use. >From the examples I checked, it looks like all other than gaussian have large positive and negative eigenvalues, so adding or subtracting doesn't change whether the matrix is definite. For the gaussian case it is different, with smooth=0 the smallest eigenvalues are zero and all others are positive. Only by *adding* a penalization, the matrix becomes positive definite. (I've never seen a case where eigenvalues are made negative to be able to invert a matrix in the Ridge regression type of penalization.) So it might be a convention if the kernel is increasing in distance but not for the gaussian kernel that is decreasing. If it's a convention than we could flip the sign and make it correspond to the gaussian case, and the other cases would not be strongly affected. I will look at the reference. I haven't found much in terms of references directly for general rbf. Josef > > -- > Robert Kern > > "I have come to believe that the whole world is an enigma, a harmless > enigma that is made terrible by our own mad attempt to interpret it as > though it had an underlying truth." > ?-- Umberto Eco > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > From agile.aspect at gmail.com Wed Mar 3 17:13:49 2010 From: agile.aspect at gmail.com (Agile Aspect) Date: Wed, 3 Mar 2010 14:13:49 -0800 Subject: [SciPy-User] scikits.audiolab NameError In-Reply-To: References: Message-ID: On Wed, Mar 3, 2010 at 11:01 AM, Nils Wagner wrote: > On Wed, 3 Mar 2010 10:01:22 -0800 > ?Agile Aspect wrote: >> On Wed, Mar 3, 2010 at 9:06 AM, Nils Wagner >> wrote: >>> Hi all, >>> >>> I installed audiolab via >>> >>> git clone git://github.com/cournape/audiolab.git >>> python setup.py install --prefix=$HOME/local >>> >>> How can I fix the backend problem wrt. alsa ? >>> >>> >>> python -i test_sndfile.py >>> /data/home/nwagner/local/lib/python2.5/site-packages/scikits.audiolab-0.11.0.dev-py2.5-linux-x86_64.egg/scikits/audiolab/soundio/play.py:48: >>> UserWarning: Could not import alsa backend; most >>>probably, >>> you did not have alsa headers when building audiolab >>> ? warnings.warn("Could not import alsa backend; most >>> probably, " >>> Traceback (most recent call last): >>> ? File "test_sndfile.py", line 332, in >>> ? ? NumpyTest().run() >>> NameError: name 'NumpyTest' is not defined >>> >>> >>> AFAIK, NumpyTest is obsolete. Am I missing something ? >>> >>> Nils >>> _______________________________________________ >>> SciPy-User mailing list >>> SciPy-User at scipy.org >>> http://mail.scipy.org/mailman/listinfo/scipy-user >>> >> >> On CentOS/Fedora >> >> ? ? ? yum install alsa\* >> > > alsa is already installed... > > header file are available in /usr/include/alsa > the library libasound.a is in /usr/lib64 > > I haven't a clue what is going on here. If this is a runtime error then the ALSA backend was never built. Despite the fact that no sound system was found during the build, it still installs the files and creates the impression everything is honky dory. Rebuild it and direct the output to a file - the output will probably indicate the ALSA backend was never found. -- Enjoy global warming while it lasts. From timmichelsen at gmx-topmail.de Wed Mar 3 17:13:36 2010 From: timmichelsen at gmx-topmail.de (Tim Michelsen) Date: Wed, 03 Mar 2010 23:13:36 +0100 Subject: [SciPy-User] calculating intersection points in probability curves In-Reply-To: References: Message-ID: Hello, my mail seems to have been too theoretical. Below is some example code. How can I calculate the intersection point (coordinates) between 'distribution_curve' and 'limit_line'? Which functions could help me here? Thanks in advance for any help / pointers. Best regards, Timmie ##### EXAMPLE CODE ####### #!/usr/bin/env python import pylab as P import numpy as np # first create a single histogram # mu, sigma = 200, 25 x = mu + sigma*P.randn(10000) n, bins = np.histogram(x) # add a line showing the expected distribution y = P.normpdf( bins, mu, sigma).cumsum() y /= y[-1] # the curve for the plot shwoing the distribution distribution_curve = P.plot(bins, y, 'k--', linewidth=1.5) # the limit of which the intersection # point (x / y) with distribution_curve is desired limit_line = P.axvline(x.mean()) P.show() From robert.kern at gmail.com Wed Mar 3 17:41:37 2010 From: robert.kern at gmail.com (Robert Kern) Date: Wed, 3 Mar 2010 16:41:37 -0600 Subject: [SciPy-User] calculating intersection points in probability curves In-Reply-To: References: Message-ID: <3d375d731003031441t2cf09d99u97235f83f1106463@mail.gmail.com> On Wed, Mar 3, 2010 at 16:13, Tim Michelsen wrote: > Hello, > my mail seems to have been too theoretical. > > Below is some example code. > > How can I calculate the intersection point (coordinates) between > 'distribution_curve' and 'limit_line'? > > Which functions could help me here? For finding where a monotonically increasing sequence crosses a particular value, use np.searchsorted() with the Y coordinate array and the value. This gives you the index into the Y array. Use that index on the X values to find the X value where it crosses. Depending on how you are interpreting those points, you may want that value, or the next one, or some weighted average of the two. For two sequences that cross, again it depends a little on the sequences themselves and on how you interpret the sequences. Are they step functions, or would you draw line segments from point to point? Are they monotonic? Do they have the same X values? Do they have the same set of Y values? etc. You could cobble something together where you evaluate "h(x) = f(x) - g(x)" (where f(x) and g(x) use interp1d on the original datasets) on the set of X points that is the union of the two sequences of X points from the two datasets. Then search for zero crossings (there may be more than one). -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From marcotuckner at public-files.de Wed Mar 3 17:47:11 2010 From: marcotuckner at public-files.de (Marco Tuckner) Date: Wed, 03 Mar 2010 23:47:11 +0100 Subject: [SciPy-User] ValueError with ts.convert of scikits.timeseries Message-ID: Hello, I encountered an error working with a recarray read from a ASCII file with ts.tsfromtxt [1]. The steps were conducted: 1) read in with ts.tsfromtxt ==> recarray with data with minutely frequency 2) missing dates were filed with ts.fill_missing_dates ==> complete series 3) convert into hourly frequency with ts.convert 4) an error occurs, see below. What could be the cause for this? My recarray have the following dtypes: dtype = [('f2', ' run dataeval.py ------------------------------------------------------------------------ --- ValueError Traceback (most recent call last) C:\scripts\eval\dataeval.py in () 42 myseries_filled_min = ts.fill_missing_dates(series) 43 ---> 44 myseries_hourly_mean = ts.convert(myseries_filled_min,'H',func=np.mean) C:\Python26\lib\site-packages\scikits\timeseries\tseries.pyc in convert(series, freq, func, position, *args, **kwargs) 2003 2004 if series.ndim == 1: -> 2005 obj = _convert1d(series, freq, func, position, *args, **kwargs) 2006 elif series.ndim == 2: 2007 base = _convert1d(series[:,0], freq, func, position, *args, **kwargs) C:\Python26\lib\site-packages\scikits\timeseries\tseries.pyc in _convert1d(series, freq, func, position, *args, **kwargs) 1913 1914 cdictresult = cseries.TS_convert(data_, from_freq, to_freq, position, -> 1915 int(start_date), mask_) 1916 start_date = Date(freq=to_freq, value=cdictresult['startindex']) 1917 data_ = masked_array(cdictresult['values'], mask=cdictresult['mask']) ValueError: data type must provide an itemsize WARNING: Failure executing file: ##### [1]: http://pytseries.sourceforge.net/core.timeseries.io.html From pitam at deepspace.ucsb.edu Wed Mar 3 20:17:40 2010 From: pitam at deepspace.ucsb.edu (pitam) Date: Wed, 03 Mar 2010 17:17:40 -0800 Subject: [SciPy-User] segfaults with weave.inline Message-ID: <1267665460.31585.3.camel@zephyr.deepspace.ucsb.edu> Hi Pauli, Thanks, that resolved the issue. I also want to contribute to make a good documentation for weave. Hence, I will submit my code and explanations with the difficulties I had to the present wiki. However, the wiki right now lacks a section for arrays in weave.inline. Shall we create one? Pitam From pgmdevlist at gmail.com Wed Mar 3 20:23:47 2010 From: pgmdevlist at gmail.com (Pierre GM) Date: Wed, 3 Mar 2010 20:23:47 -0500 Subject: [SciPy-User] ValueError with ts.convert of scikits.timeseries In-Reply-To: References: Message-ID: <67573205-1CFA-4A09-884D-B3DABF3ABE8A@gmail.com> On Mar 3, 2010, at 5:47 PM, Marco Tuckner wrote: > Hello, > I encountered an error working with a recarray read from a ASCII file > with ts.tsfromtxt [1]. > > The steps were conducted: > > 1) read in with ts.tsfromtxt ==> recarray with data with minutely frequency > 2) missing dates were filed with ts.fill_missing_dates ==> complete series > 3) convert into hourly frequency with ts.convert > 4) an error occurs, see below. > > What could be the cause for this? The fact that you're using a structured array (that is, an array with named fields. a recarray is a special kind of structured array). The conversion functions don't work in that case, you have to convert field by field. In your case, I'd do something like this: * convert the first field to hours using .convert and save the reslut in a temporary array * create an empty timeseries with the same dtype as your input and the same dates as the temporary array you just created. * Loop on the fields of the input, convert them to hours and store them in the corresponding field of your new array > > My recarray have the following dtypes: > > dtype = [('f2', ' ('f6', ' ' > Another question related to this: > How do I convert the recarrays returned by ts.tsfromtxt into a ndarray? Use .view(np.ndarray). Note that on top of dropping the dates, you also lose the mask. If you need the mask, use the .series attribute. From arokem at berkeley.edu Wed Mar 3 21:20:32 2010 From: arokem at berkeley.edu (Ariel Rokem) Date: Wed, 3 Mar 2010 18:20:32 -0800 Subject: [SciPy-User] Signal to noise ratio In-Reply-To: <4B854AF8.3060503@enthought.com> References: <4B854AF8.3060503@enthought.com> Message-ID: <43958ee61003031820y2c63d1dew56d39bb3f9249fd4@mail.gmail.com> Hi Warren, thanks for this example! I am getting the following error: Library/Frameworks/Python.framework/Versions/6.0.0/lib/python2.6/site-packages/scipy/signal/filter_design.py:224: BadCoefficients: Badly conditionned filter coefficients (numerator): the results may be meaningless "results may be meaningless", BadCoefficients) For any attempt to filter a low-pass below 12 Hz in this example (so - I don't get the plot you got - instead I get a flat line on the bottom subplot). Do you (or anyone?) have any idea why that is? Cheers, Ariel On Wed, Feb 24, 2010 at 7:51 AM, Warren Weckesser < warren.weckesser at enthought.com> wrote: > Nils Wagner wrote: > > Hi all, > > > > I have two questions concerning signal processing > > > > I have used scipy.stats.signaltonoise to compute the > > signal-to-noise ratio. > > The value is 0.0447. > > How can I judge it ? > > > > How can I filter out high frequencies using scipy ? > > > > I posted an example low-pass filtering using 'butter' and 'lfilter' from > scipy.signal here: > > http://mail.scipy.org/pipermail/scipy-user/2010-January/024032.html > > Warren > > > How can I eliminate noise from the signal ? > > > > Nils > > _______________________________________________ > > SciPy-User mailing list > > SciPy-User at scipy.org > > http://mail.scipy.org/mailman/listinfo/scipy-user > > > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > -- Ariel Rokem Helen Wills Neuroscience Institute University of California, Berkeley http://argentum.ucbso.berkeley.edu/ariel -------------- next part -------------- An HTML attachment was scrubbed... URL: From ivo.maljevic at gmail.com Wed Mar 3 22:17:46 2010 From: ivo.maljevic at gmail.com (Ivo Maljevic) Date: Wed, 3 Mar 2010 22:17:46 -0500 Subject: [SciPy-User] Signal to noise ratio In-Reply-To: <43958ee61003031820y2c63d1dew56d39bb3f9249fd4@mail.gmail.com> References: <4B854AF8.3060503@enthought.com> <43958ee61003031820y2c63d1dew56d39bb3f9249fd4@mail.gmail.com> Message-ID: <826c64da1003031917j57ae8111j3b2303099087325c@mail.gmail.com> I just tried Warren's example and it works on Ubuntu. Ivo On 3 March 2010 21:20, Ariel Rokem wrote: > Hi Warren, > > thanks for this example! > > I am getting the following error: > > Library/Frameworks/Python.framework/Versions/6.0.0/lib/python2.6/site-packages/scipy/signal/filter_design.py:224: > BadCoefficients: Badly conditionned filter coefficients (numerator): the > results may be meaningless > "results may be meaningless", BadCoefficients) > > For any attempt to filter a low-pass below 12 Hz in this example (so - I > don't get the plot you got - instead I get a flat line on the bottom > subplot). Do you (or anyone?) have any idea why that is? > > Cheers, > > Ariel > > On Wed, Feb 24, 2010 at 7:51 AM, Warren Weckesser < > warren.weckesser at enthought.com> wrote: > >> Nils Wagner wrote: >> > Hi all, >> > >> > I have two questions concerning signal processing >> > >> > I have used scipy.stats.signaltonoise to compute the >> > signal-to-noise ratio. >> > The value is 0.0447. >> > How can I judge it ? >> > >> > How can I filter out high frequencies using scipy ? >> > >> >> I posted an example low-pass filtering using 'butter' and 'lfilter' from >> scipy.signal here: >> >> http://mail.scipy.org/pipermail/scipy-user/2010-January/024032.html >> >> Warren >> >> > How can I eliminate noise from the signal ? >> > >> > Nils >> > _______________________________________________ >> > SciPy-User mailing list >> > SciPy-User at scipy.org >> > http://mail.scipy.org/mailman/listinfo/scipy-user >> > >> >> _______________________________________________ >> SciPy-User mailing list >> SciPy-User at scipy.org >> http://mail.scipy.org/mailman/listinfo/scipy-user >> > > > > -- > Ariel Rokem > Helen Wills Neuroscience Institute > University of California, Berkeley > http://argentum.ucbso.berkeley.edu/ariel > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From D.J.Baker at soton.ac.uk Thu Mar 4 06:17:54 2010 From: D.J.Baker at soton.ac.uk (Baker D.J.) Date: Thu, 4 Mar 2010 11:17:54 +0000 Subject: [SciPy-User] Scipy failing -- undefined symbol: _ZNSt8ios_base4InitD1Ev Message-ID: Hello, I've just installed scipy on our Linux x86_64 machine using the Intel compilers and MKL. All is not well, however, since when I try to use scipy, for example... from scipy import linsolve, sparse I find that there is an unresolved symbol. That is, _ZNSt8ios_base4InitD1Ev. Using c++filt would appear to suggest that I need to add "-lstdc++" to my loader command. c++filt _ZNSt8ios_base4InitD1Ev std::ios_base::Init::~Init() I'm new to numpy and scipy, and so I'm working in the dark to some degree. I've tried modifying intelccompiler.py in the following way, and recompiling numpy and scipy (the idea being that some of the programs in the scipy build are cxx files) compiler_type = 'intel' cc_exe = 'icc -O3 -fPIC' cxx_exe = 'icpc -O3 -fPIC' def __init__ (self, verbose=0, dry_run=0, force=0): UnixCCompiler.__init__ (self, verbose,dry_run, force) compiler = self.cc_exe compiler_cxx = self.cxx_exe self.set_executables(compiler=compiler, compiler_so=compiler, compiler_cxx=compiler_cxx, linker_exe=compiler, linker_so=compiler_cxx + ' -shared -lstdc++') I rebuild scipy using the following command, however the above hasn't helped: python setup.py config --compiler=intel config_fc --fcompiler=intelem install --prefix=/local/software/rh53/scipy/0.7.1/intel Could someone please advise me how to ensure that the "-lstdc++" is successfully passed to the linker as and when I build scipy. This would really be appreciated. Best -- David. From warren.weckesser at enthought.com Thu Mar 4 12:24:19 2010 From: warren.weckesser at enthought.com (Warren Weckesser) Date: Thu, 04 Mar 2010 11:24:19 -0600 Subject: [SciPy-User] Signal to noise ratio In-Reply-To: <43958ee61003031820y2c63d1dew56d39bb3f9249fd4@mail.gmail.com> References: <4B854AF8.3060503@enthought.com> <43958ee61003031820y2c63d1dew56d39bb3f9249fd4@mail.gmail.com> Message-ID: <4B8FECC3.8030607@enthought.com> Ariel Rokem wrote: > Hi Warren, > > thanks for this example! > > I am getting the following error: > > Library/Frameworks/Python.framework/Versions/6.0.0/lib/python2.6/site-packages/scipy/signal/filter_design.py:224: > BadCoefficients: Badly conditionned filter coefficients (numerator): > the results may be meaningless > "results may be meaningless", BadCoefficients) > > For any attempt to filter a low-pass below 12 Hz in this example (so - > I don't get the plot you got - instead I get a flat line on the bottom > subplot). Do you (or anyone?) have any idea why that is? > Nils Wagner reported the same behavior a week or so ago, and I see the same behavior now ("BadCoefficients" and a flat line in the last plot). Try lowering the order of the Butterworth filter to order=6. Warren > Cheers, > > Ariel > > On Wed, Feb 24, 2010 at 7:51 AM, Warren Weckesser > > wrote: > > Nils Wagner wrote: > > Hi all, > > > > I have two questions concerning signal processing > > > > I have used scipy.stats.signaltonoise to compute the > > signal-to-noise ratio. > > The value is 0.0447. > > How can I judge it ? > > > > How can I filter out high frequencies using scipy ? > > > > I posted an example low-pass filtering using 'butter' and > 'lfilter' from > scipy.signal here: > > http://mail.scipy.org/pipermail/scipy-user/2010-January/024032.html > > Warren > > > How can I eliminate noise from the signal ? > > > > Nils > > _______________________________________________ > > SciPy-User mailing list > > SciPy-User at scipy.org > > http://mail.scipy.org/mailman/listinfo/scipy-user > > > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > > > > > -- > Ariel Rokem > Helen Wills Neuroscience Institute > University of California, Berkeley > http://argentum.ucbso.berkeley.edu/ariel > ------------------------------------------------------------------------ > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > From ivo.maljevic at gmail.com Thu Mar 4 12:48:50 2010 From: ivo.maljevic at gmail.com (Ivo Maljevic) Date: Thu, 4 Mar 2010 12:48:50 -0500 Subject: [SciPy-User] Signal to noise ratio In-Reply-To: <4B8FECC3.8030607@enthought.com> References: <4B854AF8.3060503@enthought.com> <43958ee61003031820y2c63d1dew56d39bb3f9249fd4@mail.gmail.com> <4B8FECC3.8030607@enthought.com> Message-ID: <826c64da1003040948x45e36a6l682157ca206ad61a@mail.gmail.com> If your signal is sampled at 200 Hz (like in this example), and you want to filter out everything above 4 Hz or 12 Hz, you might want to consider using a wider LPF first, downsapling the signal, and then doing the filtering. Usually, sampling rate is related to the frequency content of the signal (Nyquist), and since your signal of interest is much narrower, you have very high oversampling (maybe due to very wide noise?). In any case, even Matlab wouldn't help you much if you wanted to implement such a narrow LPF: Python: >>> b, a = butter(14, ws3, 'low') C:\Python26\lib\site-packages\scipy\signal\filter_design.py:221: BadCoefficients: Badly conditionned filter coefficients (numerator): the results may be meaningless "results may be meaningless", BadCoefficients) C:\Python26\lib\site-packages\scipy\signal\filter_design.py:221: BadCoefficients: Badly conditionned filter coefficients (numerator): the results may be meaningless "results may be meaningless", BadCoefficients) >>> ws3 0.040000000000000001 >>> b array([ 1.21542041e-16, 7.90023266e-16, 3.16009306e-15, 8.69025592e-15, 1.73805118e-14, 2.60707678e-14, 2.97951632e-14, 2.60707678e-14, 1.73805118e-14, 8.69025592e-15, 3.16009306e-15, 7.90023266e-16, 1.21542041e-16, 8.68157435e-18]) >>> a array([ 1.00000000e+00, -1.28776717e+01, 7.70365408e+01, -2.83749831e+02, 7.18912579e+02, -1.32537586e+03, 1.83351674e+03, -1.93352359e+03, 1.56186993e+03, -9.61728148e+02, 4.44354147e+02, -1.49385526e+02, 3.45431991e+01, -4.91770336e+00, 3.25194854e-01]) Matlab: >> [b,a]=butter(14, 0.04, 'low') b = Columns 1 through 12 0 0 0 0 0 0 0 0 0 0 0 0 Columns 13 through 15 0 0 0 a = 1.0e+003 * Columns 1 through 7 0.0010 -0.0129 0.0770 -0.2837 0.7189 -1.3254 1.8335 Columns 8 through 14 -1.9335 1.5619 -0.9617 0.4444 -0.1494 0.0345 -0.0049 Column 15 0.0003 On 4 March 2010 12:24, Warren Weckesser wrote: > Ariel Rokem wrote: > > Hi Warren, > > > > thanks for this example! > > > > I am getting the following error: > > > > > Library/Frameworks/Python.framework/Versions/6.0.0/lib/python2.6/site-packages/scipy/signal/filter_design.py:224: > > BadCoefficients: Badly conditionned filter coefficients (numerator): > > the results may be meaningless > > "results may be meaningless", BadCoefficients) > > > > For any attempt to filter a low-pass below 12 Hz in this example (so - > > I don't get the plot you got - instead I get a flat line on the bottom > > subplot). Do you (or anyone?) have any idea why that is? > > > > Nils Wagner reported the same behavior a week or so ago, and I see the > same behavior now ("BadCoefficients" and a flat line in the last plot). > Try lowering the order of the Butterworth filter to order=6. > > Warren > > > > Cheers, > > > > Ariel > > > > On Wed, Feb 24, 2010 at 7:51 AM, Warren Weckesser > > > > wrote: > > > > Nils Wagner wrote: > > > Hi all, > > > > > > I have two questions concerning signal processing > > > > > > I have used scipy.stats.signaltonoise to compute the > > > signal-to-noise ratio. > > > The value is 0.0447. > > > How can I judge it ? > > > > > > How can I filter out high frequencies using scipy ? > > > > > > > I posted an example low-pass filtering using 'butter' and > > 'lfilter' from > > scipy.signal here: > > > > > http://mail.scipy.org/pipermail/scipy-user/2010-January/024032.html > > > > Warren > > > > > How can I eliminate noise from the signal ? > > > > > > Nils > > > _______________________________________________ > > > SciPy-User mailing list > > > SciPy-User at scipy.org > > > http://mail.scipy.org/mailman/listinfo/scipy-user > > > > > > > _______________________________________________ > > SciPy-User mailing list > > SciPy-User at scipy.org > > http://mail.scipy.org/mailman/listinfo/scipy-user > > > > > > > > > > -- > > Ariel Rokem > > Helen Wills Neuroscience Institute > > University of California, Berkeley > > http://argentum.ucbso.berkeley.edu/ariel > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > SciPy-User mailing list > > SciPy-User at scipy.org > > http://mail.scipy.org/mailman/listinfo/scipy-user > > > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > -------------- next part -------------- An HTML attachment was scrubbed... URL: From arokem at berkeley.edu Thu Mar 4 13:47:33 2010 From: arokem at berkeley.edu (Ariel Rokem) Date: Thu, 4 Mar 2010 10:47:33 -0800 Subject: [SciPy-User] Signal to noise ratio In-Reply-To: <4B8FECC3.8030607@enthought.com> References: <4B854AF8.3060503@enthought.com> <43958ee61003031820y2c63d1dew56d39bb3f9249fd4@mail.gmail.com> <4B8FECC3.8030607@enthought.com> Message-ID: <43958ee61003041047s2b4d27cahaed871674e8d4aab@mail.gmail.com> Interesting. It does work with lower filter order. In fact, there is a range of values of filter order for which I get the warning, but also some result. This results looks slightly flatter than the result with filter order set to 6, but is not completely flat. What does the filter order do, intuitively? Thanks - Ariel On Thu, Mar 4, 2010 at 9:24 AM, Warren Weckesser < warren.weckesser at enthought.com> wrote: > Ariel Rokem wrote: > > Hi Warren, > > > > thanks for this example! > > > > I am getting the following error: > > > > > Library/Frameworks/Python.framework/Versions/6.0.0/lib/python2.6/site-packages/scipy/signal/filter_design.py:224: > > BadCoefficients: Badly conditionned filter coefficients (numerator): > > the results may be meaningless > > "results may be meaningless", BadCoefficients) > > > > For any attempt to filter a low-pass below 12 Hz in this example (so - > > I don't get the plot you got - instead I get a flat line on the bottom > > subplot). Do you (or anyone?) have any idea why that is? > > > > Nils Wagner reported the same behavior a week or so ago, and I see the > same behavior now ("BadCoefficients" and a flat line in the last plot). > Try lowering the order of the Butterworth filter to order=6. > > Warren > > > > Cheers, > > > > Ariel > > > > On Wed, Feb 24, 2010 at 7:51 AM, Warren Weckesser > > > > wrote: > > > > Nils Wagner wrote: > > > Hi all, > > > > > > I have two questions concerning signal processing > > > > > > I have used scipy.stats.signaltonoise to compute the > > > signal-to-noise ratio. > > > The value is 0.0447. > > > How can I judge it ? > > > > > > How can I filter out high frequencies using scipy ? > > > > > > > I posted an example low-pass filtering using 'butter' and > > 'lfilter' from > > scipy.signal here: > > > > > http://mail.scipy.org/pipermail/scipy-user/2010-January/024032.html > > > > Warren > > > > > How can I eliminate noise from the signal ? > > > > > > Nils > > > _______________________________________________ > > > SciPy-User mailing list > > > SciPy-User at scipy.org > > > http://mail.scipy.org/mailman/listinfo/scipy-user > > > > > > > _______________________________________________ > > SciPy-User mailing list > > SciPy-User at scipy.org > > http://mail.scipy.org/mailman/listinfo/scipy-user > > > > > > > > > > -- > > Ariel Rokem > > Helen Wills Neuroscience Institute > > University of California, Berkeley > > http://argentum.ucbso.berkeley.edu/ariel > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > SciPy-User mailing list > > SciPy-User at scipy.org > > http://mail.scipy.org/mailman/listinfo/scipy-user > > > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > -- Ariel Rokem Helen Wills Neuroscience Institute University of California, Berkeley http://argentum.ucbso.berkeley.edu/ariel -------------- next part -------------- An HTML attachment was scrubbed... URL: From ivo.maljevic at gmail.com Thu Mar 4 14:20:20 2010 From: ivo.maljevic at gmail.com (Ivo Maljevic) Date: Thu, 4 Mar 2010 14:20:20 -0500 Subject: [SciPy-User] Signal to noise ratio In-Reply-To: <43958ee61003041047s2b4d27cahaed871674e8d4aab@mail.gmail.com> References: <4B854AF8.3060503@enthought.com> <43958ee61003031820y2c63d1dew56d39bb3f9249fd4@mail.gmail.com> <4B8FECC3.8030607@enthought.com> <43958ee61003041047s2b4d27cahaed871674e8d4aab@mail.gmail.com> Message-ID: <826c64da1003041120i7813e2afrc6ea11148aaa83f@mail.gmail.com> Arieal, I just did a quick search and found the same thing I told you on Matlab site (i.e., narrowband filter): http://www.mathworks.com/access/helpdesk/help/toolbox/signal/f4-1046.html While it may be interesting to play with cuttoff frequencies and filter order, it is quite useless from a practical point of view. To use a tool, you need to understand what it does and what are its limitations. What you are trying to do with the filter is almost the same as if you are trying to find the mean value of the signal (hence the almost flat line). You definitely do not need butterworth filter for that, just find the mean value of the signal for such type of operation. As for your order question, it basically determines how many past samples are you using in the filtering operation. Maybe you can read this: http://en.wikipedia.org/wiki/Digital_filter#Difference_equation Cheers, Ivo On 4 March 2010 13:47, Ariel Rokem wrote: > Interesting. It does work with lower filter order. In fact, there is a > range of values of filter order for which I get the warning, but also some > result. This results looks slightly flatter than the result with filter > order set to 6, but is not completely flat. What does the filter order do, > intuitively? > > Thanks - Ariel > > On Thu, Mar 4, 2010 at 9:24 AM, Warren Weckesser < > warren.weckesser at enthought.com> wrote: > >> Ariel Rokem wrote: >> > Hi Warren, >> > >> > thanks for this example! >> > >> > I am getting the following error: >> > >> > >> Library/Frameworks/Python.framework/Versions/6.0.0/lib/python2.6/site-packages/scipy/signal/filter_design.py:224: >> > BadCoefficients: Badly conditionned filter coefficients (numerator): >> > the results may be meaningless >> > "results may be meaningless", BadCoefficients) >> > >> > For any attempt to filter a low-pass below 12 Hz in this example (so - >> > I don't get the plot you got - instead I get a flat line on the bottom >> > subplot). Do you (or anyone?) have any idea why that is? >> > >> >> Nils Wagner reported the same behavior a week or so ago, and I see the >> same behavior now ("BadCoefficients" and a flat line in the last plot). >> Try lowering the order of the Butterworth filter to order=6. >> >> Warren >> >> >> > Cheers, >> > >> > Ariel >> > >> > On Wed, Feb 24, 2010 at 7:51 AM, Warren Weckesser >> > > > > wrote: >> > >> > Nils Wagner wrote: >> > > Hi all, >> > > >> > > I have two questions concerning signal processing >> > > >> > > I have used scipy.stats.signaltonoise to compute the >> > > signal-to-noise ratio. >> > > The value is 0.0447. >> > > How can I judge it ? >> > > >> > > How can I filter out high frequencies using scipy ? >> > > >> > >> > I posted an example low-pass filtering using 'butter' and >> > 'lfilter' from >> > scipy.signal here: >> > >> > >> http://mail.scipy.org/pipermail/scipy-user/2010-January/024032.html >> > >> > Warren >> > >> > > How can I eliminate noise from the signal ? >> > > >> > > Nils >> > > _______________________________________________ >> > > SciPy-User mailing list >> > > SciPy-User at scipy.org >> > > http://mail.scipy.org/mailman/listinfo/scipy-user >> > > >> > >> > _______________________________________________ >> > SciPy-User mailing list >> > SciPy-User at scipy.org >> > http://mail.scipy.org/mailman/listinfo/scipy-user >> > >> > >> > >> > >> > -- >> > Ariel Rokem >> > Helen Wills Neuroscience Institute >> > University of California, Berkeley >> > http://argentum.ucbso.berkeley.edu/ariel >> > ------------------------------------------------------------------------ >> > >> > _______________________________________________ >> > SciPy-User mailing list >> > SciPy-User at scipy.org >> > http://mail.scipy.org/mailman/listinfo/scipy-user >> > >> >> _______________________________________________ >> SciPy-User mailing list >> SciPy-User at scipy.org >> http://mail.scipy.org/mailman/listinfo/scipy-user >> > > > > -- > Ariel Rokem > Helen Wills Neuroscience Institute > University of California, Berkeley > http://argentum.ucbso.berkeley.edu/ariel > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From nwagner at iam.uni-stuttgart.de Thu Mar 4 14:29:10 2010 From: nwagner at iam.uni-stuttgart.de (Nils Wagner) Date: Thu, 04 Mar 2010 20:29:10 +0100 Subject: [SciPy-User] scikits.audiolab NameError In-Reply-To: References: Message-ID: On Wed, 3 Mar 2010 14:13:49 -0800 Agile Aspect wrote: > On Wed, Mar 3, 2010 at 11:01 AM, Nils Wagner > wrote: >> On Wed, 3 Mar 2010 10:01:22 -0800 >> ?Agile Aspect wrote: >>> On Wed, Mar 3, 2010 at 9:06 AM, Nils Wagner >>> wrote: >>>> Hi all, >>>> >>>> I installed audiolab via >>>> >>>> git clone git://github.com/cournape/audiolab.git >>>> python setup.py install --prefix=$HOME/local >>>> >>>> How can I fix the backend problem wrt. alsa ? >>>> >>>> >>>> python -i test_sndfile.py >>>> /data/home/nwagner/local/lib/python2.5/site-packages/scikits.audiolab-0.11.0.dev-py2.5-linux-x86_64.egg/scikits/audiolab/soundio/play.py:48: >>>> UserWarning: Could not import alsa backend; most >>>>probably, >>>> you did not have alsa headers when building audiolab >>>> ? warnings.warn("Could not import alsa backend; most >>>> probably, " >>>> Traceback (most recent call last): >>>> ? File "test_sndfile.py", line 332, in >>>> ? ? NumpyTest().run() >>>> NameError: name 'NumpyTest' is not defined >>>> >>>> >>>> AFAIK, NumpyTest is obsolete. Am I missing something ? >>>> >>>> Nils >>>> _______________________________________________ >>>> SciPy-User mailing list >>>> SciPy-User at scipy.org >>>> http://mail.scipy.org/mailman/listinfo/scipy-user >>>> >>> >>> On CentOS/Fedora >>> >>> ? ? ? yum install alsa\* >>> >> >> alsa is already installed... >> >> header file are available in /usr/include/alsa >> the library libasound.a is in /usr/lib64 >> >> I haven't a clue what is going on here. > > If this is a runtime error then the ALSA backend was >never built. > > Despite the fact that no sound system was found during >the build, it > still installs the files and creates the impression >everything is > honky dory. > > Rebuild it and direct the output to a file - the output >will probably > indicate the ALSA backend was never found. > > -- > Enjoy global warming while it lasts. > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user Hi all, I just managed the installation of audiolab on opensuse11.2 I have installed libsndfile from source. It doesn't work with the rpm's provided by opensuse. Furthermore I have used the following site.cfg [sndfile] library_dirs = /home/nwagner/local/lib include_dirs = /home/nwagner/local/include sndfile_libs = sndfile [alsa] library_dirs = /usr/lib64 include_dirs = /usr/include The [alsa] section is necessary to detect libasound.a Now it works for me. Cheers Nils From craig.howard at earthlink.net Thu Mar 4 16:17:34 2010 From: craig.howard at earthlink.net (Craig) Date: Thu, 4 Mar 2010 13:17:34 -0800 (PST) Subject: [SciPy-User] Using Pyinstaller or cx_freeze with scipy Message-ID: Hello: I was attempting to use cx_freeze to create a stand-alone application that uses scipy, but ran into a problem. When I attempt to run the frozen application, I get the error: scipy\interpolate\polyint.py Cannot import name factorial I looked at the scipy package and the factorial function is in scipy.misc.common.py but the file scipy.interpolate.polyint.py has the line: from scipy import factorial So the polyint script is looking for the factorial function in some other place than its actual physical location. I guess scipy somehow inserts the factorial function in the correct namespace so that it runs correctly. Is there a way to get scipy and cx_freeze to get along? Thanks for your help in advance. Regards, Craig Howard From kwmsmith at gmail.com Thu Mar 4 16:47:03 2010 From: kwmsmith at gmail.com (Kurt Smith) Date: Thu, 4 Mar 2010 15:47:03 -0600 Subject: [SciPy-User] interpolate.bispl{rep, ev} need some love, or I'm using them incorrectly... Message-ID: I've been trying to get interpolation working on a not-too-large array (512 X 512) using interpolate.interp2d, which is a nice wrapper for interpolate.bispl{rep,ev}. Apparently these routines are meant to work on smallish arrays (~ 50 X 50) and give me a segfault when I hand them anything about (200 X 200) or so. When they do work, they're prohibitively slow. My question is: what is the usecase for these bivariate spline routines? I've discovered ndimage.spline_filter and ndimage.map_coordinates -- these fit my purposes much better; fast and nice interface. What is the difference between the two approaches? Kurt From josef.pktd at gmail.com Thu Mar 4 17:10:53 2010 From: josef.pktd at gmail.com (josef.pktd at gmail.com) Date: Thu, 4 Mar 2010 17:10:53 -0500 Subject: [SciPy-User] interpolate.bispl{rep, ev} need some love, or I'm using them incorrectly... In-Reply-To: References: Message-ID: <1cd32cbb1003041410y55f8dca3p7522eb9fddfae4cc@mail.gmail.com> On Thu, Mar 4, 2010 at 4:47 PM, Kurt Smith wrote: > I've been trying to get interpolation working on a not-too-large array > (512 X 512) using interpolate.interp2d, which is a nice wrapper for > interpolate.bispl{rep,ev}. ?Apparently these routines are meant to > work on smallish arrays (~ 50 X 50) and give me a segfault when I hand > them anything about (200 X 200) or so. ?When they do work, they're > prohibitively slow. > > My question is: ?what is the usecase for these bivariate spline > routines? ?I've discovered ndimage.spline_filter and > ndimage.map_coordinates -- these fit my purposes much better; fast and > nice interface. ?What is the difference between the two approaches? >From the docs, I think, bispl is a true 2dim spline, while ndimage.spline_filter is a sequence of 1d filter applied along each axis. For function approximation 200*200=40000 is a large number of points For z = f(x,y) I wouldn't usually get as many observations as in an image, and the number of knot points might be required to be smallish. I don't know anything about the c or fortran internals of either of them. Josef > > Kurt > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > From massimodisasha at yahoo.it Thu Mar 4 17:18:00 2010 From: massimodisasha at yahoo.it (Massimo Di Stefano) Date: Thu, 4 Mar 2010 23:18:00 +0100 Subject: [SciPy-User] helmert implementation (7 parameters - geometric transformation) In-Reply-To: References: Message-ID: Hi Charles, apologize me, i had only now a chance to answer your mail. i'm really gratefull for your help, now the code works perfectly and i'm really really happy for this ! i tried it with some points and all works fine :-) reading it i also learned some functions like : np.newaxis linalg.lstsq you gived me an awesome help, thanks!!! i've a question about the code, what does : # res = rhs - np.dot(A, sol) # in the code i added the equation to apply the transformation to an input file with coordinates to be converted : XYZ = np.loadtxt(str(inputf)) XYZsize = XYZ.shape[0] ENZglob = np.zeros((XYZsize,3),float) for i in np.arange(XYZsize): X = sol[0] + (1 + sol[6]) * ( XYZ[i,0] - sol[5] * XYZ[i,1] + sol[4] * XYZ[i,2] ) Y = sol[1] + (1 + sol[6]) * ( sol[5] * XYZ[i,0] + XYZ[i,1] - sol[3] * XYZ[i,2] ) Z = sol[2] + (1 + sol[6]) * ( -sol[4] * XYZ[i,0] + sol[3] * XYZ[i,1] + XYZ[i,2] ) ENZglob[i,:] = np.hstack((X,Y,Z)) np.savetxt(output,ENZglob) thanks again!!! regards, Massimo. Il giorno 03/mar/2010, alle ore 02.02, scipy-user-request at scipy.org ha scritto: > I've attached a script for the computation. Two things of note: the angles > in the pdf results are in degrees, the value of ? is pretty much in the > noise (the condition number of the matrix is 10^10), and the fit you get > with my version differs from the data by about 7mm. Note that the Helmert > parameters result from a linearization of the rotation matrix, see > Gauss-Newton for more about linearization and least squares, but in this > case I think the limiting factor is the accuracy of the coordinates, not the > linearization. From kwmsmith at gmail.com Thu Mar 4 17:30:11 2010 From: kwmsmith at gmail.com (Kurt Smith) Date: Thu, 4 Mar 2010 16:30:11 -0600 Subject: [SciPy-User] interpolate.bispl{rep, ev} need some love, or I'm using them incorrectly... In-Reply-To: <1cd32cbb1003041410y55f8dca3p7522eb9fddfae4cc@mail.gmail.com> References: <1cd32cbb1003041410y55f8dca3p7522eb9fddfae4cc@mail.gmail.com> Message-ID: On Thu, Mar 4, 2010 at 4:10 PM, wrote: > On Thu, Mar 4, 2010 at 4:47 PM, Kurt Smith wrote: >> I've been trying to get interpolation working on a not-too-large array >> (512 X 512) using interpolate.interp2d, which is a nice wrapper for >> interpolate.bispl{rep,ev}. ?Apparently these routines are meant to >> work on smallish arrays (~ 50 X 50) and give me a segfault when I hand >> them anything about (200 X 200) or so. ?When they do work, they're >> prohibitively slow. >> >> My question is: ?what is the usecase for these bivariate spline >> routines? ?I've discovered ndimage.spline_filter and >> ndimage.map_coordinates -- these fit my purposes much better; fast and >> nice interface. ?What is the difference between the two approaches? > > >From the docs, I think, bispl is a true 2dim spline, while > ndimage.spline_filter is a sequence of 1d filter applied along each > axis. > > For function approximation ?200*200=40000 ?is a large number of points > For ?z = f(x,y) I wouldn't usually get as many observations as in an > image, and the number of knot points might be required to be smallish. > > I don't know anything about the c or fortran internals of either of them. Thanks. It looks like interpolate.bisplrep is suitable for irregularly spaced data, whereas ndimage.spline_filter & map_coordinates require gridded data (naturally, since they're used on image-like data). > > Josef > From robfalck at gmail.com Thu Mar 4 20:55:56 2010 From: robfalck at gmail.com (Rob Falck) Date: Thu, 4 Mar 2010 20:55:56 -0500 Subject: [SciPy-User] Lagrange Multipliers in optimize.slsqp In-Reply-To: References: <1cd32cbb1002260555k3b72a50bsc2e606c9f0e68265@mail.gmail.com> Message-ID: Any opinions on how this change should be implemented? I'd prefer to keep the code clean, and the solution below is simple, but I'd rather not break current implementations of SLSQP that people have employed, as inserting a new element into the output likely would. I'm leaning towards allowing both boolean or integer types for the full_output argument. 0 or 1 would work as True and False do now, and 2 would return the Lagrange multipliers as well as everything else. On Tue, Mar 2, 2010 at 2:14 PM, Guilherme P. de Freitas wrote: > Hi everyone, > >> Ah, this should be enough then to return the multipliers. ?See if >> it gives what you'd expect? ?Then you can file an enhancement ticket >> if you want the multipliers back. >> >> Index: slsqp.py >> =================================================================== >> --- slsqp.py ? ?(revision 6242) >> +++ slsqp.py ? ?(working copy) >> @@ -371,5 +371,6 @@ >> ? ? ? ? return [list(x), >> ? ? ? ? ? ? ? ? float(fx), >> ? ? ? ? ? ? ? ? int(majiter), >> - ? ? ? ? ? ? ? ?int(mode), >> + ? ? ? ? ? ? ? ?list(w[:m]), >> + ? ? ? ? ? ? ? ?int(mode), >> ? ? ? ? ? ? ? ? exit_modes[int(mode)] ] >> >> Skipper >> _______________________________________________ >> SciPy-User mailing list >> SciPy-User at scipy.org >> http://mail.scipy.org/mailman/listinfo/scipy-user >> > > Thanks! That seems to give the right multipliers back. I'll file the ticket. > > Best, > > Guilherme > > > -- > Guilherme P. de Freitas > http://www.gpfreitas.com > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > -- - Rob Falck From charlesr.harris at gmail.com Thu Mar 4 21:54:10 2010 From: charlesr.harris at gmail.com (Charles R Harris) Date: Thu, 4 Mar 2010 19:54:10 -0700 Subject: [SciPy-User] helmert implementation (7 parameters - geometric transformation) In-Reply-To: References: Message-ID: On Thu, Mar 4, 2010 at 3:18 PM, Massimo Di Stefano wrote: > Hi Charles, > > apologize me, i had only now a chance to answer your mail. > > i'm really gratefull for your help, > now the code works perfectly and i'm really really happy for this ! > > i tried it with some points and all works fine :-) > > reading it i also learned some functions like : > > np.newaxis > linalg.lstsq > > you gived me an awesome help, thanks!!! > > You're welcome ;) Note that it is easy to extend to more than three vectors. > i've a question about the code, > what does : > > # > res = rhs - np.dot(A, sol) > # > > It's the residuals, i.e., the error remaining after the fit. I find the residuals generally more informative than their squared norm that is returned by the lstsq function. > > in the code i added the equation to apply the transformation to an input > file with coordinates to be converted : > > XYZ = np.loadtxt(str(inputf)) > XYZsize = XYZ.shape[0] > ENZglob = np.zeros((XYZsize,3),float) > for i in np.arange(XYZsize): > X = sol[0] + (1 + sol[6]) * ( XYZ[i,0] - sol[5] * XYZ[i,1] + sol[4] * > XYZ[i,2] ) > Y = sol[1] + (1 + sol[6]) * ( sol[5] * XYZ[i,0] + XYZ[i,1] - sol[3] * > XYZ[i,2] ) > Z = sol[2] + (1 + sol[6]) * ( -sol[4] * XYZ[i,0] + sol[3] * XYZ[i,1] + > XYZ[i,2] ) > ENZglob[i,:] = np.hstack((X,Y,Z)) > np.savetxt(output,ENZglob) > > > > thanks again!!! > > regards, > > Massimo. > > Chuck -------------- next part -------------- An HTML attachment was scrubbed... URL: From steveredmond at sympatico.ca Fri Mar 5 08:31:26 2010 From: steveredmond at sympatico.ca (SteveRedmond) Date: Fri, 5 Mar 2010 05:31:26 -0800 (PST) Subject: [SciPy-User] [SciPy-user] Audiolab on Py2.6 Message-ID: <27788613.post@talk.nabble.com> ninjasmith wrote: > > >> I made some tests and I am almost sure the problem is with this file: >> "C:\Python26\Lib\site-packages\scikits\audiolab\pysndfile\_sndfile.pyd". >> >> But I don?t know how to see its contents or fix the problem. >> >> Any more tips? (Please!) >> -- > > I have this problem as well, as far as I am aware its not fixed and is a > problem linking to the sndfile.dll. > I just want to echo that I have this problem too. I am using WinXP Home SP3 and a new full installation of Python(x,y)-2.6.2. The simplest attempt to import from _sndfile.pyd is causing audiolab to fail, e.g., a one line script, "from scikits.audiolab import Sndfile", results in the following error: Traceback (most recent call last): File "C:\Python26\lib\site-packages\scikits\audiolab\pysndfile\__init__.py", line 1, in from _sndfile import Sndfile, Format, available_file_formats, available_encodings ImportError: DLL load failed: The specified procedure could not be found. I hope this is only a small and familiar glitch, and that David Cournapeau can get a round to it soon. Audiolab looked promising until this issue stopped me. SteveR -- View this message in context: http://old.nabble.com/Audiolab-on-Py2.6-tp26064218p27788613.html Sent from the Scipy-User mailing list archive at Nabble.com. From josef.pktd at gmail.com Fri Mar 5 09:40:22 2010 From: josef.pktd at gmail.com (josef.pktd at gmail.com) Date: Fri, 5 Mar 2010 09:40:22 -0500 Subject: [SciPy-User] changing signs Message-ID: <1cd32cbb1003050640s2b104542qaefb2c014d07dd28@mail.gmail.com> http://boscoh.com/protein/a-sign-a-flipped-structure-and-a-scientific-flameout-of-epic-proportions (link found at http://python.genedrift.org/2010/03/03/python-testing-beginner%E2%80%99s-guide-review/ ) Just a reminder about test coverage Josef From jsalvati at u.washington.edu Fri Mar 5 14:19:51 2010 From: jsalvati at u.washington.edu (John Salvatier) Date: Fri, 5 Mar 2010 11:19:51 -0800 Subject: [SciPy-User] Easy to make ufuncs from scalar Fortran function? Message-ID: <113e17f21003051119s40e29ae3l8694cc42f0481a41@mail.gmail.com> Hello, Can anyone tell me if it is very difficult to make a numpy ufunc given a scalar function written in Fortran? I have read part of http://docs.scipy.org/doc/numpy/user/c-info.beyond-basics.html on creating ufuncs, is there anything else I should read? John -------------- next part -------------- An HTML attachment was scrubbed... URL: From johan.gronqvist at gmail.com Fri Mar 5 16:02:28 2010 From: johan.gronqvist at gmail.com (=?ISO-8859-1?Q?Johan_Gr=F6nqvist?=) Date: Fri, 05 Mar 2010 22:02:28 +0100 Subject: [SciPy-User] Easy to make ufuncs from scalar Fortran function? In-Reply-To: <113e17f21003051119s40e29ae3l8694cc42f0481a41@mail.gmail.com> References: <113e17f21003051119s40e29ae3l8694cc42f0481a41@mail.gmail.com> Message-ID: John Salvatier skrev: > Can anyone tell me if it is very difficult to make a numpy ufunc given a > scalar function written in Fortran? I have read part of > http://docs.scipy.org/doc/numpy/user/c-info.beyond-basics.html on > creating ufuncs, is there anything else I should read? I have never created ufuncs, but as the docs you point to seem very c-oriented, I just wanted to make sure you know that calling fortran from c is not too complicated (at least with gnu compilers). If I would try, I would first wrap the fortran code in c, and then look at how to create ufuncs from c-code, but I have no idea how to do the second part. A page that seems rather informative and that was suggested by a google search on mixing c and fortran is . I hope it helps a bit, although it does not answer your question. / johan From vincent at vincentdavis.net Sat Mar 6 11:44:38 2010 From: vincent at vincentdavis.net (Vincent Davis) Date: Sat, 6 Mar 2010 09:44:38 -0700 Subject: [SciPy-User] structured array question? (slow learner :) Message-ID: <77e831101003060844y1b475c39scac32e32219d3600@mail.gmail.com> Ok not sure what I am doing wrong here, In fact I am sure this was working and now I updated python and it doesn't now. I am skeptical that that is true. My question is what is happening to the strings? >>> import numpy as np >>> a = [(1,1),(1,2),(1,3),(2,4),(2,5),(2,6)] >>> b = [(1,1,'apple', 'pie'),(2,5,'boys','play')] >>> aa = np.array(a, [('x',int),('y',int)]) >>> bb = np.array(b, [('x',int),('y',int), ('xb',str), ('yb',str)]) >>> bb array([(1, 1, '', ''), (2, 5, '', '')], dtype=[('x', '>> *Vincent Davis 720-301-3003 * vincent at vincentdavis.net my blog | LinkedIn -------------- next part -------------- An HTML attachment was scrubbed... URL: From Chris.Barker at noaa.gov Sat Mar 6 12:25:14 2010 From: Chris.Barker at noaa.gov (Christopher Barker) Date: Sat, 06 Mar 2010 09:25:14 -0800 Subject: [SciPy-User] structured array question? (slow learner :) In-Reply-To: <77e831101003060844y1b475c39scac32e32219d3600@mail.gmail.com> References: <77e831101003060844y1b475c39scac32e32219d3600@mail.gmail.com> Message-ID: <4B928FFA.8040605@noaa.gov> Vincent Davis wrote: > Ok not sure what I am doing wrong here, In fact I am sure this was > working and now I updated python and it doesn't now. I'm not sure if anything has changed, but: > I am skeptical that > that is true. My question is what is happening to the strings? strings in a structured array need to have a length specified. They default to 0: > dtype=[('x', ' References: <77e831101003060844y1b475c39scac32e32219d3600@mail.gmail.com> Message-ID: On Sat, Mar 6, 2010 at 10:44 AM, Vincent Davis wrote: > Ok not sure what I am doing wrong here, In fact I am sure this was working > and now I updated python and it doesn't now. I am skeptical that that is > true. My question is what is happening to the strings? > > >>> import numpy as np > >>> a = [(1,1),(1,2),(1,3),(2,4),(2,5),(2,6)] > >>> b = [(1,1,'apple', 'pie'),(2,5,'boys','play')] > >>> aa = np.array(a, [('x',int),('y',int)]) > >>> bb = np.array(b, [('x',int),('y',int), ('xb',str), ('yb',str)]) > >>> bb > array([(1, 1, '', ''), (2, 5, '', '')], > dtype=[('x', ' You need to give it a size for the strings (I've never really understood why you need to with structured arrays, but not regular ones). Try this: bb = np.array(b, [('x',int),('y',int), ('xb','S5'), ('yb','S5')]) Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma -------------- next part -------------- An HTML attachment was scrubbed... URL: From robert.kern at gmail.com Sat Mar 6 13:46:42 2010 From: robert.kern at gmail.com (Robert Kern) Date: Sat, 6 Mar 2010 12:46:42 -0600 Subject: [SciPy-User] structured array question? (slow learner :) In-Reply-To: References: <77e831101003060844y1b475c39scac32e32219d3600@mail.gmail.com> Message-ID: <3d375d731003061046p1fe215bcv663c0ac6b9b4b2fa@mail.gmail.com> On Sat, Mar 6, 2010 at 11:26, Ryan May wrote: > On Sat, Mar 6, 2010 at 10:44 AM, Vincent Davis > wrote: >> >> Ok not sure what I am doing wrong here, In fact I am sure this was working >> and now I updated python and it doesn't now. I am skeptical that that is >> true. My question is what is happening to the strings? >> >>> import numpy as np >> >>> a = [(1,1),(1,2),(1,3),(2,4),(2,5),(2,6)] >> >>> b = [(1,1,'apple', 'pie'),(2,5,'boys','play')] >> >>> aa = np.array(a, [('x',int),('y',int)]) >> >>> bb = np.array(b, [('x',int),('y',int), ('xb',str), ('yb',str)]) >> >>> bb >> array([(1, 1, '', ''), (2, 5, '', '')], >> ?? ? ?dtype=[('x', ' > You need to give it a size for the strings (I've never really understood why > you need to with structured arrays, but not regular ones). np.array() is a complicated function with many codepaths. It can do some autodetection for simple dtypes, but it would be difficult to write one for structured dtypes, I think. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From vincent at vincentdavis.net Sat Mar 6 16:08:02 2010 From: vincent at vincentdavis.net (Vincent Davis) Date: Sat, 6 Mar 2010 14:08:02 -0700 Subject: [SciPy-User] structured array question? (slow learner :) In-Reply-To: <3d375d731003061046p1fe215bcv663c0ac6b9b4b2fa@mail.gmail.com> References: <77e831101003060844y1b475c39scac32e32219d3600@mail.gmail.com> <3d375d731003061046p1fe215bcv663c0ac6b9b4b2fa@mail.gmail.com> Message-ID: <77e831101003061308y7f4e5f31g549791d707e5b21@mail.gmail.com> Again I am new to this but I spent 2hr on this and looked at the documentation an tutorials. To be fare there are not a lot of examples using strings. I would suggest that there are two many ways to specify dtype. At least that is my impression. I would find a nice table that list all with the different way they are used. for example @ Ryan used ('xb','S5') @ Christopher used ('xb', '|S10') I tried ('xb', |S10) there is also a10 or somthing numpy.float64() can be used Is it possible for me to help contribute something like this. As I learn more about python and numpy I often come across topics that are not very clear to me, or could benefit from more/different examples. I assume this is most applicable to the tutorials. Thanks again *Vincent Davis 720-301-3003 * vincent at vincentdavis.net my blog | LinkedIn On Sat, Mar 6, 2010 at 11:46 AM, Robert Kern wrote: > On Sat, Mar 6, 2010 at 11:26, Ryan May wrote: > > On Sat, Mar 6, 2010 at 10:44 AM, Vincent Davis > > > wrote: > >> > >> Ok not sure what I am doing wrong here, In fact I am sure this was > working > >> and now I updated python and it doesn't now. I am skeptical that that is > >> true. My question is what is happening to the strings? > >> >>> import numpy as np > >> >>> a = [(1,1),(1,2),(1,3),(2,4),(2,5),(2,6)] > >> >>> b = [(1,1,'apple', 'pie'),(2,5,'boys','play')] > >> >>> aa = np.array(a, [('x',int),('y',int)]) > >> >>> bb = np.array(b, [('x',int),('y',int), ('xb',str), ('yb',str)]) > >> >>> bb > >> array([(1, 1, '', ''), (2, 5, '', '')], > >> dtype=[('x', ' > > > You need to give it a size for the strings (I've never really understood > why > > you need to with structured arrays, but not regular ones). > > np.array() is a complicated function with many codepaths. It can do > some autodetection for simple dtypes, but it would be difficult to > write one for structured dtypes, I think. > > -- > Robert Kern > > "I have come to believe that the whole world is an enigma, a harmless > enigma that is made terrible by our own mad attempt to interpret it as > though it had an underlying truth." > -- Umberto Eco > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > -------------- next part -------------- An HTML attachment was scrubbed... URL: From vincent at vincentdavis.net Sat Mar 6 16:46:25 2010 From: vincent at vincentdavis.net (Vincent Davis) Date: Sat, 6 Mar 2010 14:46:25 -0700 Subject: [SciPy-User] Combining arrays based on (x,y) index values Message-ID: <77e831101003061346u1cca3d90n7231a0dfec35c5d5@mail.gmail.com> I have 3 arrays, each have an x and y column and I need to extend each row with the additional rows from the other arrays. Only one of the arrays has all the x,y values. I am also not sure how to deal with the missing values. I was thinking about making an array full of nan. So for example if I have >>> bb array([['1', '1', 'apple', 'pie'], ['2', '5', 'boys', 'play']], dtype='|S8') >>> aa array([[1, 1,free], [1, 2,upgrade], [1, 3, down], [2, 4, left], [2, 5, right], [2, 6, now]]) and I what to end up with magicfunc(aa,bb) array([[1, 1, free, 'apple', 'pie'], [1, 2, upgrade, '', ''], [1, 3, down, '', ''], [2, 4, left, '', ''], [2, 5, right, 'boys', 'play'], [2, 6, now, '', '']]) Whats the "right" way to do this, I have several ideas but I can't be the first to do this. I know the dimensions of the final array. but don't really have a plan of where to go from there. *Vincent Davis 720-301-3003 * vincent at vincentdavis.net my blog | LinkedIn -------------- next part -------------- An HTML attachment was scrubbed... URL: From robert.kern at gmail.com Sat Mar 6 17:30:20 2010 From: robert.kern at gmail.com (Robert Kern) Date: Sat, 6 Mar 2010 16:30:20 -0600 Subject: [SciPy-User] Combining arrays based on (x,y) index values In-Reply-To: <77e831101003061346u1cca3d90n7231a0dfec35c5d5@mail.gmail.com> References: <77e831101003061346u1cca3d90n7231a0dfec35c5d5@mail.gmail.com> Message-ID: <3d375d731003061430m67307c2dnb1b3c64bd9926482@mail.gmail.com> On Sat, Mar 6, 2010 at 15:46, Vincent Davis wrote: > > I have 3 arrays, each have an x and y column and I need to extend each row with the additional rows from the other arrays. Only one of the arrays has all the x,y values. I am also not sure how to deal with the missing values. I was thinking about making an array full of nan. You want what is called an outer join. You have to use structured arrays: In [2]: import numpy as np In [3]: b_dtype = np.dtype([('i', int), ('j', int), ('b_word1', 'S8'), ('b_word2', 'S8')]) In [4]: bb = np.array([(1, 1, 'apple', 'pie'), (2, 5, 'boys', 'play')]) In [5]: bb Out[5]: array([['1', '1', 'apple', 'pie'], ['2', '5', 'boys', 'play']], dtype='|S5') In [6]: bb = np.array([(1, 1, 'apple', 'pie'), (2, 5, 'boys', 'play')], dtype=b_dtype) In [7]: bb Out[7]: array([(1, 1, 'apple', 'pie'), (2, 5, 'boys', 'play')], dtype=[('i', ' References: <77e831101003061346u1cca3d90n7231a0dfec35c5d5@mail.gmail.com> <3d375d731003061430m67307c2dnb1b3c64bd9926482@mail.gmail.com> Message-ID: <77e831101003061532x7326b15fi6c3492ce0068172f@mail.gmail.com> Thank you, that is exactly what I needed, and I was already using structured arrays. *Vincent Davis 720-301-3003 * vincent at vincentdavis.net my blog | LinkedIn On Sat, Mar 6, 2010 at 3:30 PM, Robert Kern wrote: > On Sat, Mar 6, 2010 at 15:46, Vincent Davis > wrote: > > > > I have 3 arrays, each have an x and y column and I need to extend each > row with the additional rows from the other arrays. Only one of the arrays > has all the x,y values. I am also not sure how to deal with the missing > values. I was thinking about making an array full of nan. > > You want what is called an outer join. You have to use structured arrays: > > In [2]: import numpy as np > > In [3]: b_dtype = np.dtype([('i', int), ('j', int), ('b_word1', 'S8'), > ('b_word2', 'S8')]) > > In [4]: bb = np.array([(1, 1, 'apple', 'pie'), (2, 5, 'boys', 'play')]) > > In [5]: bb > Out[5]: > array([['1', '1', 'apple', 'pie'], > ['2', '5', 'boys', 'play']], > dtype='|S5') > > In [6]: bb = np.array([(1, 1, 'apple', 'pie'), (2, 5, 'boys', > 'play')], dtype=b_dtype) > > In [7]: bb > Out[7]: > array([(1, 1, 'apple', 'pie'), (2, 5, 'boys', 'play')], > dtype=[('i', ' ('b_word2', '|S8')]) > > In [8]: a_dtype = np.dtype([('i', int), ('j', int), ('a_word', 'S8')]) > > In [9]: aa = np.array([(1, 1, 'free'), (1, 2, 'upgrade'), (1, 3, > 'down'), (2, 5, 'right')], dtype=a_dtype) > > In [10]: aa > Out[10]: > array([(1, 1, 'free'), (1, 2, 'upgrade'), (1, 3, 'down'), (2, 5, 'right')], > dtype=[('i', ' > In [11]: from numpy.lib.recfunctions import join_by > > In [12]: join_by(['i', 'j'], aa, bb, jointype='outer') > Out[12]: > masked_array(data = [(1, 1, 'free', 'apple', 'pie') (1, 2, 'upgrade', --, > --) > (1, 3, 'down', --, --) (2, 5, 'right', 'boys', 'play')], > mask = [(False, False, False, False, False) (False, > False, False, True, True) > (False, False, False, True, True) (False, False, False, False, False)], > fill_value = (999999, 999999, 'N/A', 'N/A', 'N/A'), > dtype = [('i', ' ('b_word1', '|S8'), ('b_word2', '|S8')]) > > -- > Robert Kern > > "I have come to believe that the whole world is an enigma, a harmless > enigma that is made terrible by our own mad attempt to interpret it as > though it had an underlying truth." > -- Umberto Eco > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > -------------- next part -------------- An HTML attachment was scrubbed... URL: From vincent at vincentdavis.net Sun Mar 7 00:22:56 2010 From: vincent at vincentdavis.net (Vincent Davis) Date: Sat, 6 Mar 2010 22:22:56 -0700 Subject: [SciPy-User] operations on large arrays Message-ID: <77e831101003062122w2890311eh8a4fd856cbdc13b@mail.gmail.com> I have arrays of 8-20 rows and 230,000 column, all the data is float64 I what to be able to find the difference in the correlation matrix between arrays let A and B be of size (10, 230000) np.corrcoef(a)-np.corrcoef(b) I can't seem to do this with more than 10000 columns at a time because of memory limitations. (about 9GB usable to python) Is there a better way? I also have problem finding the column means which is surprising to me, I was not able to get the column means for 10000 columns, but I can computer the corrcoeff ? np.mean(a, axis=0) Do I just need to divide up the job or is there a better approach? Thanks *Vincent Davis 720-301-3003 * vincent at vincentdavis.net my blog | LinkedIn -------------- next part -------------- An HTML attachment was scrubbed... URL: From vincent at vincentdavis.net Sun Mar 7 01:05:03 2010 From: vincent at vincentdavis.net (Vincent Davis) Date: Sat, 6 Mar 2010 23:05:03 -0700 Subject: [SciPy-User] operations on large arrays In-Reply-To: <77e831101003062122w2890311eh8a4fd856cbdc13b@mail.gmail.com> References: <77e831101003062122w2890311eh8a4fd856cbdc13b@mail.gmail.com> Message-ID: <77e831101003062205n22790adw6804401c40e3ee60@mail.gmail.com> I just figured out that I had a few arrays that where taking up a bunch of the memory. That said I still wonder if there is a better way. *Vincent Davis 720-301-3003 * vincent at vincentdavis.net my blog | LinkedIn On Sat, Mar 6, 2010 at 10:22 PM, Vincent Davis wrote: > I have arrays of 8-20 rows and 230,000 column, all the data is float64 > I what to be able to find the difference in the correlation matrix between > arrays > let A and B be of size (10, 230000) > np.corrcoef(a)-np.corrcoef(b) > > I can't seem to do this with more than 10000 columns at a time because of > memory limitations. (about 9GB usable to python) > Is there a better way? > > I also have problem finding the column means which is surprising to me, I > was not able to get the column means for 10000 columns, but I can computer > the corrcoeff ? > np.mean(a, axis=0) > > Do I just need to divide up the job or is there a better approach? > > Thanks > > *Vincent Davis > 720-301-3003 * > vincent at vincentdavis.net > my blog | LinkedIn > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rmay31 at gmail.com Sun Mar 7 09:58:24 2010 From: rmay31 at gmail.com (Ryan May) Date: Sun, 7 Mar 2010 08:58:24 -0600 Subject: [SciPy-User] structured array question? (slow learner :) In-Reply-To: <77e831101003061308y7f4e5f31g549791d707e5b21@mail.gmail.com> References: <77e831101003060844y1b475c39scac32e32219d3600@mail.gmail.com> <3d375d731003061046p1fe215bcv663c0ac6b9b4b2fa@mail.gmail.com> <77e831101003061308y7f4e5f31g549791d707e5b21@mail.gmail.com> Message-ID: On Sat, Mar 6, 2010 at 3:08 PM, Vincent Davis wrote: > Again I am new to this but I spent 2hr on this and looked at the > documentation an tutorials. To be fare there are not a lot of examples using > strings. > I would suggest that there are two many ways to specify dtype. At least > that is my impression. > I would find a nice table that list all with the different way they are > used. > > for example > @ Ryan used ('xb','S5') > @ Christopher used ('xb', '|S10') > These are both specifying strings. 'S5' is just specifying a string length of 5 while '|S10' is specifying a string length of 10. The '|' is optional and specifies that the system-native endianness should be used to control the byte ordering. So these are both the exact same way. > I tried ('xb', |S10) > There's no way this actually ran without quotes. > there is also a10 or somthing > 'a' is the same as using 'S' above. > numpy.float64() can be used > That's for floating point types, not strings. A lot of the complexity from strings is that, unlike numeric types, there's no minium/typical sizes to assume for strings. This, combined with the fact that all items within a numpy array have to have the same size, makes string handling complex. (This implies that in memory, (1,1,'apple', 'pie') and (2,5,'boys','play') will occupy the same amount of memory.) Did you look at this: http://docs.scipy.org/doc/numpy/reference/arrays.dtypes.html Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma -------------- next part -------------- An HTML attachment was scrubbed... URL: From eadrogue at gmx.net Sun Mar 7 12:56:26 2010 From: eadrogue at gmx.net (Ernest =?iso-8859-1?Q?Adrogu=E9?=) Date: Sun, 7 Mar 2010 18:56:26 +0100 Subject: [SciPy-User] structured array question? (slow learner :) In-Reply-To: <77e831101003061308y7f4e5f31g549791d707e5b21@mail.gmail.com> References: <77e831101003060844y1b475c39scac32e32219d3600@mail.gmail.com> <3d375d731003061046p1fe215bcv663c0ac6b9b4b2fa@mail.gmail.com> <77e831101003061308y7f4e5f31g549791d707e5b21@mail.gmail.com> Message-ID: <20100307175626.GA3210@doriath.local> 6/03/10 @ 14:08 (-0700), thus spake Vincent Davis: > Again I am new to this but I spent 2hr on this and looked at the > documentation an tutorials. To be fare there are not a lot of examples using > strings. Notice that you can also use Python objects instead of strings, as there's little or no performance penalty. In [5]: np.array([('foo', 4.5), ('bar', 5.1)], 'O, d') This way you need not specify the length of the string in the dtype. Ernest From vincent at vincentdavis.net Sun Mar 7 16:02:13 2010 From: vincent at vincentdavis.net (Vincent Davis) Date: Sun, 7 Mar 2010 14:02:13 -0700 Subject: [SciPy-User] structured array question? (slow learner :) In-Reply-To: References: <77e831101003060844y1b475c39scac32e32219d3600@mail.gmail.com> <3d375d731003061046p1fe215bcv663c0ac6b9b4b2fa@mail.gmail.com> <77e831101003061308y7f4e5f31g549791d707e5b21@mail.gmail.com> Message-ID: <77e831101003071302v75456d2fr1e62c5e3129f2a65@mail.gmail.com> Thanks again for the help, My point in mentioning that I was not able to find the answer was to point out that the information is spread out and not obvious the first time you look for the information. The fact that a10 |S10, S10 are the same thing and numpy.str does not get rejected but does not work is confusing the first time you look at it, I was suggesting that it could be presented a little better. Probably the only contribution I can make is to point out that there is a lack of documentation from the perspective of a beginner. Thanks Again *Vincent Davis 720-301-3003 * vincent at vincentdavis.net my blog | LinkedIn On Sun, Mar 7, 2010 at 7:58 AM, Ryan May wrote: > On Sat, Mar 6, 2010 at 3:08 PM, Vincent Davis wrote: > >> Again I am new to this but I spent 2hr on this and looked at the >> documentation an tutorials. To be fare there are not a lot of examples using >> strings. >> I would suggest that there are two many ways to specify dtype. At least >> that is my impression. >> I would find a nice table that list all with the different way they are >> used. >> >> for example >> @ Ryan used ('xb','S5') >> @ Christopher used ('xb', '|S10') >> > > These are both specifying strings. 'S5' is just specifying a string length > of 5 while '|S10' is specifying a string length of 10. The '|' is optional > and specifies that the system-native endianness should be used to control > the byte ordering. So these are both the exact same way. > > >> I tried ('xb', |S10) >> > > There's no way this actually ran without quotes. > > >> there is also a10 or somthing >> > > 'a' is the same as using 'S' above. > > >> numpy.float64() can be used >> > > That's for floating point types, not strings. A lot of the complexity from > strings is that, unlike numeric types, there's no minium/typical sizes to > assume for strings. This, combined with the fact that all items within a > numpy array have to have the same size, makes string handling complex. > (This implies that in memory, (1,1,'apple', 'pie') and (2,5,'boys','play') > will occupy the same amount of memory.) > > Did you look at this: > > http://docs.scipy.org/doc/numpy/reference/arrays.dtypes.html > > > Ryan > > -- > Ryan May > Graduate Research Assistant > School of Meteorology > University of Oklahoma > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From d.l.goldsmith at gmail.com Mon Mar 8 02:42:58 2010 From: d.l.goldsmith at gmail.com (David Goldsmith) Date: Sun, 7 Mar 2010 23:42:58 -0800 Subject: [SciPy-User] [OT] Anyone here know Audacity and WAV? Message-ID: <45d1ab481003072342y5350324an434e0ac35fa71cbc@mail.gmail.com> If so, please reply off list. Thanks! DG -------------- next part -------------- An HTML attachment was scrubbed... URL: From millman at berkeley.edu Mon Mar 8 03:44:52 2010 From: millman at berkeley.edu (Jarrod Millman) Date: Mon, 8 Mar 2010 00:44:52 -0800 Subject: [SciPy-User] PSF GSoC 2010 (Py3K focus) Message-ID: Hello, Given the interest in participating in the GSoC this summer, I am forwarding a very interesting email from Titus Brown. If you are interested in doing a GSoC or mentoring, please read his email carefully. Basically, the PSF will be focuing on Py3K-related projects. Given Pauli's work on Py3K support for NumPy, I think we might be in a good position to move forward on porting the rest of our stack to Py3K. So we should focus on projects to: 1. finish porting and testing NumPy with Py3K 2. port and test SciPy with Py3K 3. port and test matplotlib with Py3K 4. port and test ipython with Py3K 5. etc. Given the PSF's stated emphasis this year, it probably doesn't make sense to pursue any non-Py3K projects. Jarrod ---------- Forwarded message ---------- From: C. Titus Brown Date: Tue, Mar 2, 2010 at 6:12 AM Subject: [SoC2009-mentors] [ctb at msu.edu: GSoC 2010 - it's on!] To: soc2009-mentors at python.org ----- Forwarded message from "C. Titus Brown" ----- Date: Wed, 24 Feb 2010 12:54:52 -0800 From: "C. Titus Brown" To: psf-members at python.org Cc: gsoc2010-mentors at python.org Subject: GSoC 2010 - it's on! Hi all, it's that time of year again, and Google has decided to run the Google Summer of Code again! ?http://groups.google.com/group/google-summer-of-code-discuss/browse_thread/thread/d839c0b02ac15b3f ?http://socghop.appspot.com/ Arc Riley has stepped up to run it for the PSF again this year, and I'm backstopping him. ?If you are interested in mentoring or kibbitzing on those who are, please sign up for the soc2010-mentors mailing list here, ?http://mail.python.org/mailman/listinfo/soc2010-mentors This year we're proposing to solicit and prioritize applications for Python 3.x -- 3K tools, porting old projects, etc. ?Python 2.x projects will be a distinct second. ?There will be no "core" category this year, although obviously if someone on one of the core teams wants to push a project it'll help! If you have an idea for a project, please send it to the -mentors list and add it to the wiki at ? http://wiki.python.org/moin/SummerOfCode/2010 We're also going to change a few things up to make it more useful to the PSF. Specifically, ?- the foundation is going to *require* 1 blog post/wk from each student. ?- we're going to hire an administrative assistant to monitor the students. ?- the student application process will be a bit more rigorous and job-app ? like; the Django SF has been doing this for at least one round and they ? claim that it results in much better and more serious students. ?- we'll be focusing on student quality more than on project egalitarianism. ? If project X can recruit three fantastic students to one fantastic and one ? mediocre student for project Y, then project X gets three and project Y ? gets one. The hope is that this will make the GSoC much more useful for Python than it has been in the past. Arc will be posting something to the www.python.org site and python-announce soon, too. Followups to soc2010-mentors. cheers, --titus -- C. Titus Brown, ctb at msu.edu ----- End forwarded message ----- From millman at berkeley.edu Mon Mar 8 03:52:25 2010 From: millman at berkeley.edu (Jarrod Millman) Date: Mon, 8 Mar 2010 00:52:25 -0800 Subject: [SciPy-User] Google Summer of Code... In-Reply-To: References: <4B8C3C81.7000509@noaa.gov> <1cd32cbb1003011435u725d37e5ne3c98475f3cfa8a@mail.gmail.com> <3d375d731003011443h1a5c0b02h837f5af3f5348037@mail.gmail.com> Message-ID: Hello Sebastian, Thanks for taking the time to outline a potential GSoC project. It is definitely worth taking the time to add it to the wiki: http://projects.scipy.org/scipy/wiki/SummerofCodeIdeas Unfortunately, though, it isn't likely that a project like this will be accepted this year. But it will be nice to have the proposal written down because someone might decide to work on it without a GSoC or someone might do the project next year. I forwarded an email from Titus Brown, which explains that the PSF will be looking for Py3K-related projects this year. So if we get any GSoC projects funded this year, they will probably be focused on porting numpy, scipy, matplotlib, ipython, etc. to Py3K. Thanks, Jarrod On Wed, Mar 3, 2010 at 1:14 AM, Sebastian Walter wrote: > I could mentor an algorithmic differentiation (AD) project, but I'm > still not quite sure how to proceed. > Should I write up a proposal on the wiki and after that propose the > project on the > http://mail.python.org/mailman/listinfo/soc2010-mentors mailing list? > > I have already created a package that I believe would be a very good > addition to scipy/numpy (preferably numpy) when it is mature enough. > It is hosted on http://github.com/b45ch1/taylorpoly > > The package is not an AD tool but makes it very easy to create AD > tools using those algorithms. > An illustrative example how to do (forward mode) AD is given in: > http://github.com/b45ch1/taylorpoly/blob/master/examples/utps_for_algorithmic_differentiation.py > > What is missing up to now are differentiated algorithms for tan, atan, > asin, sinh, etc. (in Taylor arithmetic) > as well as the core algorithms for reverse mode AD. > > Implementing those algorithms should be doable in 4 months. Also, > since the task is to implement many small algorithms, > this project is unlikely to fail completely. The worst that can happen > is that not as many algorithms get implemented as one could wish for. > > Could anyone give feedback if that project is ok? > > best regards, > Sebastian From sebastian.walter at gmail.com Mon Mar 8 04:09:10 2010 From: sebastian.walter at gmail.com (Sebastian Walter) Date: Mon, 8 Mar 2010 10:09:10 +0100 Subject: [SciPy-User] Google Summer of Code... In-Reply-To: References: <4B8C3C81.7000509@noaa.gov> <1cd32cbb1003011435u725d37e5ne3c98475f3cfa8a@mail.gmail.com> <3d375d731003011443h1a5c0b02h837f5af3f5348037@mail.gmail.com> Message-ID: On Mon, Mar 8, 2010 at 9:52 AM, Jarrod Millman wrote: > Hello Sebastian, > > Thanks for taking the time to outline a potential GSoC project. ?It is > definitely worth taking the time to add it to the wiki: > http://projects.scipy.org/scipy/wiki/SummerofCodeIdeas > > Unfortunately, though, it isn't likely that a project like this will > be accepted this year. ?But it will be nice to have the proposal > written down because someone might decide to work on it without a GSoC > or someone might do the project next year. will do that > > I forwarded an email from Titus Brown, which explains that the PSF > will be looking for Py3K-related projects this year. ?So if we get any > GSoC projects funded this year, they will probably be focused on > porting numpy, scipy, matplotlib, ipython, etc. to Py3K. I've just read that email about the focus on Py3K. It's a pity that the focus is solely on porting code and not on adding new features at all. But of course I perfectly understand the priorities. > > Thanks, > Jarrod > > On Wed, Mar 3, 2010 at 1:14 AM, Sebastian Walter > wrote: >> I could mentor an algorithmic differentiation (AD) project, but I'm >> still not quite sure how to proceed. >> Should I write up a proposal on the wiki and after that propose the >> project on the >> http://mail.python.org/mailman/listinfo/soc2010-mentors mailing list? >> >> I have already created a package that I believe would be a very good >> addition to scipy/numpy (preferably numpy) when it is mature enough. >> It is hosted on http://github.com/b45ch1/taylorpoly >> >> The package is not an AD tool but makes it very easy to create AD >> tools using those algorithms. >> An illustrative example how to do (forward mode) AD is given in: >> http://github.com/b45ch1/taylorpoly/blob/master/examples/utps_for_algorithmic_differentiation.py >> >> What is missing up to now are differentiated algorithms for tan, atan, >> asin, sinh, etc. (in Taylor arithmetic) >> as well as the core algorithms for reverse mode AD. >> >> Implementing those algorithms should be doable in 4 months. Also, >> since the task is to implement many small algorithms, >> this project is unlikely to fail completely. The worst that can happen >> is that not as many algorithms get implemented as one could wish for. >> >> Could anyone give feedback if that project is ok? >> >> best regards, >> Sebastian > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > From dlenski at gmail.com Mon Mar 8 10:09:37 2010 From: dlenski at gmail.com (Daniel Lenski) Date: Mon, 8 Mar 2010 15:09:37 +0000 (UTC) Subject: [SciPy-User] fromimage/imread segfaults on my images Message-ID: Hi all, I'm using SciPy to process some sparse binary images with a resolution of about 5000x5000 pixels. I try to load images like this: im = Image.open('/tmp/foo.pbm') print "Image loaded, size is %s and mode is %s." % (im.size, im.mode) arr = fromimage(im) or arr = imread('/tmp/foo.pbm') In either case, I get a segfault. The segfault is definitely in the SciPy code, rather than the PIL code, since PIL's Image.open runs fine. I ran strace, and there's an attempt to mmap() a region as large as the image, one byte per pixel, immediately before the segfault: mmap(NULL, 21463040, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f278b5be000 The funny thing is... the imread() implementation in pylab *does* work, but it converts all images to RGB mode and reverses them vertically for no apparent reason. So I'd rather not use it. Is this a known bug in SciPy? Any workarounds/fixes? I don't know any other good, reliable way to get a big image into an array :-( Dan From dlenski at gmail.com Mon Mar 8 10:31:18 2010 From: dlenski at gmail.com (Daniel Lenski) Date: Mon, 8 Mar 2010 15:31:18 +0000 (UTC) Subject: [SciPy-User] fromimage/imread segfaults on my images References: Message-ID: On Mon, 08 Mar 2010 15:09:37 +0000, Daniel Lenski wrote: > I ran strace, and there's an attempt to mmap() a region as large as the > image, one byte per pixel, immediately before the segfault: > > mmap(NULL, 21463040, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, > -1, 0) = 0x7f278b5be000 Just to clarify... this system is running Linux 2.6, amd64 build, and has 4gb of RAM. So there's no reason why a 21 MB mmap would fail, normally. Dan From paul.anton.letnes at gmail.com Mon Mar 8 12:47:51 2010 From: paul.anton.letnes at gmail.com (Paul Anton Letnes) Date: Mon, 8 Mar 2010 09:47:51 -0800 Subject: [SciPy-User] scipy+lapack array copy Message-ID: Hi everyone. I have a numerical project where I link a fortran module to python using f2py. The fortran module basically sets up the left hand side coefficient matrix of a linear equation system. The right hand side is small, so I set that up in python. So far, everything works great. Now, when I call scipy-lapack, I am using: from scipy.linalg.lapack import flapack as lapack lu, piv, x, info = lapack.zgesv(A, b) A is created in the fortran part of the program. b is created from numpy.zeros(). Both report as F_CONTIGUOUS by printing A.flags and b.flags. The problem is that I'd like A to be large (>1GB), but the lapack wrapper (or lapack itself?) copies the array, doubling the memory use. Aside from being unnecessary, this also reduces the practical problem size I can solve by a factor 2, which of course is very annoying. How can I get around this problem? Regards, Paul. From jsseabold at gmail.com Mon Mar 8 13:10:32 2010 From: jsseabold at gmail.com (Skipper Seabold) Date: Mon, 8 Mar 2010 13:10:32 -0500 Subject: [SciPy-User] scipy+lapack array copy In-Reply-To: References: Message-ID: On Mon, Mar 8, 2010 at 12:47 PM, Paul Anton Letnes wrote: > Hi everyone. > > I have a numerical project where I link a fortran module to python using f2py. The fortran module basically sets up the left hand side coefficient matrix of a linear equation system. The right hand side is small, so I set that up in python. So far, everything works great. > > Now, when I call scipy-lapack, I am using: > from scipy.linalg.lapack import flapack as lapack > lu, piv, x, info = lapack.zgesv(A, b) > A is created in the fortran part of the program. b is created from numpy.zeros(). Both report as F_CONTIGUOUS by printing A.flags and b.flags. > > The problem is that I'd like A to be large (>1GB), but the lapack wrapper (or lapack itself?) copies the array, doubling the memory use. Aside from being unnecessary, this also reduces the practical problem size I can solve by a factor 2, which of course is very annoying. > > How can I get around this problem? > It looks like zgesv allows you to set overwrite_a = 1. If this isn't what you want, there might be another way to proceed. In [5]: from scipy.linalg.lapack import flapack as lapack In [6]: lapack.zgesv? Type: fortran String Form: Namespace: Interactive Docstring: zgesv - Function signature: lu,piv,x,info = zgesv(a,b,[overwrite_a,overwrite_b]) Required arguments: a : input rank-2 array('D') with bounds (n,n) b : input rank-2 array('D') with bounds (n,nrhs) Optional arguments: overwrite_a := 0 input int overwrite_b := 0 input int Return objects: lu : rank-2 array('D') with bounds (n,n) and a storage piv : rank-1 array('i') with bounds (n) x : rank-2 array('D') with bounds (n,nrhs) and b storage info : int Skipper From Deil.Christoph at googlemail.com Mon Mar 8 14:02:49 2010 From: Deil.Christoph at googlemail.com (Christoph Deil) Date: Mon, 8 Mar 2010 20:02:49 +0100 Subject: [SciPy-User] flat / nonflat array index conversion Message-ID: <7523C74A-2E1C-4AF1-8B6D-23CD51D39930@googlemail.com> Is there a numpy function to convert corresponding array indices in flattened / nonflat multidimensional arrays for a given shape? E.g. for a = array([0,1,2,3,4,5]).reshape(2,3) I want some function that converts e.g. 1 to [0,1] and 5 to [1,2] if I tell it a.shape. For 2D it's of course easy to do it by hand, but I need something that is fast and works for arrays of any dimension. From josef.pktd at gmail.com Mon Mar 8 14:11:36 2010 From: josef.pktd at gmail.com (josef.pktd at gmail.com) Date: Mon, 8 Mar 2010 14:11:36 -0500 Subject: [SciPy-User] flat / nonflat array index conversion In-Reply-To: <7523C74A-2E1C-4AF1-8B6D-23CD51D39930@googlemail.com> References: <7523C74A-2E1C-4AF1-8B6D-23CD51D39930@googlemail.com> Message-ID: <1cd32cbb1003081111y7ae45c96n1771c35b29ea2bf3@mail.gmail.com> On Mon, Mar 8, 2010 at 2:02 PM, Christoph Deil wrote: > Is there a numpy function to convert corresponding array indices in flattened / nonflat multidimensional arrays for a given shape? > > E.g. for a = array([0,1,2,3,4,5]).reshape(2,3) I want some function that converts e.g. 1 to [0,1] and 5 to [1,2] if I tell it a.shape. For 2D it's of course easy to do it by hand, but I need something that is fast and works for arrays of any dimension. in numpy docs under Indexing Routines >>> list(np.ndindex(3,2,4)) [(0, 0, 0), (0, 0, 1), (0, 0, 2), (0, 0, 3), (0, 1, 0), (0, 1, 1), (0, 1, 2), (0, 1, 3), (1, 0, 0), (1, 0, 1), (1, 0, 2), (1, 0, 3), (1, 1, 0), (1, 1, 1), (1, 1, 2), (1, 1, 3), (2, 0, 0), (2, 0, 1), (2, 0, 2), (2, 0, 3), (2, 1, 0), (2, 1, 1), (2, 1, 2), (2, 1, 3)] there are also other iterators and functions Josef > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > From kwgoodman at gmail.com Mon Mar 8 14:11:42 2010 From: kwgoodman at gmail.com (Keith Goodman) Date: Mon, 8 Mar 2010 11:11:42 -0800 Subject: [SciPy-User] flat / nonflat array index conversion In-Reply-To: <7523C74A-2E1C-4AF1-8B6D-23CD51D39930@googlemail.com> References: <7523C74A-2E1C-4AF1-8B6D-23CD51D39930@googlemail.com> Message-ID: On Mon, Mar 8, 2010 at 11:02 AM, Christoph Deil wrote: > Is there a numpy function to convert corresponding array indices in flattened / nonflat multidimensional arrays for a given shape? > > E.g. for a = array([0,1,2,3,4,5]).reshape(2,3) I want some function that converts e.g. 1 to [0,1] and 5 to [1,2] if I tell it a.shape. For 2D it's of course easy to do it by hand, but I need something that is fast and works for arrays of any dimension. > You could create a dictionary using numpy.ndenumerate. Or you could use a third party package such as the labeled array package, la: >> a = np.array([0,1,2,3,4,5]).reshape(2,3) >> from la import larry >> y = larry(a) >> y.todict() {(0, 0): 0, (0, 1): 1, (0, 2): 2, (1, 0): 3, (1, 1): 4, (1, 2): 5} From paul.anton.letnes at gmail.com Mon Mar 8 14:15:19 2010 From: paul.anton.letnes at gmail.com (Paul Anton Letnes) Date: Mon, 8 Mar 2010 11:15:19 -0800 Subject: [SciPy-User] scipy+lapack array copy In-Reply-To: References: Message-ID: On 8. mars 2010, at 10.10, Skipper Seabold wrote: > On Mon, Mar 8, 2010 at 12:47 PM, Paul Anton Letnes > wrote: >> Hi everyone. >> >> I have a numerical project where I link a fortran module to python using f2py. The fortran module basically sets up the left hand side coefficient matrix of a linear equation system. The right hand side is small, so I set that up in python. So far, everything works great. >> >> Now, when I call scipy-lapack, I am using: >> from scipy.linalg.lapack import flapack as lapack >> lu, piv, x, info = lapack.zgesv(A, b) >> A is created in the fortran part of the program. b is created from numpy.zeros(). Both report as F_CONTIGUOUS by printing A.flags and b.flags. >> >> The problem is that I'd like A to be large (>1GB), but the lapack wrapper (or lapack itself?) copies the array, doubling the memory use. Aside from being unnecessary, this also reduces the practical problem size I can solve by a factor 2, which of course is very annoying. >> >> How can I get around this problem? >> > > It looks like zgesv allows you to set overwrite_a = 1. If this isn't > what you want, there might be another way to proceed. > > In [5]: from scipy.linalg.lapack import flapack as lapack > > In [6]: lapack.zgesv? > Type: fortran > String Form: > Namespace: Interactive > Docstring: > zgesv - Function signature: > lu,piv,x,info = zgesv(a,b,[overwrite_a,overwrite_b]) > Required arguments: > a : input rank-2 array('D') with bounds (n,n) > b : input rank-2 array('D') with bounds (n,nrhs) > Optional arguments: > overwrite_a := 0 input int > overwrite_b := 0 input int > Return objects: > lu : rank-2 array('D') with bounds (n,n) and a storage > piv : rank-1 array('i') with bounds (n) > x : rank-2 array('D') with bounds (n,nrhs) and b storage > info : int > > > Skipper > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user Skipper, thanks a lot. This looks like everything I need. I have to overwrite A I guess, otherwise it will have to be copied. I must have overlooked this in the documentation. Regards, Paul. From rmay31 at gmail.com Mon Mar 8 14:51:40 2010 From: rmay31 at gmail.com (Ryan May) Date: Mon, 8 Mar 2010 13:51:40 -0600 Subject: [SciPy-User] flat / nonflat array index conversion In-Reply-To: <7523C74A-2E1C-4AF1-8B6D-23CD51D39930@googlemail.com> References: <7523C74A-2E1C-4AF1-8B6D-23CD51D39930@googlemail.com> Message-ID: On Mon, Mar 8, 2010 at 1:02 PM, Christoph Deil wrote: > Is there a numpy function to convert corresponding array indices in flattened / nonflat multidimensional arrays for a given shape? > > E.g. for a = array([0,1,2,3,4,5]).reshape(2,3) I want some function that converts e.g. 1 to [0,1] and 5 to [1,2] if I tell it a.shape. For 2D it's of course easy to do it by hand, but I need something that is fast and works for arrays of any dimension. Look at numpy.unravel_index: Convert a flat index to an index tuple for an array of given shape. Parameters ---------- x : int Flattened index. dims : tuple of ints Input shape, the shape of an array into which indexing is required. Returns ------- idx : tuple of ints Tuple of the same shape as `dims`, containing the unraveled index. Notes ----- In the Examples section, since ``arr.flat[x] == arr.max()`` it may be easier to use flattened indexing than to re-map the index to a tuple. Examples -------- >>> arr = np.arange(20).reshape(5, 4) >>> arr array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11], [12, 13, 14, 15], [16, 17, 18, 19]]) >>> x = arr.argmax() >>> x 19 >>> dims = arr.shape >>> idx = np.unravel_index(x, dims) >>> idx (4, 3) >>> arr[idx] == arr.max() True Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma From Chris.Barker at noaa.gov Mon Mar 8 14:58:08 2010 From: Chris.Barker at noaa.gov (Christopher Barker) Date: Mon, 08 Mar 2010 11:58:08 -0800 Subject: [SciPy-User] fromimage/imread segfaults on my images In-Reply-To: References: Message-ID: <4B9556D0.9090409@noaa.gov> Daniel Lenski wrote: > I'm using SciPy to process some sparse binary images with a resolution of > about 5000x5000 pixels. I try to load images like this: > > im = Image.open('/tmp/foo.pbm') > print "Image loaded, size is %s and mode is %s." % (im.size, im.mode) > arr = fromimage(im) > > or > > arr = imread('/tmp/foo.pbm') where do fromimage and imread come from? "namespaces are one honking great idea". > In either case, I get a segfault. The segfault is definitely in the > SciPy code, rather than the PIL code, since PIL's Image.open runs fine. don't be so sure -- I think PIL used lazy loading, so it doesn't actually read all the data with the open call, but rather when you try to do something with it. I'd try making a few calls on the PIl image, and make sure it is what you expect. If it is, the easiest way to get it into a numpy array is: np.asarray(pil_image) do you have a smaller image in the same format you can experiment with? That might make it easier to figure out. > I don't know any other good, reliable way > to get a big image into an array :-( if you really can't get PIL to work, pbm looks really simple: http://netpbm.sourceforge.net/doc/pbm.html read the header, then read the data with np.fromfile(), then convert to a uint8 array with np.unpackbits(). You could also take a look at MPL's imread() and see what it does -- I don't think MPL requires PIL, though I could be wrong. -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chris.Barker at noaa.gov From mudit_19a at yahoo.com Mon Mar 8 15:05:59 2010 From: mudit_19a at yahoo.com (mudit sharma) Date: Tue, 9 Mar 2010 01:35:59 +0530 (IST) Subject: [SciPy-User] Finding coefficient Message-ID: <803819.25205.qm@web94912.mail.in2.yahoo.com> I have 2d array of observations x1, x2, x3, x4 which I am looking to solve in such a way that z have a minimum value. ax1 + bx2 + cx3 + dx4 = s z = np.where(s < 0).shape[0] I am currently using a brute force method by putting a constraint 0 > (a,b,c,d) < 20. I am looking for ideas to acheive this more efficiently. Cheers, M From deil.christoph at googlemail.com Mon Mar 8 16:47:51 2010 From: deil.christoph at googlemail.com (Christoph Deil) Date: Mon, 8 Mar 2010 22:47:51 +0100 Subject: [SciPy-User] flat / nonflat array index conversion continued Message-ID: <4D84E2BB-592B-4CAA-AC12-C87BB94CC95B@googlemail.com> Sorry that I don't reply to the thread I started today (http://mail.scipy.org/pipermail/scipy-user/2010-March/024565.html), but I had the list in digest mode. Anyways, Ryan suggested I use numpy.unravel_index, and indeed this does exactly what I wanted. My question now is how I can vectorize numpy.unravel_index? Here is what I tried: idx = array([1,5]) # really I have 1e6 indices I want to unravel unravel_index(idx,(2, 3)) # Doesn't work. Raises a ValueError v_u_i = vectorize(unravel_index) # Try to vectorize it v_u_i(idx,(2, 3)) # Doesn't work. Raises a TypeError Thanks for you help! --Christoph From bsouthey at gmail.com Mon Mar 8 17:29:18 2010 From: bsouthey at gmail.com (Bruce Southey) Date: Mon, 08 Mar 2010 16:29:18 -0600 Subject: [SciPy-User] operations on large arrays In-Reply-To: <77e831101003062205n22790adw6804401c40e3ee60@mail.gmail.com> References: <77e831101003062122w2890311eh8a4fd856cbdc13b@mail.gmail.com> <77e831101003062205n22790adw6804401c40e3ee60@mail.gmail.com> Message-ID: <4B957A3E.8030709@gmail.com> On 03/07/2010 12:05 AM, Vincent Davis wrote: > I just figured out that I had a few arrays that where taking up a > bunch of the memory. That said I still wonder if there is a better way. > > > > > *Vincent Davis > 720-301-3003 * > vincent at vincentdavis.net > > my blog | LinkedIn > > > > > On Sat, Mar 6, 2010 at 10:22 PM, Vincent Davis > > wrote: > > I have arrays of 8-20 rows and 230,000 column, all the data is float64 > I what to be able to find the difference in the correlation matrix > between arrays > let A and B be of size (10, 230000) > np.corrcoef(a)-np.corrcoef(b) > > I can't seem to do this with more than 10000 columns at a time > because of memory limitations. (about 9GB usable to python) > Is there a better way? > > I also have problem finding the column means which is surprising > to me, I was not able to get the column means for 10000 columns, > but I can computer the corrcoeff ? > np.mean(a, axis=0) > > Do I just need to divide up the job or is there a better approach? > > Thanks > > > > > *Vincent Davis > 720-301-3003 * > vincent at vincentdavis.net > > my blog | LinkedIn > > > > > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > Is there a better way to do what? A problem with 'np.corrcoef(a)-np.corrcoef(b)' is that it is unclear what you want as if a and b have more than 1d then you get an array back. If the array is near zero then what does that mean? One interpretation that perhaps you should be seeing if these are the same array. If the array is not zero then what does that mean? Do you need to know which parts of a and b lead to different correlations? You can always do np.corrcoef(a,b) such that the diagonal relating each column of a to each column of b is one. Bruce -------------- next part -------------- An HTML attachment was scrubbed... URL: From dvanliere at gmail.com Mon Mar 8 22:10:10 2010 From: dvanliere at gmail.com (Diederik van Liere) Date: Mon, 8 Mar 2010 22:10:10 -0500 Subject: [SciPy-User] Compiling scipy.sparse.sparsetools extension throws g++ internal error Message-ID: Dear scipy-user members, I am trying to build Scipy for my 32bit Redhat server and I am running into serious trouble, both with scipy 0.7.1 and the latest SVN version. I get the following error: building 'scipy.sparse.sparsetools._csr' extension compiling C++ sources C compiler: g++ -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -fPIC creating build/temp.linux-i686-2.6/scipy/sparse/sparsetools compile options: '-I/usr/local/lib/python2.6/site-packages/numpy/core/include -I/usr/local/include/python2.6 -c' g++: scipy/sparse/sparsetools/csr_wrap.cxx g++: Internal error: Terminated (program cc1plus) Please submit a full bug report. See for instructions. g++: Internal error: Terminated (program cc1plus) Please submit a full bug report. See for instructions. error: Command "g++ -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/local/lib/python2.6/site-packages/numpy/core/include -I/usr/local/include/python2.6 -c scipy/sparse/sparsetools/csr_wrap.cxx -o build/temp.linux-i686-2.6/scipy/sparse/sparsetools/csr_wrap.o" failed with exit status 1 and I really don't know how to fix this. I have tried both Numpy 1.3.0 and the latest Numpy SVN version but to no avail. I hope someone can point me in the right direction. Thanks so much, Best regards, Diederik -------------- next part -------------- An HTML attachment was scrubbed... URL: From david at silveregg.co.jp Mon Mar 8 22:21:11 2010 From: david at silveregg.co.jp (David Cournapeau) Date: Tue, 09 Mar 2010 12:21:11 +0900 Subject: [SciPy-User] Compiling scipy.sparse.sparsetools extension throws g++ internal error In-Reply-To: References: Message-ID: <4B95BEA7.7000603@silveregg.co.jp> Diederik van Liere wrote: > error: Command "g++ -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 > -Wall -fPIC -I/usr/local/lib/python2.6/site-packages/numpy/core/include > -I/usr/local/include/python2.6 -c scipy/sparse/sparsetools/csr_wrap.cxx -o > build/temp.linux-i686-2.6/scipy/sparse/sparsetools/csr_wrap.o" failed with > exit status 1 What's the version of g++ ? > and I really don't know how to fix this. I have tried both Numpy 1.3.0 and > the latest Numpy SVN version but to no avail. I hope someone can point me in > the right direction. Changing numpy version is unlikely to fix anything here, as the error is a crash from the C++ compiler. One solution would be to update gcc (by compiling your own version), or more simply, if you don't need scipy.sparse to disable it in scipy/setup.py by commenting the sparse line. David From dvanliere at gmail.com Mon Mar 8 22:29:42 2010 From: dvanliere at gmail.com (Diederik van Liere) Date: Mon, 8 Mar 2010 22:29:42 -0500 Subject: [SciPy-User] Compiling scipy.sparse.sparsetools extension throws g++ internal error Message-ID: > Diederik van Liere wrote: >>* error: Command "g++ -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3*>>* -Wall -fPIC -I/usr/local/lib/python2.6/site-packages/numpy/core/include*>>* -I/usr/local/include/python2.6 -c scipy/sparse/sparsetools/csr_wrap.cxx -o*>>* build/temp.linux-i686-2.6/scipy/sparse/sparsetools/csr_wrap.o" failed with*>>* exit status 1* > What's the version of g++ ? I am using GCC 4.1.2 (32bit) >>* and I really don't know how to fix this. I have tried both Numpy 1.3.0 and*>>* the latest Numpy SVN version but to no avail. I hope someone can point me in*>>* the right direction.* > Changing numpy version is unlikely to fix anything here, as the error is > a crash from the C++ compiler. Okay, good to know. > One solution would be to update gcc (by compiling your own version), or > more simply, if you don't need scipy.sparse to disable it in > scipy/setup.py by commenting the sparse line. I don't think I will need this, this is for sparse matrix manipulation, right? I need scipy.linalg although I prefer a complete working version of Scipy because it might the case the sparse module is required by one of other libraries I am suing. But thanks David for giving me some workarounds. > David -------------- next part -------------- An HTML attachment was scrubbed... URL: From david at silveregg.co.jp Mon Mar 8 22:38:25 2010 From: david at silveregg.co.jp (David Cournapeau) Date: Tue, 09 Mar 2010 12:38:25 +0900 Subject: [SciPy-User] Compiling scipy.sparse.sparsetools extension throws g++ internal error In-Reply-To: References: Message-ID: <4B95C2B1.3050800@silveregg.co.jp> Diederik van Liere wrote: > I don't think I will need this, this is for sparse matrix manipulation, right? Yes. > I need scipy.linalg although I prefer a complete working version of > Scipy because it might the case the sparse module is required by one > of other libraries I am suing. Indeed - not building scipy.sparse is clearly a temporary workaround, I would not advise to do this as a long term solution. Another obvious thing to try is building the scipy's trunk, or re-generating the c++ sources from swig. The latter, by generating a different file, may be able to exercise another codepath in g++, and avoid the crash depending on where the crash happens in g++. Ideally, if you could find-out what part of the code causes the crash and report the bug, we may be able to implement a workaround in scipy. cheers, David From dvanliere at gmail.com Mon Mar 8 23:27:50 2010 From: dvanliere at gmail.com (Diederik van Liere) Date: Mon, 8 Mar 2010 23:27:50 -0500 Subject: [SciPy-User] Compiling scipy.sparse.sparsetools extension throws g++ internal error Message-ID: > Diederik van Liere wrote: >>* I need scipy.linalg although I prefer a complete working version of*>>* Scipy because it might the case the sparse module is required by one*>>* of other libraries I am suing.* > Indeed - not building scipy.sparse is clearly a temporary workaround, I > would not advise to do this as a long term solution. Another obvious > thing to try is building the scipy's trunk, or re-generating the c++ > sources from swig. The latter, by generating a different file, may be > able to exercise another codepath in g++, and avoid the crash depending > on where the crash happens in g++. Thanks David, I disable the sparse package and scipy builds fine (I am already using the latest SVN version of Scipy). However,when I import scipy.linalg I receive the following error in Python: ImportError: /usr/local/lib/python2.6/site-packages/scipy/linalg/clapack.so: undefined symbol: clapack_sgesv Which looks very similar to this bug report: http://projects.scipy.org/scipy/ticket/1031 I would like to give you more detailed information but I am not sure what you need / or how to provide that. > Ideally, if you could find-out what part of the code causes the crash > and report the bug, we may be able to implement a workaround in scipy. > cheers, > David PS: I hope this reply does not start a new thread, don't know how to prevent that. -------------- next part -------------- An HTML attachment was scrubbed... URL: From david at silveregg.co.jp Mon Mar 8 23:38:20 2010 From: david at silveregg.co.jp (David Cournapeau) Date: Tue, 09 Mar 2010 13:38:20 +0900 Subject: [SciPy-User] Compiling scipy.sparse.sparsetools extension throws g++ internal error In-Reply-To: References: Message-ID: <4B95D0BC.1060101@silveregg.co.jp> Diederik van Liere wrote: > > ImportError: /usr/local/lib/python2.6/site-packages/scipy/linalg/clapack.so: > undefined symbol: clapack_sgesv what is the output of python setup.py config inside scipy build ? Also, the output of ldd on clapack.so may be useful. David From dvanliere at gmail.com Tue Mar 9 00:06:49 2010 From: dvanliere at gmail.com (Diederik van Liere) Date: Tue, 9 Mar 2010 00:06:49 -0500 Subject: [SciPy-User] Compiling scipy.sparse.sparsetools extension throws g++ internal error Message-ID: > Diederik van Liere wrote: >>* *>>* ImportError: /usr/local/lib/python2.6/site-packages/scipy/linalg/clapack.so:*>>* undefined symbol: clapack_sgesv* > what is the output of python setup.py config inside scipy build ? I am not quite sure which output you mean, do you mean the console output or a particular log file? I didn't see any log file in particular. The console output does not give any errors as far as I can tell. Import scipy in python does work. > Also, the output of ldd on clapack.so may be useful. The output of ldd looks suspect (I compared it to other posts): ldd /usr/local/lib/python2.6/site-packages/scipy/lib/lapack/clapack.so libgfortran.so.1 => /usr/lib/libgfortran.so.1 (0x00b96000) libm.so.6 => /lib/libm.so.6 (0x00f41000) libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00552000) libc.so.6 => /lib/libc.so.6 (0x00110000) /lib/ld-linux.so.2 (0x00e8f000) However, Scipy does find the lapack, blas etc as this snippet from the log shows: atlas_threads_info: Setting PTATLAS=ATLAS libraries lapack_atlas not found in /usr/local/include numpy.distutils.system_info.atlas_threads_info Setting PTATLAS=ATLAS Setting PTATLAS=ATLAS FOUND: libraries = ['lapack', 'lapack', 'f77blas', 'cblas', 'atlas'] library_dirs = ['/usr/local/include'] language = f77 How can I prevent starting a new thread every time? Best, Diederik -------------- next part -------------- An HTML attachment was scrubbed... URL: From david at silveregg.co.jp Tue Mar 9 00:15:46 2010 From: david at silveregg.co.jp (David Cournapeau) Date: Tue, 09 Mar 2010 14:15:46 +0900 Subject: [SciPy-User] Compiling scipy.sparse.sparsetools extension throws g++ internal error In-Reply-To: References: Message-ID: <4B95D982.90300@silveregg.co.jp> Diederik van Liere wrote: >> Diederik van Liere wrote: > >>> * *>>* ImportError: /usr/local/lib/python2.6/site-packages/scipy/linalg/clapack.so:*>>* undefined symbol: clapack_sgesv* >> what is the output of python setup.py config inside scipy build ? > > I am not quite sure which output you mean, do you mean the console > output or a particular log file? I didn't see any log file in > particular. I meant the console output, yes, to see which BLAS/LAPACK is detected. > ldd /usr/local/lib/python2.6/site-packages/scipy/lib/lapack/clapack.so > libgfortran.so.1 => /usr/lib/libgfortran.so.1 (0x00b96000) > libm.so.6 => /lib/libm.so.6 (0x00f41000) > libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00552000) > libc.so.6 => /lib/libc.so.6 (0x00110000) > /lib/ld-linux.so.2 (0x00e8f000) This is indeed suspicious. How did you build your Atlas ? It would be useful to have the full build output when building scipy.linalg. > > However, Scipy does find the lapack, blas etc as this snippet from the log > shows: > > atlas_threads_info: > Setting PTATLAS=ATLAS > libraries lapack_atlas not found in /usr/local/include > numpy.distutils.system_info.atlas_threads_info > Setting PTATLAS=ATLAS > Setting PTATLAS=ATLAS > FOUND: > libraries = ['lapack', 'lapack', 'f77blas', 'cblas', 'atlas'] > library_dirs = ['/usr/local/include'] > language = f77 I don't know if this linked to our issue, but this PTATLAS=ATLAS seems a bit strange, I don't remember having seen it. > How can I prevent starting a new thread every time? It is a setting in your email client - are you using email or something else to post ? David From millman at berkeley.edu Tue Mar 9 00:29:28 2010 From: millman at berkeley.edu (Jarrod Millman) Date: Mon, 8 Mar 2010 21:29:28 -0800 Subject: [SciPy-User] PSF GSoC 2010 (Py3K focus) In-Reply-To: References: Message-ID: I added Titus' email regarding the PSF's focus on Py3K-related projects to our SoC ideas wiki page: http://projects.scipy.org/scipy/wiki/SummerofCodeIdeas Given Titus' email, this is the most likely list of projects we will get accepted this year: - finish porting NumPy to Py3K - port SciPy to Py3K - port matplotlib to Py3K - port ipython to Py3K Given that we know what projects we will likely have accepted, it is worth starting to flesh these proposals out in detail. Also, we should start discussing how we will choose which student's we want to work on these ports. In particular, we should list what skills and background will be necessary to successfully complete these ports. Thoughts? Ideas? Best, Jarrod From bsouthey at gmail.com Tue Mar 9 09:38:10 2010 From: bsouthey at gmail.com (Bruce Southey) Date: Tue, 09 Mar 2010 08:38:10 -0600 Subject: [SciPy-User] scipy+lapack array copy Message-ID: <4B965D52.9040708@gmail.com> On 8. mars 2010, at 10.10, Skipper Seabold wrote: > On Mon, Mar 8, 2010 at 12:47 PM, Paul Anton Letnes > gmail.com> wrote: >> Hi everyone. >> >> I have a numerical project where I link a fortran module to python using f2py. The fortran module basically sets up the left hand side coefficient matrix of a linear equation system. The right hand side is small, so I set that up in python. So far, everything works great. >> >> Now, when I call scipy-lapack, I am using: >> from scipy.linalg.lapack import flapack as lapack >> lu, piv, x, info = lapack.zgesv(A, b) >> A is created in the fortran part of the program. b is created from numpy.zeros(). Both report as F_CONTIGUOUS by printing A.flags and b.flags. >> >> The problem is that I'd like A to be large (>1GB), but the lapack wrapper (or lapack itself?) copies the array, doubling the memory use. Aside from being unnecessary, this also reduces the practical problem size I can solve by a factor 2, which of course is very annoying. >> >> How can I get around this problem? >> If memory usage is a concern then you can directly form the X.T*X matrix rather than doing the transpose and multiplication. The advantage is that X.T*X has a fixed dimensions regardless of the number of observations. Further, you can exploit symmetry and use half-storage (there are lapack routines). The disadvantage is that is more complex and probably not as fast as doing the multiplication. If numerical stability is a concern then you probably need to use a better solving than LU with partial pivoting anyhow. Bruce From dlenski at gmail.com Tue Mar 9 01:35:09 2010 From: dlenski at gmail.com (Daniel Lenski) Date: Tue, 9 Mar 2010 06:35:09 +0000 (UTC) Subject: [SciPy-User] fromimage/imread segfaults on my images References: <4B9556D0.9090409@noaa.gov> Message-ID: On Mon, 08 Mar 2010 11:58:08 -0800, Christopher Barker wrote: > Daniel Lenski wrote: >> I'm using SciPy to process some sparse binary images with a resolution >> of about 5000x5000 pixels. I try to load images like this: >> >> im = Image.open('/tmp/foo.pbm') >> print "Image loaded, size is %s and mode is %s." % (im.size, im.mode) >> arr = fromimage(im) >> >> or >> >> arr = imread('/tmp/foo.pbm') > > where do fromimage and imread come from? "namespaces are one honking > great idea". Whoops, sorry. Those are from scipy.misc. >> In either case, I get a segfault. The segfault is definitely in the >> SciPy code, rather than the PIL code, since PIL's Image.open runs fine. > > don't be so sure -- I think PIL used lazy loading, so it doesn't > actually read all the data with the open call, but rather when you try > to do something with it. > > I'd try making a few calls on the PIl image, and make sure it is what > you expect. If it is, the easiest way to get it into a numpy array is: Everything works fine as long as I stick with PIL calls only... I can even dump the entire contents of the image to a string with PIL.Image.fromstring(). No problems there. > np.asarray(pil_image) I looked at the code for scipy.misc.fromimage, and this is basically all it does. This is where the segfault occurs. > do you have a smaller image in the same format you can experiment with? > That might make it easier to figure out. Smaller images work fine. I haven't figured out exactly where the cutoff is, but 500x500 works fine, for instance. >> I don't know any other good, reliable way >> to get a big image into an array :-( > > if you really can't get PIL to work, pbm looks really simple: > > http://netpbm.sourceforge.net/doc/pbm.html > > read the header, then read the data with np.fromfile(), then convert to > a uint8 array with np.unpackbits(). That's what I've ended up doing... rolled my own loadpbm() function. > You could also take a look at MPL's imread() and see what it does -- I > don't think MPL requires PIL, though I could be wrong. MPL requires PIL to load and save images in formats /other than/ PNG. Dan From dlenski at gmail.com Mon Mar 8 22:26:14 2010 From: dlenski at gmail.com (Daniel Lenski) Date: Tue, 9 Mar 2010 03:26:14 +0000 (UTC) Subject: [SciPy-User] fromimage/imread segfaults on my images References: <4B9556D0.9090409@noaa.gov> Message-ID: On Mon, 08 Mar 2010 11:58:08 -0800, Christopher Barker wrote: > Daniel Lenski wrote: >> I'm using SciPy to process some sparse binary images with a resolution >> of about 5000x5000 pixels. I try to load images like this: >> >> im = Image.open('/tmp/foo.pbm') >> print "Image loaded, size is %s and mode is %s." % (im.size, im.mode) >> arr = fromimage(im) >> >> or >> >> arr = imread('/tmp/foo.pbm') > > where do fromimage and imread come from? "namespaces are one honking > great idea". Sorry! That'd be from scipy.misc import fromimage, imread > don't be so sure -- I think PIL used lazy loading, so it doesn't > actually read all the data with the open call, but rather when you try > to do something with it. > > I'd try making a few calls on the PIl image, and make sure it is what > you expect. If it is, the easiest way to get it into a numpy array is: True, PIL lazy-loads the image. However, I've checked this, and I'm able to manipulate the image via PIL with no problems. > np.asarray(pil_image) Yeah, I looked at the scipy.misc.fromimage code and this is all it does, basically. > do you have a smaller image in the same format you can experiment with? > That might make it easier to figure out. Yes, smaller images in the same format work fine! >> I don't know any other good, reliable way >> to get a big image into an array :-( > > if you really can't get PIL to work, pbm looks really simple: > > http://netpbm.sourceforge.net/doc/pbm.html > > read the header, then read the data with np.fromfile(), then convert to > a uint8 array with np.unpackbits(). That's what I've ended up doing... > You could also take a look at MPL's imread() and see what it does -- I > don't think MPL requires PIL, though I could be wrong. MPL does require PIL for formats other than PNG. Dan From e.antero.tammi at gmail.com Tue Mar 9 14:51:38 2010 From: e.antero.tammi at gmail.com (eat) Date: Tue, 9 Mar 2010 19:51:38 +0000 (UTC) Subject: [SciPy-User] Re: Seeking help/ advice for applying functions Message-ID: > > On 9 March 2010 09:59, eat gmail.com> wrote: > > Robert Kern gmail.com> writes: > > > >> > >> Your example is not very clear. Can you write a less cryptic one with > >> informative variable names and perhaps some comments about what each > >> part is doing? > >> > > Anne Archibald gmail.com> writes: Hi, I moved this thread from scipy-dev to scipy-user. First of all, Thanks Anne you clarified a lot. > > """ > > Hi, > > > > I have tried to clarify my code. First part is the relevant one, the rest is > > there just to provide some context to run some tests. > > The short answer is that no, there's no way to optimize what you're doing. > > The long answer is: when numpy and scipy are fast, they are fast > because they avoid running python code: if you add two arrays, there's > only one line of python code, and all the work is done by loops > written in C. If your code is calling many different python functions, > well, since they're python functions, to apply them at all you must > necessarily execute python code. There goes any potential speed > advantage. (There may be a convenience advantage; if so, you can look > into using np.vectorize, which is just a wrapper around a python loop, > but is convenient.) Not only that I'm new to Scipy/ Numpy but I'm new to python aswell. I think I assumed that once python functions get compiled they'll would be (almost) as efficient than builtins. > > That said, I assume you are considering numpy/scipy because you have > arrays of thousands or more. It also seems unlikely that you actually > have thousands of different functions (that's an awful lot of source > code!). So if your "different" functions are actually just a handful > (or fewer) pieces of actual code, and you are getting your thousands > of functions by wrapping them up with parameters and local variables, > well, now there are possibilities. Exactly what possibilities depend > on what your functions look like - which is one reason Robert Kern > asked you to clarify your code - but they all boil down to rearranging > the problem so that it goes back to "few functions, much data", then > writing the functions in such a way that you can use numpy to apply > them to thousands or millions of data points at once. Yes, indeed I don't have so many different 'base' functions, but just configured (parametrized) different ways. However there are situations when it's advantage to be able to treat your fuctions as 'black boxes'. For example when parametrization is based on optimization. Yes, I'll also recognize that my original question was too generic. I'll try to be more specific next time. > > > Also originally I should have posted this to Scipy-User list. Would it be > > more appropriate to continue the discussion there? > > Probably. > > Anne Thanks a lot, eat > > > Regards, > > eat > > """ > > > > import numpy as np > > > > ## relevant part are in scipy-dev From robert.kern at gmail.com Tue Mar 9 14:59:15 2010 From: robert.kern at gmail.com (Robert Kern) Date: Tue, 9 Mar 2010 13:59:15 -0600 Subject: [SciPy-User] Re: Seeking help/ advice for applying functions In-Reply-To: References: Message-ID: <3d375d731003091159u4151c737j65f4b2f2a7ca945@mail.gmail.com> On Tue, Mar 9, 2010 at 13:51, eat wrote: > Not only that I'm new to Scipy/ Numpy but I'm new to python aswell. > I think I assumed that once python functions get compiled they'll would be > (almost) as efficient than builtins. No, not at all. Python functions do not get compiled to machine code. They get compiled to Python bytecode, but that Python bytecode is interpreted. Python functions have tons of overhead compared to builtins. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From peridot.faceted at gmail.com Tue Mar 9 15:11:55 2010 From: peridot.faceted at gmail.com (Anne Archibald) Date: Tue, 9 Mar 2010 15:11:55 -0500 Subject: [SciPy-User] Re: Seeking help/ advice for applying functions In-Reply-To: References: Message-ID: On 9 March 2010 14:51, eat wrote: >> >> On 9 March 2010 09:59, eat gmail.com> wrote: >> > Robert Kern gmail.com> writes: >> > >> >> >> >> Your example is not very clear. Can you write a less cryptic one with >> >> informative variable names and perhaps some comments about what each >> >> part is doing? >> >> >> > > Anne Archibald gmail.com> writes: > > Hi, > > I moved this thread from scipy-dev to scipy-user. > > First of all, Thanks Anne you clarified a lot. > > >> > """ >> > Hi, >> > >> > I have tried to clarify my code. First part is the relevant one, the rest > is >> > there just to provide some context to run some tests. >> >> The short answer is that no, there's no way to optimize what you're doing. >> >> The long answer is: when numpy and scipy are fast, they are fast >> because they avoid running python code: if you add two arrays, there's >> only one line of python code, and all the work is done by loops >> written in C. If your code is calling many different python functions, >> well, since they're python functions, to apply them at all you must >> necessarily execute python code. There goes any potential speed >> advantage. (There may be a convenience advantage; if so, you can look >> into using np.vectorize, which is just a wrapper around a python loop, >> but is convenient.) > > Not only that I'm new to Scipy/ Numpy but I'm new to python aswell. > I think I assumed that once python functions get compiled they'll would be > (almost) as efficient than builtins. Not especially. They are compiled to bytecode, whose execution is not particularly fast. But the big problem is all the baggage of python's nature as a dynamic language: for example each value is allocated with malloc() and contains type information; for another example, each access to a list involves identifying that the object really is a list, dispatching to the list-lookup function, determining the type of the argument (integer, slice object, long integer, other), and bounds checking before finally returning the list element. Thus even tools like cython that let you write, effectively, python code that gets compiled to machine code are not much faster unless you can turn off the dynamic features of python (which cython lets you do, selectively; it's great). >> >> That said, I assume you are considering numpy/scipy because you have >> arrays of thousands or more. It also seems unlikely that you actually >> have thousands of different functions (that's an awful lot of source >> code!). So if your "different" functions are actually just a handful >> (or fewer) pieces of actual code, and you are getting your thousands >> of functions by wrapping them up with parameters and local variables, >> well, now there are possibilities. Exactly what possibilities depend >> on what your functions look like - which is one reason Robert Kern >> asked you to clarify your code - but they all boil down to rearranging >> the problem so that it goes back to "few functions, much data", then >> writing the functions in such a way that you can use numpy to apply >> them to thousands or millions of data points at once. > > Yes, indeed I don't have so many different 'base' functions, but just > configured (parametrized) different ways. However there are situations > when it's advantage to be able to treat your fuctions as 'black boxes'. > For example when parametrization is based on optimization. Think about whether you can write each 'base' function to take arrays as arguments, for example: def F(x, mu, sigma): return np.exp(-((x-mu)/sigma)**2) If your current code does something like fis = [lambda x: F(x, mui, sigmai) for (mui, sigmai) in zip(muis, sigmais)] r = [f(7) for f in fis] you can rewrite it as the single line r = F(7, muis, sigmais) (if muis and sigmais are numpy arrays). Now you have just a couple of lines of python, and the heavy lifting all happens inside numpy loops. If you have several different functions, look into separating your input arrays based on which function needs to be applied to them; remember numpy lets you select out all the elements of an array meeting a criterion. I realize this kind of rewriting will mess up a nice clean functional design, but as is often the case, that is the price you pay for performance. If your code works and is fast enough, I recommend leaving it as is. Anne From josef.pktd at gmail.com Tue Mar 9 16:01:31 2010 From: josef.pktd at gmail.com (josef.pktd at gmail.com) Date: Tue, 9 Mar 2010 16:01:31 -0500 Subject: [SciPy-User] return "full_output" or how to stop throwing away already calculated results Message-ID: <1cd32cbb1003091301m7fdd82e5je2cfcd6cf292d0ba@mail.gmail.com> scipy functions throw away a lot of intermediate results examples fmin_slsqp ticket:1129 scipy.linalg.lstsq throws away residuals : if n