[Numpy-discussion] The problem with arrays

yogesh karpate yogeshkarpate@gmail....
Wed Sep 23 00:07:15 CDT 2009


Dear Fabrice
                     Finally your suggestions worked :).....Thanks a lot...
soon the code I'm working will be available as a part of Free Software
Foundation.
Regards
Yogesh

On Tue, Sep 22, 2009 at 11:23 PM, Fabrice Silva <silva@lma.cnrs-mrs.fr>wrote:

> Le mardi 22 septembre 2009 à 23:00 +0530, yogesh karpate a écrit :
>
> > This is the main thing . When I try to store it in array like
> > R_time=array([R_t[0][i]]). It just stores the final value in that
> > array when loop ends.I cant get out of this For loop.I really have
> > this small problem. I really need help on this guys.
> >
> >         for i in range(a1):
> >                 data_temp=(bpf[left[0][i]:
> >         right[0][i]])# left is an array and right is also an array
> >                 maxloc=data_temp.argmax()       #taking indices of
> >         max. value of data segment
> >                 maxval=data_temp[maxloc]
> >                 minloc=data_temp.argmin()
> >                 minval=data_temp[minloc]
> >                 maxloc = maxloc-1+left # add offset of present
> >         location
> >                 minloc = minloc-1+left # add offset of present
> >         location
> >                 R_index = maxloc
> >                 R_t = t[maxloc]
> >                 R_amp = array([maxval])
> >                 S_amp = minval#%%% Assuming the S-wave is the lowest
> >                 #%%% amp in the given window
> >                 #S_t = t[minloc]
> >                 R_time=array([R_t[0][i]])
> >                 plt.plot(R_time,R_amp,'go');
> >                 plt.show()
>
> Two options :
> - you define an empty list before the loop
>        >>> R_time = []
>  and you append the computed value while looping
>        >>> for i:
>        >>>     ...
>        >>>     R_time.append(t[maxloc])
>
> - or you define a preallocated array before the loop
>        >>> R_time = np.empty(a1)
>  and fill it with the computed values
>        >>> for i:
>        >>>     ...
>        >>>     R_time[i] = t[maxloc]
>
>
> Same thing with R_amp. After looping, whatever the solution you choose,
> you can plot  the whole set of (time, value) tuples
>        >>> plt.plot(R_time, R_amp)
>
> --
> Fabrice Silva <silva@lma.cnrs-mrs.fr>
> LMA UPR CNRS 7051
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20090923/9401303b/attachment.html 


More information about the NumPy-Discussion mailing list