Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #7735
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail |
|---|---|
| From | Peter Otten <__peter__@web.de> |
| Newsgroups | comp.lang.python |
| Subject | Re: data type and logarithm |
| Followup-To | comp.lang.python |
| Date | Thu, 16 Jun 2011 13:55:52 +0200 |
| Organization | None |
| Lines | 49 |
| Message-ID | <itcqv0$nfj$1@solani.org> (permalink) |
| References | <b583dac8-826e-4bd5-b230-00e667855896@m24g2000yqc.googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="ISO-8859-1" |
| Content-Transfer-Encoding | 7Bit |
| X-Trace | solani.org 1308225312 24051 eJwNyMkBwCAMA7CV6hw2jNMEsv8IrZ5KJ9gKJiMnZ7nfwh+yzX04qKsFgdDTMQWThb3k6Z70DwhJEHg= (16 Jun 2011 11:55:12 GMT) |
| X-Complaints-To | abuse@news.solani.org |
| NNTP-Posting-Date | Thu, 16 Jun 2011 11:55:12 +0000 (UTC) |
| X-User-ID | eJwNwokRACEIBLCWBJevHF2k/xLuJrHt4gy4OWx+L2hD5euRRAk9/DERrcpBH80RvboPtIrmhb1u4hBvVX9lqhWg |
| Cancel-Lock | sha1:JGJewwjY7JJzB3F3mif586e3Xyk= |
| X-NNTP-Posting-Host | eJwNwoERwCAIBLCVeOEBx1GE/UdoL6E6vMKcbpyfH3YLZcR25nIONBzvxqLmq1cdrXkoz22Z6EESaritcmuUexaiAUhwf53fGGg= |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:7735 |
Followups directed to: comp.lang.python
Show key headers only | View raw
simona bellavista wrote:
> Hi, I am quite new to python and I am trying to do some simple plots.
> I am using python Python 2.6.4 and numpy/1.5.1
> I have an ASCII data file that I am reading with the following lines
> of code:
>
> import pylab
> import numpy as np
>
> filename='something.dat'
> file = open(filename)
>
> rho = np.array([], dtype = 'float64')
> entropy = np.array([], dtype = 'float64')
> for line in file:
> columns = line.split()
> rho = np.append(rho,columns[0])
You have to convert the string to a float, e. g.
rho = np.append(rho, np.float64(columns[0]))
> entropy = np.append(entropy,columns[1])
>
> and rho and entropy are apparently read correctly, but when I look to
> the data type
>
> print rho.dtype
> print entropy.dtype
>
> I get |S22 , what's that?
> Then I want to plot a logarithmic plot and I do
>
> pylab.plot(np.log(rho), entropy)
>
> and I get
>
> NotImplementedError: Not implemented for this type
>
> Does anybody has a clue? I do not know how to proceed
It should be easier to use numpy.loadtxt():
with open(filename) as f:
a = np.loadtxt(f)
rho = a[..., 0]
entropy = a[..., 1]
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
data type and logarithm simona bellavista <afylot@gmail.com> - 2011-06-16 01:37 -0700
Re: data type and logarithm Nobody <nobody@nowhere.com> - 2011-06-16 10:16 +0100
Re: data type and logarithm "afylot@gmail.com" <antonella.garzilli@gmail.com> - 2011-06-16 02:27 -0700
Re: data type and logarithm Peter Otten <__peter__@web.de> - 2011-06-16 13:55 +0200
Re: data type and logarithm Terry Reedy <tjreedy@udel.edu> - 2011-06-16 13:20 -0400
Re: data type and logarithm Robert Kern <robert.kern@gmail.com> - 2011-06-16 16:21 -0500
csiph-web