Benjamin | 9 Feb 18:37
Picon
Favicon
Gravatar

[F2py] basic help

I have a fortran 77 code (which I did not write, but currently runs fine) and I
would like to create a 'front end' for it with python. As a first step, I would
like to simply be able to call this fortran code from python (ideally it would
just be one call and I pass in the input as paramaters).

Based on the user guide (http://cens.ioc.ee/projects/f2py2e/usersguide/) section
2.1 'the quick way' I have entered the command:
f2py -c *.f -m slab

but I get errors. The output is really long so I won't post it here, but it
looks like it does fine until it tries to compile the code. Some errors/warnings
are at the bottom of this post. Note that the only changes I made to the main
fortran program was making it a subroutine and passing the input as parameters.
I was hoping this would be fairly trivial for me, like it was for this guy:
http://moo.nac.uci.edu/~hjm/fd_rrt1d/index.html

Any advice is appreciated.
Ben

446   if (biz.gt.3.75) go to 148                                        
   1
Warning: Label 446 at (1) defined but not used
gfortran:f77: slab.f
Warning: Nonconforming tab character in column 1 of line 221

slab.h:13.24:
    Included at slab.f:14:

           parameter(mm=vm*im*jm)                                       
                        1
(Continue reading)

Eirik Gjerløw | 9 Feb 10:54
Picon
Picon
Gravatar

Numpy array slicing

Hello, this is (I think) a rather basic question about numpy slicing. I 
have the following code:

In [29]: a.shape
Out[29]: (3, 4, 12288, 2)

In [30]: mask.shape
Out[30]: (3, 12288)

In [31]: mask.dtype
Out[31]: dtype('bool')

In [32]: sum(mask[0])
Out[32]: 12285

In [33]: a[[0] + [slice(None)] + [mask[0]] + [slice(None)]].shape
Out[33]: (12285, 4, 2)

My question is: Why is not the final shape (4, 12285, 2) instead of 
(12285, 4, 2)?

Eirik Gjerløw
Andreas H. | 9 Feb 13:52
Picon

ask.scipy.org registration not working

Hi,

I'm running Chromium 16.0.912.77 (Developer Build 118311 Linux) Ubuntu
10.04. When registering for ask.scipy.org, I always get the error message
"You entered an invalid captcha". However, I don't see any captcha where I
could enter anything. The ReCaptcha widget is just not shown.

Trying the same with Opera/9.80 (X11; Linux x86_64; U; en) Presto/2.9.168
Version/11.52, I do see the ReCaptcha widget. However, when I enter a
correct captcha and click "Register", I'm running into some sort of
timeout after about a minute or two. The error message is

   Proxy Error
   The proxy server received an invalid response from an upstream server.
   The proxy server could not handle the request POST /login.
   Reason: Error reading from remote server
   Apache/2.2.3 (CentOS) Server at ask.scipy.org Port 80

Cheers,
Andreas.
Tyler | 8 Feb 00:58
Picon
Gravatar

Repeated measures scipy.stats support?

I have the following question, and am wondering if its possible to solve using existing scipy.stats, or anything else that anyone knows about =)

If I have n subjects that I have an Active-Control measurement for, for instance "(Minutes it takes to complete 1st lap) - (Minutes it takes to complete second lap)", an each subject runs 1-4 times, how do I properly calculate a p value for "Is one lap faster than the other?"

Example data:
Subject#       1stLap-2ndLap Minutes
1                     .3
1                     -.1
2                     .2
2                     .4
2                     -.3
3                     .6
4                     .2
4                     -.2
4                     .1
4                     .6
5                     .5
5                     -.4
6                     .2
6                     .1

      -Thanks a million
           -Tyler

_______________________________________________
SciPy-User mailing list
SciPy-User <at> scipy.org
http://mail.scipy.org/mailman/listinfo/scipy-user
suzana8447 | 7 Feb 15:39
Picon
Gravatar

[SciPy-user] How to use Least square fit to fit three functions


Hello, 

I would really appreciate if someone suggest me how to use least square fit
(scipy) to fit three functions at the same time because i looked at the
website site of scipy-least square:

http://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.leastsq.html
http://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.leastsq.html 

and I realized that lesatsq takes only one function as an argument. Is there
any way to let leastsq fit three functions for example?

Thanks in advance.
--

-- 
View this message in context: http://old.nabble.com/How-to-use-Least-square-fit-to-fit-three-functions-tp33278985p33278985.html
Sent from the Scipy-User mailing list archive at Nabble.com.
Pappu Kumar | 7 Feb 11:43
Picon
Favicon
Gravatar

Fitting Differential Equations to a Curve

I am trying to fit the differential equation ay' + by''=0 to a curve by varying a and b The following code does not work:

from scipy.integrate import odeint
from scipy.optimize import curve_fit
from numpy import linspace, random, array

time = linspace(0.0,10.0,100)
def deriv(time,a,b):
    dy=lambda y,t : array([ y[1], a*y[0]+b*y[1] ])
    yinit = array([0.0005,0.2]) # initial values
    Y=odeint(dy,yinit,time)
    return Y[:,0]

z = deriv(time, 2, 0.1)
zn = z + 0.1*random.normal(size=len(time))

popt, pcov = curve_fit(deriv, time, zn)
print popt # it only outputs the initial values of a, b!
_______________________________________________
SciPy-User mailing list
SciPy-User <at> scipy.org
http://mail.scipy.org/mailman/listinfo/scipy-user
Fabien Lafont | 7 Feb 11:43
Picon

[scipy-user] How to use genfromtext() with np.array?

I've saved a np.array in a file using write(). Ihave then a file with
my np.array over 8 columns and I can't load it using genfromtext to
load at the same time the entire array. It seems genfromtext doesn't
"see" the array as a real array but as 8 different columns. Is it
possible to load the array easily with genfromtext, or save my array
in a different way. It works with a for loop over each indices of the
array with + "\n" but it's not very convenient.

Thx,

Fabien
federico vaggi | 7 Feb 10:18
Picon
Gravatar

From Delaunay edges to spatial points

Hello,

I am a relative newbie to tessellation, so I might be asking a very naive question.  I have an unweighted graph (list of nodes, edge lists) that I would like to plot on the surface of a sphere.

Given the edge list, is there a way to come up with a x,y,z position of all the nodes so that they follow a Delaunay tessellation?  Most software I've seen starts from positions in space and then tries to obtain the edge list - I'd like to do the inverse, if possible.

I am not 100% sure if this is more appropriate for the scipy mailing list or the networkx mailing list, so I think I'll post it in both places as long as that's not frowned upon.

Thank you very much,

Fede

_______________________________________________
SciPy-User mailing list
SciPy-User <at> scipy.org
http://mail.scipy.org/mailman/listinfo/scipy-user
Conrad Lee | 5 Feb 16:05
Picon
Gravatar

Can I copy a sparse matrix into an existing dense numpy matrix?

Say I have a huge numpy matrix A taking up tens of gigabytes. It takes a non-negligible amount of time to allocate this memory.

Let's say I also have a collection of scipy sparse matrices with the same dimensions as the numpy matrix. Sometimes I want to convert one of these sparse matrices into a dense matrix to perform some vectorized operations that can't be performed on sparse matrices.

Can I load one of these sparse matrices into A rather than re-allocate space each time I want to convert a sparse matrix into a dense matrix? The .toarray() and .todense() methods which are available on scipy sparse matrices do not seem to take an optional dense array argument, but maybe there is some other way to do this.

(I've also started a stackoverflow version of this question here.)

Thanks,

Conrad lee

_______________________________________________
SciPy-User mailing list
SciPy-User <at> scipy.org
http://mail.scipy.org/mailman/listinfo/scipy-user
nicky van foreest | 5 Feb 00:12
Picon
Gravatar

scipy.stats.poisson, strange output?

Hi,

I used two types of poisson, and obtained different results. Specifically:

In [1]: from scipy.stats import poisson

In [2]: import numpy as np

In [3]: grid = np.arange(20)

In [4]: rv = poisson(10)

In [5]: print rv.pmf(grid)
[  4.53999298e-05   4.53999298e-04   2.26999649e-03   7.56665496e-03
   1.89166374e-02   3.78332748e-02   6.30554580e-02   9.00792257e-02
   1.12599032e-01   1.25110036e-01   1.25110036e-01   1.13736396e-01
   9.47803301e-02   7.29079462e-02   5.20771044e-02   3.47180696e-02
   2.16987935e-02   1.27639962e-02   7.09110899e-03   3.73216263e-03]

In [6]: print poisson.pmf(10., grid)
[             nan   1.01377712e-07   3.81898506e-05   8.10151179e-04
   5.29247668e-03   1.81327887e-02   4.13030934e-02   7.09832687e-02
   9.92615338e-02   1.18580076e-01   1.25110036e-01   1.19378060e-01
   1.04837256e-01   8.58701508e-02   6.62818432e-02   4.86107508e-02
   3.40976998e-02   2.29995844e-02   1.49851586e-02   9.46624674e-03]

In [7]:

So, in line [5], rv.pmf(grid)[0] is a number, while in [6],
poisson.pmf(10,grid)[0] is nan. Am I doing something wrong, or is this
an unintentional inconsistency?

Nicky
Dan Richards | 4 Feb 11:48
Picon
Favicon

scipy.spatial.Delaunay.convex_hull problelm

Hi All,

 

I have been using scipy to find the Delaunay tetrahedron of a set of points in three-dimensions. However, now I wish to only generate the external faces of the tetrahedron. I assume this can be done using scipy.spatial.Delaunay.convex_hull?

 

For my three-dimensional tetrahedron I am using this:

 

import scipy

from scipy import spatial

 

Points = ([x1,y1,z1], [x2,y2,z2]...[xn,yn,zn])

Del = scipy.spatial.Delaunay(Points)

 

faces = []

v = x.vertices

for i in xrange(x.nsimplex):

    faces.extend([

        (v[i,0],v[i,1],v[i,2]),

        (v[i,1],v[i,3],v[i,2]),

        (v[i,0],v[i,3],v[i,1]),

        (v[i,0],v[i,2],v[i,3]),])

 

for i in faces:

    MakeLines(i[0],i[1],i[2])

 

This allows me to create a three-dimensional tetragedron. I had thought to find the 3D convex hull could simply change either:  “v = x.verticies” into “v=x.convex_hull” ; or “Del =  scipy.spatial.Delaunay (Points)” into “Del = scipy.spatial.Delaunay.convex_hull(Points)”.However, neither of these have worked as planned?

 

If anyone is able to give me some advice or simply point me in the right direction that would be much appreciated.

 

Thanks,

Dan

 

"Before acting on this email or opening any attachments you should read the Manchester Metropolitan University email disclaimer available on its website http://www.mmu.ac.uk/emaildisclaimer "
_______________________________________________
SciPy-User mailing list
SciPy-User <at> scipy.org
http://mail.scipy.org/mailman/listinfo/scipy-user

Gmane