473,383 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

MemoryError in python

When I tried to calculate two-dimensional FFT of the array with 4096*4096 elements by using 64bit Windows XP with 64GB,
I ran into the Memoryerror althogh the usage of memory was less than 1GB.

I am wondering whether python has the upper limit memory usage.
Even if so, I don't know how to set the upper limit memory usage.

I showed you my code as follows.

Could you help me, please ?

-------------------------------------------------------
Expand|Select|Wrap|Line Numbers
  1.  
  2. #!/usr/bin/env python
  3. # -*- coding: utf-8 -*-
  4.  
  5. if __name__ == '__main__':
  6.     pass
  7.  
  8. import scipy 
  9. import scipy.io
  10. import scipy.fftpack
  11. import scipy.stats
  12. import pylab 
  13. import random
  14. import os
  15. import math
  16. import cmath
  17.  
  18. h=   2.46342852e-03  # rms of height
  19. size_mesh = 1.0 
  20. l=   85.16152053/math.sqrt(2.0)*80.0/512/size_mesh 
  21. N=    512
  22. L=    512 
  23.  
  24. F = scipy.zeros((N,N),dtype=scipy.complex128 )
  25.  
  26.  
  27. for I in scipy.arange(0,N-1,1):
  28.     for J in scipy.arange(0,N-1,1):
  29.         Kx=2.0*math.pi*I/L
  30.         Ky=2.0*math.pi*J/L
  31.         if (I == 0) or (I == N/2) or (J == 0) or (J == N/2):
  32.             rdm_number= random.gauss(0,1)
  33.         else:
  34.             rdm_number= (random.gauss(0,1) +1.0j*random.gauss(0,1) )/math.sqrt(2.0)
  35.         F[I,J]=2.0*math.pi*L*math.sqrt(l**2*h**2/(4.0*math.pi)*scipy.exp(-Kx**2*l**2/4.0 -Ky**2*l**2/4.0))*rdm_number
  36.  
  37. for I in scipy.arange(1,N/2-1,1):
  38.     for J in scipy.arange(1,N/2-1,1):
  39.         F[N-I,N-J]= F[I,J].conjugate()
  40.  
  41. for I in scipy.arange(N/2+1,N-1,1):
  42.     for J in scipy.arange(1,N/2-1,1):
  43.         F[N-I,N-J]= F[I,J].conjugate()
  44.  
  45. RS = scipy.fftpack.ifft2(F)
  46.  
  47. del F
  48.  
  49. scipy.io.write_array(
  50.     os.path.join("RS.txt"), 
  51.         RS, 
  52.         separator=" " 
  53.     )
  54.  
  55. pylab.clf()
  56. Z = scipy.real(RS) 
  57.  
  58. del RS
  59.  
  60. pylab.imshow(Z)
  61. pylab.contour(Z)
  62. pylab.xlabel('x')
  63. pylab.ylabel('y')
  64. pylab.savefig( os.path.join("RS.png"))
  65. pylab.clf()
  66.  
  67. del  Z
  68.  
--------------------------------------------------
May 27 '10 #1
0 1725

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Andy Rechenberg | last post by:
The problem is basically in the subject line. I am building an Intranet site based on Zope/CMF/Plone. In order to fulfill the requirements Zope/Python must be run on Windows. Zope is running...
36
by: Armin Rigo | last post by:
Hi! This is a rant against the optimization trend of the Python interpreter. Sorting a list of 100000 integers in random order takes: * 0.75 seconds in Python 2.1 * 0.51 seconds in Python...
2
by: Sylvain Thenault | last post by:
Hi there ! I've noticed the following problem with python >= 2.3 (actually 2.3.4 and 2.4): syt@musca:test$ python Python 2.3.4 (#2, Sep 24 2004, 08:39:09) on linux2 Type "help", "copyright",...
0
by: Bernhard Reimar Hoefle | last post by:
I have the following python script: ####################################### from numarray import * while 1: a=arange(1,300000000) b=a*100/100 del a del b...
7
by: Dody Suria Wijaya | last post by:
Hi, I encountered a Memory Error Exception on using IMAP4 just like in Python documentation example, on a specially large email (10 MB). Any idea how to fix/circumvent this? >>> typ, data =...
5
by: Michael Sperlle | last post by:
Is it possible? Bestcrypt can supposedly be set up on linux, but it seems to need changes to the kernel before it can be installed, and I have no intention of going through whatever hell that would...
0
by: Stephen G | last post by:
Hi there. I have been receiving MemoryErrors using the Windows version of Python 2.5. The script I have written times the sending and the reception of emails with various attachments. I get many...
0
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 380 open (-36) / 3658 closed (+65) / 4038 total (+29) Bugs : 965 open ( -9) / 6555 closed (+35) / 7520 total (+26) RFE : 272 open...
6
by: Terry Carroll | last post by:
I am trying to do something with a very large tarfile from within Python, and am running into memory constraints. The tarfile in question is a 4-gigabyte datafile from freedb.org,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.