Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #37496

Re: Memory error with quadratic interpolation

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <winefrog@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'elements.': 0.05; 'error:': 0.05; 'skip:" 60': 0.05; 'indices': 0.07; 'python': 0.09; '"r")': 0.09; '22,': 0.09; '__init__': 0.09; 'advice.': 0.09; 'skip:" 80': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.10; 'subject:error': 0.11; 'files.': 0.13; 'adjusted': 0.16; 'advice:': 0.16; 'benjamin': 0.16; 'cc:name:python list': 0.16; 'code?': 0.16; 'columns': 0.16; 'numpy': 0.16; 'wrote:': 0.17; 'code.': 0.20; 'import': 0.21; 'supposed': 0.21; 'subject:skip:i 10': 0.22; 'wednesday,': 0.22; 'skip:_ 20': 0.22; "i've": 0.23; 'tried': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; '(most': 0.27; 'cc:addr:gmail.com': 0.27; 'used,': 0.27; 'cc:2**2': 0.27; "doesn't": 0.28; 'received:209.85.212': 0.28; 'run': 0.28; 'arrays': 0.29; 'skip:_ 10': 0.29; 'probably': 0.29; 'function': 0.30; 'error': 0.30; 'code': 0.31; 'problem.': 0.32; 'file': 0.32; 'running': 0.32; 'could': 0.32; 'skip:s 30': 0.33; 'traceback': 0.33; 'problem': 0.33; '(with': 0.33; 'version': 0.34; 'agree': 0.34; 'received:google.com': 0.34; 'list': 0.35; 'so,': 0.35; 'received:209.85': 0.35; 'really': 0.36; 'subject:with': 0.36; 'test': 0.36; 'should': 0.36; 'thank': 0.36; 'skip:p 20': 0.36; 'possible': 0.37; 'received:209': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'skip:l 20': 0.38; 'gives': 0.39; 'where': 0.40; 'help': 0.40; 'your': 0.60; 'you.': 0.61; 'first': 0.61; 'kind': 0.61; 'solve': 0.62; 'skip:n 10': 0.63; 'more': 0.63; 'show': 0.63; 'here': 0.65; '2013': 0.84; 'isaac': 0.84; 'oscar': 0.84; 'was:': 0.91; 'hundred': 0.95; 'won': 0.96
X-Received by 10.50.37.242 with SMTP id b18mr5588407igk.6.1358962412327; Wed, 23 Jan 2013 09:33:32 -0800 (PST)
Newsgroups comp.lang.python
Date Wed, 23 Jan 2013 09:33:31 -0800 (PST)
In-Reply-To <mailman.910.1358959906.2939.python-list@python.org>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=129.118.224.160; posting-account=DOyQBwoAAADIEpwWr89vk1x7RGFM33oc
References <0909ee56-c304-4b9d-8be9-97c7a3261d27@googlegroups.com> <j4l4t9-skt.ln1@satorlaser.homedns.org> <mailman.880.1358935694.2939.python-list@python.org> <8daf86cf-386c-44ae-83d5-25fb04572c00@googlegroups.com> <mailman.898.1358952056.2939.python-list@python.org> <a5662c8c-67c3-47e6-a8b7-2eddbc272657@googlegroups.com> <mailman.910.1358959906.2939.python-list@python.org>
User-Agent G2/1.0
X-Google-Web-Client true
X-Google-IP 129.118.224.160
MIME-Version 1.0
Subject Re: Memory error with quadratic interpolation
From Isaac Won <winefrog@gmail.com>
To comp.lang.python@googlegroups.com
Content-Type text/plain; charset=ISO-8859-1
Cc Isaac Won <winefrog@gmail.com>, Python List <python-list@python.org>, Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Message-ID <mailman.914.1358962421.2939.python-list@python.org> (permalink)
Lines 169
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1358962421 news.xs4all.nl 6971 [2001:888:2000:d::a6]:46311
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:37496

Show key headers only | View raw


On Wednesday, January 23, 2013 10:51:43 AM UTC-6, Oscar Benjamin wrote:
> On 23 January 2013 14:57, Isaac Won <winefrog@gmail.com> wrote:
> 
> > On Wednesday, January 23, 2013 8:40:54 AM UTC-6, Oscar Benjamin wrote:
> 
> >> On 23 January 2013 14:28, Isaac Won <winefrog@gmail.com> wrote:
> 
> >>
> 
> [SNIP]
> 
> >
> 
> > Following is full error message after I adjusted following Ulich's advice:
> 
> >
> 
> > interp = interp1d(indices[not_nan], x[not_nan], kind = 'quadratic')
> 
> > File "/lustre/work/apps/python-2.7.1/lib/python2.7/site-packages/scipy/interpolate/interpolate.py", line 311, in __init__
> 
> >      self._spline = splmake(x,oriented_y,order=order)
> 
> >   File "/lustre/work/apps/python-2.7.1/lib/python2.7/site-packages/scipy/interpolate/interpolate.py", line 809, in splmake
> 
> >      coefs = func(xk, yk, order, conds, B)
> 
> >   File "/lustre/work/apps/python-2.7.1/lib/python2.7/site-packages/scipy/interpolate/interpolate.py", line 530, in _find_smoothest
> 
> >      u,s,vh = np.dual.svd(B)
> 
> >   File "/lustre/work/apps/python-2.7.1/lib/python2.7/site-packages/scipy/linalg/decomp_svd.py", line 91, in svd
> 
> >      full_matrices=full_matrices, overwrite_a = overwrite_a)
> 
> > MemoryError
> 
> 
> 
> Where is the new code? You should show full working code (with the
> 
> import statements) and the full error that is generated by exactly
> 
> that code. If possible you should also write code that someone else
> 
> could run even without having access to your data files. If you did
> 
> that in your first post, you'd probably have an answer to your problem
> 
> by now.
> 
> 
> 
> Here is a version of your code that many people on this list can test
> 
> straight away:
> 
> 
> 
> import numpy as np
> 
> from scipy.interpolate import interp1d
> 
> x = np.array(31747 * [0.0], float)
> 
> indices = np.arange(len(x))
> 
> interp = interp1d(indices, x, kind='quadratic')
> 
> 
> 
> Running this gives the following error:
> 
> 
> 
> ~$ python tmp.py
> 
> Traceback (most recent call last):
> 
>   File "tmp.py", line 5, in <module>
> 
>     interp = interp1d(indices, x, kind='quadratic')
> 
>   File "/usr/lib/python2.7/dist-packages/scipy/interpolate/interpolate.py",
> 
> line 308, in __init__
> 
>     self._spline = splmake(x,oriented_y,order=order)
> 
>   File "/usr/lib/python2.7/dist-packages/scipy/interpolate/interpolate.py",
> 
> line 805, in splmake
> 
>     B = _fitpack._bsplmat(order, xk)
> 
> MemoryError
> 
> 
> 
> Unless I've misunderstood how this function is supposed to be used, it
> 
> just doesn't really seem to work for arrays of much more than a few
> 
> hundred elements.
> 
> 
> 
> 
> 
> Oscar

Thank you Oscar for your help and advice.

I agree with you. So, I tried to find the way to solve this problem.

My full code adjusted is:
from scipy.interpolate import interp1d

import numpy as np
import matplotlib.pyplot as plt



with open(filin, "r") as f:

        for line in f:
                columns = line.strip().split()

                a.append(columns[5])
                x = np.array(a, float)


not_nan = np.logical_not(np.isnan(x))
indices = np.arange(len(x))
interp = interp1d(indices[not_nan], x[not_nan], kind = 'quadratic')

p = interp(indices)




k = np.arange(31747)

plt.subplot(211)
plt.plot(k, p)
plt.xlabel('Quadratic interpolation')
plt.subplot(212)
plt.plot(k, x)

plt.show()
-----------------------------------------------------------------
Whole error message was:

Traceback (most recent call last):
  File "QI1.py", line 22, in <module>
    interp = interp1d(indices[not_nan], x[not_nan], kind = 'quadratic')
  File "/lustre/work/apps/python-2.7.1/lib/python2.7/site-packages/scipy/interpolate/interpolate.py", line 311, in __init__
    self._spline = splmake(x,oriented_y,order=order)
  File "/lustre/work/apps/python-2.7.1/lib/python2.7/site-packages/scipy/interpolate/interpolate.py", line 809, in splmake
    coefs = func(xk, yk, order, conds, B)
  File "/lustre/work/apps/python-2.7.1/lib/python2.7/site-packages/scipy/interpolate/interpolate.py", line 530, in _find_smoothest
    u,s,vh = np.dual.svd(B)
  File "/lustre/work/apps/python-2.7.1/lib/python2.7/site-packages/scipy/linalg/decomp_svd.py", line 91, in svd
    full_matrices=full_matrices, overwrite_a = overwrite_a)
MemoryError
----------------------------------------------------------------------
Thank you again Oscar,

Isaac

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Memory error with quadratic interpolation Isaac Won <winefrog@gmail.com> - 2013-01-22 20:06 -0800
  Re: Memory error with quadratic interpolation Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2013-01-23 09:55 +0100
    Re: Memory error with quadratic interpolation Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-01-23 10:08 +0000
      Re: Memory error with quadratic interpolation Isaac Won <winefrog@gmail.com> - 2013-01-23 06:26 -0800
      Re: Memory error with quadratic interpolation Isaac Won <winefrog@gmail.com> - 2013-01-23 06:26 -0800
      Re: Memory error with quadratic interpolation Isaac Won <winefrog@gmail.com> - 2013-01-23 06:28 -0800
        Re: Memory error with quadratic interpolation Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-01-23 14:40 +0000
          Re: Memory error with quadratic interpolation Isaac Won <winefrog@gmail.com> - 2013-01-23 06:57 -0800
            Re: Memory error with quadratic interpolation Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-01-23 16:51 +0000
              Re: Memory error with quadratic interpolation Isaac Won <winefrog@gmail.com> - 2013-01-23 09:33 -0800
                Re: Memory error with quadratic interpolation Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-01-24 10:30 +0000
              Re: Memory error with quadratic interpolation Isaac Won <winefrog@gmail.com> - 2013-01-23 09:33 -0800
          Re: Memory error with quadratic interpolation Isaac Won <winefrog@gmail.com> - 2013-01-23 06:57 -0800
      Re: Memory error with quadratic interpolation Isaac Won <winefrog@gmail.com> - 2013-01-23 06:28 -0800
    Re: Memory error with quadratic interpolation Isaac Won <winefrog@gmail.com> - 2013-01-23 06:47 -0800
  Re: Memory error with quadratic interpolation Isaac Won <winefrog@gmail.com> - 2013-01-23 06:24 -0800

csiph-web