[SciPy-user] lambda forms?

Emanuele Zattin emanuelez@gmail....
Thu Jun 28 09:38:19 CDT 2007


hmmm.... then it must be something else in the optimization part...

In [23]: run cutoff
---------------------------------------------------------------------------
<type 'exceptions.ValueError'>            Traceback (most recent call last)

/home/emanuelez/Tesi/Code/cutoff.py in <module>()
    175 # FIND OBJECTS PROPERTIES
    176 # -----------------------
--> 177 get_objects_info(blurred, 2, obj_x, obj_y, obj_v)
    178
    179

/home/emanuelez/Tesi/Code/cutoff.py in get_objects_info(image, size,
obj_x, obj_y, obj_v)
    144                 #for indices in max_list:
    145                 ml = array(max_list)
--> 146                 params = fitgaussian(neigh, obj_x[ml],
obj_y[ml], obj_v[ml])
    147                 print len(max_list), params
    148

/home/emanuelez/Tesi/Code/cutoff.py in fitgaussian(data, obj_x, obj_y, obj_v)
    125     errorfunction = lambda p: ravel(gaussian(*p)(*indices(data.shape)) -
    126                                  data)
--> 127     p, success = leastsq(errorfunction, params)
    128     return p
    129

/usr/lib/python2.5/site-packages/scipy/optimize/minpack.py in
leastsq(func, x0, args, Dfun, full_output, col_deriv, ftol, xtol,
gtol, maxfev, epsfcn, factor, diag)
    264         if (maxfev == 0):
    265             maxfev = 200*(n+1)
--> 266         retval =
_minpack._lmdif(func,x0,args,full_output,ftol,xtol,gtol,maxfev,epsfcn,factor,diag)
    267     else:
    268         if col_deriv:

<type 'exceptions.ValueError'>: object too deep for desired array
WARNING: Failure executing file: <cutoff.py>


On 6/28/07, dmitrey <openopt@ukr.net> wrote:
> works for me
> (however, I used 1-line:
>
> return lambda x,y:sum(height*exp(-(((center_x-x)/width)**2+((center_y-y)/width)**2)/2))
>
> )
> HTH, D
>
> Emanuele Zattin wrote:
> > Hello,
> > i'm trying to define a function to calculate the sum of some gaussian
> > given their paramers. Something like:
> >
> > def gaussian(height, center_x, center_y, width):
> >     """Returns a gaussian function with the given parameters"""
> >     width = float(width)
> >     return lambda x,y:
> > sum(height*exp(-(((center_x-x)/width)**2+((center_y-y)/width)**2)/2))
> >
> > where all the parameters are arrays of the same length (the length is variable).
> > This version of course does not work, but i wonder if it is still
> > possible using lambda forms or if i have to write the function in an
> > explicit way.
> >
> > Emanuele
> > _______________________________________________
> > SciPy-user mailing list
> > SciPy-user@scipy.org
> > http://projects.scipy.org/mailman/listinfo/scipy-user
> >
> >
> >
> >
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user@scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>


More information about the SciPy-user mailing list