Mathematical Operations on Array

Fodness, Bryan C - GS Bryan.Fodness at itt.com
Fri Apr 1 08:56:32 EDT 2011


I am loading text into an array and would like to convert the values.

from math import *
from numpy import *
from pylab import *

data=loadtxt('raw.dat')
mincos=degrees(acos(data[:,0]))
minazi=degrees(data[:,1])
minthick=data[:,2]/0.006858

I am not sure why degrees()  works, but acos() does not.

I receive the following

Traceback (most recent call last):
  File "C:\ test.py", line 6, in ?
    mincos=degrees(acos(float(data[:,0])))
TypeError: only length-1 arrays can be converted to Python scalars

Can anyone tell me what I am doing wrong?

________________________________
This e-mail and any files transmitted with it may be proprietary and are intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error please notify the sender.
Please note that any views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of ITT Corporation. The recipient should check this e-mail and any attachments for the presence of viruses. ITT accepts no liability for any damage caused by any virus transmitted by this e-mail.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110401/5d8700d6/attachment.html>


More information about the Python-list mailing list