[SciPy-user] scale arrays with interpolation

Fabian Braennstroem f.braennstroem at gmx.de
Sun Sep 14 05:29:04 EDT 2008


Hi Alex,

* Alex Liberzon <alex.liberzon at gmail.com> wrote:
> Hi Fabian
>
> Fortunately, I'm from the same field so I think I understand what you're 
> talking about :-) 

I hope it was not too confusing...

> If I translate your wish is::
> a) find the location and the value of the maximum of the y_array => 
> local_max
> b) half_width is the x_array value at the position of the maximum of y_array
>
> If this is true, then you'd better use numpy arrays and not lists:
> # starting from your lists:
>  x_array = asarray(x_array).astype('f') # array of floats
>  y_array = asarray(y_array).astype('f')
>
> half_width = x_array[argmax(y_array)]
>
> scaled_x_array = x_array/half_width
> scaled_y_array = y_array/max(y_array)
>
> plot(scaled_x_array,scaled_y_array,'o')

Thanks! This is a good way with a lot of elements, but I
think, if one does this with just a few elements in the
numpy array, one has to do some kind of interpolation, to
find the 'exact'
half_width!?

Regards!
 Fabian




More information about the SciPy-User mailing list