|
From: Sudheer J. <sud...@ya...> - 2013-02-21 01:22:40
|
Thank you very much Smith and Paul,
I was away from office due to a medical situation. So could not respond and thank you regarding the help. I have got the results now and the tips from both of you were extremely useful. I am facing an issue with the code when I call plt.xcorr, in a loop. it builds up usage of memory by python and reaches to the RAM what ever available ( in my 4 GB laptop it reaches almost full and in my 24 GB desktop it reaches the available. I suspected the plot not being closed during each iteration so have given a plt.close('all') in the loop. after which it is taking a good time to run the code which was otherwise faster until ram usage reaches its maximum.
Is there a way to get out of this situation?. I am attaching the code here and also the link to the data I am using. If possible kindly help.
ftp ftpser.incois.gov.in
user temp
password incoistemp
cd /home0/temp/comp
bin
mget qu_test.nc.gz gunzip qu_test.nc.gz
***************************************************************
Sudheer Joseph
Indian National Centre for Ocean Information Services
Ministry of Earth Sciences, Govt. of India
POST BOX NO: 21, IDA Jeedeemetla P.O.
Via Pragathi Nagar,Kukatpally, Hyderabad; Pin:5000 55
Tel:+91-40-23886047(O),Fax:+91-40-23895011(O),
Tel:+91-40-23044600(R),Tel:+91-40-9440832534(Mobile)
E-mail:sjo...@gm...;sud...@ya...
Web- http://oppamthadathil.tripod.com
***************************************************************
________________________________
From: Sterling Smith <sm...@fu...>
To: Sudheer Joseph <sud...@ya...>
Cc: Paul Hobson <pmh...@gm...>; "mat...@li..." <mat...@li...>
Sent: Friday, 8 February 2013 10:23 PM
Subject: Re: [Matplotlib-users] cross correlation
Sudheer,
For the documentation you are looking for
print ax1.xcorr.__doc__
(Paul tried to give you the IPython method of getting that documentation which is by typing a ? (or ??) after the desired object.)
In the documentation (at the link you gave http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.xcorr), it says that there are three objects returned by xcorr:
Return value is a tuple (*lags*, *c*, *line*) where:
- *lags* are a length ``2*maxlags+1`` lag vector
- *c* is the ``2*maxlags+1`` auto correlation vector
- *line* is a :class:`~matplotlib.lines.Line2D` instance
returned by :func:`~matplotlib.pyplot.plot`.
So the error you were getting is due to the fact that you have only specified two variables to hold the three returned objects.
Try:
lags,c,line = ax1.xcorr .....
(Note that you have xcorr and lags backwards in your attempt.)
-Sterling
On Feb 8, 2013, at 1:56AM, Sudheer Joseph wrote:
> Thank you verymuch Hobson,
> However I think I did not understand the suggestion by you fully( pardon my ignorance). I use the below test code from matplotlib site. How does one make a call to get lags and correlation corresponding to the x and y values in the plot. a Print command of
> In [23]: print ax1.xcorr
> <bound method AxesSubplot.xcorr of <matplotlib.axes.AxesSubplot object at 0x44c1410>>
> results as above. Is it possible to assign the xcorr,lags=ax1.xcorr(x, y, usevlines=True, maxlags=50, normed=True, lw=2) ? with a different syntax? I get below error when I try the above .
> In [27]: xcorr,lags=ax1.xcorr(x, y, usevlines=True, maxlags=50, normed=True, lw=2)
> ---------------------------------------------------------------------------
> ValueError Traceback (most recent call last)
> /home/sjo/work/PY_WORK/stats/<ipython-input-27-e1e58c045ad4> in <module>()
> ----> 1 xcorr,lags=ax1.xcorr(x, y, usevlines=True, maxlags=50, normed=True, lw=2)
>
> ValueError: too many values to unpack
>
>
>
> import matplotlib.pyplot as plt
> import numpy as np
> x,y = np.random.randn(2,100)
> fig = plt.figure()
> ax1 = fig.add_subplot(211)
> ax1.xcorr(x, y, usevlines=True, maxlags=50, normed=True, lw=2)
> ax1.grid(True)
> ax1.axhline(0, color='black', lw=2)
> ax2 = fig.add_subplot(212, sharex=ax1)
> ax2.acorr(x, usevlines=True, normed=True, maxlags=50, lw=2)
> ax2.grid(True)
> ax2.axhline(0, color='black', lw=2)
> plt.show()
>
>
> From: Paul Hobson <pmh...@gm...>
> To: Sudheer Joseph <sud...@ya...>
> Cc: "mat...@li..." <mat...@li...>
> Sent: Thursday, 7 February 2013 10:31 PM
> Subject: Re: [Matplotlib-users] cross correlation
>
>
>
>
> On Thu, Feb 7, 2013 at 3:24 AM, Sudheer Joseph <sud...@ya...> wrote:
> Dear Users,
> I am relatively new to Matplotlib. I wanted to find cross correlation between 2 time series for my research and was looking at options available with python and found http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.xcorr . However I wanted to save the results in a netcdf file for further use. ie the correlation, lags and significance if possible. Is there a way to get the corr and lags from the axis.xcorr ?? any help in this matter will be greatly appreciated.
> Sudheer
>
> Sudheer,
>
> A call to axes.xcorr returns the lags, correlation (from np.correlate) and the line artists on the figure.
>
> In IPython, doing "plt.xcorr??" should provide sufficient information. It's a pretty simple method.
> -paul
>
>
> ------------------------------------------------------------------------------
> Free Next-Gen Firewall Hardware Offer
> Buy your Sophos next-gen firewall before the end March 2013
> and get the hardware for free! Learn more.
> http://p.sf.net/sfu/sophos-d2d-feb_______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users |