On 20.09.2016 17:48, Gabriele Brambilla wrote:
Hi,
I have this script
import numpy as np
import random as rnd
from math import *
import matplotlib.pyplot as plt
folder = '../NOBACKUP/heavi3/'
pre = '10'
dat = '.dat'
snshot = '4189'
d = 0.02
d2 = d/2.0
tot = 156
half = 78
points = 33750000000
BxN = np.zeros((tot,tot,tot))
ByN = np.zeros((tot,tot,tot))
BzN = np.zeros((tot,tot,tot))
ExN = np.zeros((tot,tot,tot))
EyN = np.zeros((tot,tot,tot))
EzN = np.zeros((tot,tot,tot))
Egnotte = []
ExS = [1,0,0]
EyS = [0,1,0]
EzS = [0,0,1]
BxS = [0,1,1]
ByS = [1,0,1]
BzS = [1,1,0]
numpyArrays =[ExN]#, EyN, EzN, BxN, ByN, BzN]
FC = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
fields = ['EX_']#, 'EY_', 'EZ_', 'BX_', 'BY_', 'BZ_']
stagger = [ExS]#, EyS, EzS, BxS, ByS, BzS]
print 'im here'
for field, arry, stag in zip(fields, numpyArrays, stagger):
g=0
fname = folder+ field + pre + snshot + dat
print fname
f = open(fname, 'rb')
print "pastopens"
for iw in range(points):
range() in Python 2 returns a list of all the numbers in the range.
With points set to 33750000000, as in your code, the list will have that
many integers and a block of memory that may hold all of them is
probably very hard to obtain on most machines.
The solution is to use xrange() which yields values on demand, i.e. 1
single integer everytime through the for loop.
As one of many small improvements in Python 3, range behaves like Python
2 xrange, so this kind of problem cannot happen there.
Best,
Wolfgang
print iw
But when I run it it is killed in the for cycle, it doesn't print any
number:
[gabriele:~/Desktop/GITcode] gbrambil% python EknotFromKostas.py
im here
../NOBACKUP/heavi3/EX_104189.dat
pastopens
Killed
does it mean that my number of points is too high?
Thanks
GB
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor