In all it's glory: I'm just a bit embarrassed because I'm sure it's poor coding:
def gridarea(H): """ returns an array of area corresponding to each nx,ny,nz %=========================================== % %------------------------------------------- % input % - H : Header dict object with nx, ny, nz % % output % - Numpy array area corresponding to nx,ny,nz %------------------------------------------- % %------------------------------------------- % last changes: ww, 2007 %=========================================== """ import math import numpy as N pih=math.pi/180. r_earth=6.371e6 cosfunc = lambda y : math.cos(y*pih)*r_earth nz=H['nz'] nx=H['nx'] ny=H['ny'] outlat0=H['outlat0'] dyout=H['dyout'] dxout=H['dxout'] area=N.zeros((nx,ny)) #creates numpy array for iy in range(ny): ylata=outlat0+(float(iy)+0.5)*dyout ylatp=ylata+0.5*dyout ylatm=ylata-0.5*dyout if (ylatm<0 and ylatp>0): hzone=dyout*r_earth*pih else: cosfact=cosfunc(ylata) cosfactp=cosfunc(ylatp) cosfactm=cosfunc(ylatm) if cosfactp<cosfactm: hzone=math.sqrt(r_earth**2-cosfactp**2)-math.sqrt (r_earth**2-cosfactm**2) else: hzone=math.sqrt(r_earth**2-cosfactm**2)-math.sqrt (r_earth**2-cosfactp**2) gridarea=2.*math.pi*r_earth*hzone*dxout/360. for ix in range(nx): print nx, ix, iy area[ix,iy]=gridarea return area #returns numpy array of area Here's the traceback: ... 360 357 9 360 358 9 360 359 9 360 0 10 OverflowError: long int too large to convert to int Traceback: File "<string>", line 1, in ? File "c:\07\Programming\Python\mod_fp\getfp.py", line 11, in ? H,fail=readheader(pathname,1,0) File "c:\07\Programming\Python\mod_fp\mod_fp.py", line 170, in readheader H['area'] = gridarea(H) File "c:\07\Programming\Python\mod_fp\mod_fp.py", line 332, in gridarea area[ix,iy]=gridarea
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor