Re: Extract Indices of Numpy Array Based on Given Bit Information

2014-10-17 Thread Chris Angelico
On Sat, Oct 18, 2014 at 5:42 PM, Artur Bercik  wrote:
> I got some sense, but could not imagine if required Bit No. 2–5, and  Bit
> Combination .
>
> I hope example with the new case would make me more sense.
>

Just write the number in binary, with the bits you're interested in
set to 1, and everything else 0:

... 876543210
... 00000

>>> 0b00000
60
>>> 1073741877 & 0b00000
52

So this number does _not_ have all zeroes there. If it did, the result
would be zero. To look for some other pattern, just do the same thing
- suppose we want to find numbers where it's 1001, we just look for
the result to be 0b000100100, or 36.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Flush stdin

2014-10-17 Thread Chris Angelico
On Fri, Oct 17, 2014 at 10:38 PM, Empty Account  wrote:
> I will be using this script on Unix based systems and I wondered what
> approach I could use
> to flush stdin?

Why exactly do you need to flush stdin? If you've written a small
amount of data to the console, it's stdout that you need to flush.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Extract Indices of Numpy Array Based on Given Bit Information

2014-10-17 Thread Chris Angelico
On Sat, Oct 18, 2014 at 4:58 PM, Artur Bercik  wrote:
> I want to get the index of my data where the following occurs:
>
> Bit No. 0–1
> Bit Combination: 00

So, what you want to do is look at each number in binary, and find the
ones that have two zeroes in the last two places?
1073741824: 100
1073741877: 1110101

The easiest way to do this is with simple bitwise operations:

>>> 1073741824 & 3
0
>>> 1073741877 & 3
1

3 is 0011 in binary, so a bitwise AND with that will tell
you about just the last two bits. The result will be an integer - 0,
1, 2, or 3, representing 00, 01, 10, or 11 for those last two bits. So
all you have to do is AND each number with 3, and when the result is
0, that's what you want.

Does that make sense?

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Flush stdin

2014-10-17 Thread Empty Account
Hi,

I am using netcat to listen to a port and python to read stdin and print to
the console.

nc -l 2003 | python print_metrics.py

sys.stdin.flush() doesn’t seem to flush stdin, so I am using the termios
module.

while True:
   input = sys.stdin.readline()
   # do some parsing
   …
   sys.stdout.write(parsed_data)
   time.sleep(3)
   termios.tcflush(sys.stdin, termios.TCIOFLUSH)


I am receiving this exception
termios.error: (25, 'Inappropriate ioctl for device')


I will be using this script on Unix based systems and I wondered what
approach I could use
to flush stdin?

Many Thanks

Aidy
-- 
https://mail.python.org/mailman/listinfo/python-list


Extract Indices of Numpy Array Based on Given Bit Information

2014-10-17 Thread Artur Bercik
Dear Python and Numpy Users:

My data are in the form of '32-bit unsigned integer' as follows:

myData = np.array([1073741824, 1073741877, 1073742657, 1073742709,
1073742723, 1073755137, 1073755189,1073755969],dtype=np.int32)

I want to get the index of my data where the following occurs:

Bit No. 0–1
Bit Combination: 00

How can I do it? I heard this type of problem first time, please help me.

Artur
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Tutor] Convert Qstring to string in windows

2014-10-17 Thread eryksun
On Thu, Oct 16, 2014 at 10:21 AM, C@rlos  wrote:
> in linux i do for this way:
> pythonstringtext=qstringtext.text().toUtf8.data()
> and it return a python string correctly.

pythonstringtext is a byte string that has to be decoded as UTF-8.
Here's the 'mojibake' result when it gets decoded as UTF-16LE or
Windows codepages 850 and 1252:

>>> s = u'áéíóú'
>>> b = s.encode('utf-8')

>>> print b.decode('utf-16le')
ꇃ꧃귃돃뫃

>>> print b.decode('850')
├í├®├¡├│├║

>>> print b.decode('1252')
áéíóú

The native character size in the Windows kernel is 2 bytes, so UTF-16
is the path of least resistance for in-memory strings used with GUI
controls and file/registry paths. UTF-8 is preferred for text data in
files and network communication.
-- 
https://mail.python.org/mailman/listinfo/python-list


Processing xml for output with cElementTree

2014-10-17 Thread Joseph L. Casale
I am unfortunately unable to use lxml for a project and must resort to base 
only libraries
to create several nested elements located directly under a root element. The 
caveat is the
incremental writing and flushing of the nested elements as they are created.

So assuming the structure is texttext if I would 
like to
manually deconstruct this in order to write each element in order of 
appearance, is there
any built in facility for this?

The way I am currently doing is rather pathetic...

Thanks,
jlc
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: windows log to event viewer

2014-10-17 Thread Mark Lawrence

On 17/10/2014 10:59, Arulnambi Nandagoban wrote:

Hello,

I am trying to run a tcp server as a windows service.

The project also includes an application layer protocol somewhat like
CoAP and few soap calls to data base.

There is some moment the code enter into exception during a soap method
call. This exception is not viewed in

Windows event viewer. Should I specify somewhere to log these exception
in windows event viewer. Or, give me some suggestion how to log some

Critical message in windows log.

--

nambi



http://stackoverflow.com/questions/113007/writing-to-the-windows-logs-in-python

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

--
https://mail.python.org/mailman/listinfo/python-list


Re: 2d color-bar map plot

2014-10-17 Thread Mark Lawrence

On 17/10/2014 07:28, Dhananjay wrote:

Dear all,
I am bit new to the python/pyplot.
This might be simple, but I guess I am missing something here.


I doubt that you'll get detailed answers here so suggest you try 
https://lists.sourceforge.net/lists/listinfo/matplotlib-users which is 
also available as gmane.comp.python.matplotlib.general


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

--
https://mail.python.org/mailman/listinfo/python-list


Re: Write list to new column in existent csv

2014-10-17 Thread Peter Otten
Tal Bar-Or wrote:

> I am tryin to figure how to write a list i have as follows

> To a a csv to for example the 3rd column , i am really got stacked here i
> tried few codes with csv.writerow() but didn't got it work ,will really
> appreciate if someone could help me with that Please advice Thanks

Here's a sketch:

Open the source file using a csv.reader(); open the destination file using a 
csv.writer().

Use zip() and a for-loop to iterate over the new column and the rows in the 
source.

Insert the new field into the source row, e. g. row.insert(3, field)

Use writerow() to write the modified row.


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: windows log to event viewer

2014-10-17 Thread Irmen de Jong
On 17-10-2014 11:59, Arulnambi Nandagoban wrote:
> Hello,
> 
>  
> 
> I am trying to run a tcp server as a windows service.
> 
> The project also includes an application layer protocol somewhat like CoAP 
> and few soap
> calls to data base.
> 
> There is some moment the code enter into exception during a soap method call. 
> This
> exception is not viewed in
> 
> Windows event viewer. Should I specify somewhere to log these exception in 
> windows event
> viewer. Or, give me some suggestion how to log some
> 
> Critical message in windows log.
> 

What I would try is to catch the exception and log it, including a message, to 
the NT
Event log. You should be able to do this using the NTEventLogHandler from 
Python's
standard logging module, see:

https://docs.python.org/3.4/library/logging.handlers.html#logging.handlers.NTEventLogHandler


Irmen

-- 
https://mail.python.org/mailman/listinfo/python-list


Write list to new column in existent csv

2014-10-17 Thread Tal Bar-Or
Hello Group,

I am tryin to figure how to write a list i have as follows

['info', '19987→445 [SYN] Seq=0 Win=8192 Len=0 MSS=1460 WS=256 
SACK_PERM=1\n', '445→19987 [SYN, ACK] Seq=0 Ack=1 Win=65535 Len=0 MSS=1460 
WS=64 SACK_PERM=1\n', '19987→445 [ACK] Seq=1 Ack=1 Win=65536 Len=0\n', 
'Negotiate Protocol Request\n', '[TCP Retransmission] Negotiate Protocol 
Request\n', '445→19987 [ACK] Seq=1 Ack=160 Win=1049536 Len=0\n', 'Negotiate 
Protocol Response\n', 'Negotiate Protocol Request\n', 'Negotiate Protocol 
Response\n', 'Session Setup Request, NTLMSSP_NEGOTIATE\n', 'Session Setup 
Response, Error: STATUS_MORE_PROCESSING_REQUIRED, NTLMSSP_CHALLENGE\n', 
'Session Setup Request, NTLMSSP_AUTH, User: GEFEN\\tbaror\n', '445→19987 
[ACK] Seq=768 Ack=1016 Win=1049728 Len=0\n', 'Session Setup Response\n', 'Tree 
Connect Request Tree: media.isilon.gefen.local\\Media\n', 'Tree Connect 
Response\n', 'Create Request File: New Text document.txt\n', 'Create Response 
File: New Text document.txt\n', 'GetInfo Request FS_INFO/SMB2_FS_INFO_01 File: 
New Text document.txt;GetInfo Request FS_INFO/SMB2_FS_INFO_05 File: New Text 
document.txt\n']


To a a csv to for example the 3rd column , i am really got stacked here i tried 
few codes with csv.writerow() but didn't got it work ,will really appreciate if 
someone could help me with that
Please advice
Thanks

The csv
ip.src,ip.dst,smb.file,smb2.filename,smb.path,smb2.tree,smb.time,smb2.time,smb.cmd,smb2.cmd,tcp.time_delta,tcp.analysis.ack_rtt,tcp.analysis.ack_lost_segment,tcp.analysis.duplicate_ack,tcp.analysis.lost_segment,tcp.analysis.retransmission,tcp.analysis.out_of_order,tcp.analysis.window_full,tcp.analysis.window_update,tcp.analysis.zero_window
172.18.2.54,172.18.5.64,0,
172.18.5.64,172.18.2.54,0.003322,0.003322
172.18.2.54,172.18.5.64,0.29,0.29
172.18.2.54,172.18.5.64,,,114,,0.84,
172.18.2.54,172.18.5.64,,,114,,0.300507,1
172.18.5.64,172.18.2.54,0.000114,0.300621
172.18.5.64,172.18.2.540,0.000266,
172.18.2.54,172.18.5.640,0.92,0.92
172.18.5.64,172.18.2.54,,0.000192,,0,0.000192,0.000192
172.18.2.54,172.18.5.641,0.000589,0.000589
172.18.5.64,172.18.2.54,,0.001788,,1,0.001788,0.001788
172.18.2.54,172.18.5.641,0.000193,0.000193
172.18.5.64,172.18.2.54,0.005582,0.005582
172.18.5.64,172.18.2.54,,0.008014,,1,0.002432,
172.18.2.54,172.18.5.64\\media.isilon.gefen.local\Media3,0.000203,0.000203
172.18.5.64,172.18.2.54,,0.000458,,3,0.000458,0.000458
172.18.2.54,172.18.5.64,,New Text 
document.txt,,\\media.isilon.gefen.local\Media5,0.000189,0.000189
172.18.5.64,172.18.2.54\\media.isilon.gefen.local\Media,,0.000274,,5,0.000274,0.000274

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: your mail

2014-10-17 Thread Terry Reedy

On 10/17/2014 6:43 AM, Cameron Simpson wrote:

On 17Oct2014 11:45, Dhananjay  wrote:



2.1576318858 -1.8651195165 4.2333428278
...
(total of 200 lines)

Columns 1,2,3 corresponds to x,y,z axis data points.



   for line in open('flooding-psiphi.dat','r'):
   line = line.split()
   xs.append(float(line[0]))
   ys.append(float(line[1]))
   zs.append(float(line[2]))


A further refinement:
   for line in open('flooding-psiphi.dat','r'):
   x, y, z = map(float, line.split())
   xs.append(x)
   ys.append(y)
   zs.append(z)


--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


Re: 2d color-bar map plot

2014-10-17 Thread Peter Pearson
On Fri, 17 Oct 2014 14:28:13 +0800, Dhananjay wrote:
[snip]
> xs = ys = zs = []
> for line in fl1:
> line = line.split()
> xs.append(float(line[0]))
> ys.append(float(line[1]))
> zs.append(float(line[2]))
>
> print xs[0], ys[0], zs[0]

The line "xs = ys = zs = []" is almost surely not what you want to do.
It results in xs, ys, and zs all being the same object.  Look:

>>> xs = ys = zs = []
>>> xs.append(1)
>>> print(ys)
[1]
>>> 

Since your xs, ys, and zs are all identical, some unfortunate part
of the plotting package is trying in vain to find some thickness to
the thing it's plotting, but it can't, because all the points you've
given it lie on the x=y=z plane.  (It's sad that it tries so heroically
to give a detailed error message that turns out to be so obscure.)

So spend a few more characters:
xs = []
ys = []
zs = []

Then, on to the next problem.

-- 
To email me, substitute nowhere->runbox, invalid->com.
-- 
https://mail.python.org/mailman/listinfo/python-list


non-gobject based dbus library?

2014-10-17 Thread Tycho Andersen
Hi all,

An application I maintain recently moved away from the gobject event
loop to the tulip/trollius/asyncio event loop. However, we were using
python-dbus, which internally uses the gobject event loop, as our main
event loop. This worked nicely when we were gobject based, but now
that we're not, I'm trying to find alternatives to python-dbus so that
we can re-implement the dbus-based functionality.

I tried gbulb: https://bitbucket.org/a_ba/gbulb but it seems mostly
abandoned, and I had to hack on it to even get our application to
boot, and some things didn't work correctly.

Does anyone have any ideas?

(Please keep me in CC, I'm not subscribed.)

Thanks!

Tycho
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Permissions on files installed by pip?

2014-10-17 Thread Jean-Michel Pichavant
- Original Message -
> From: "Adam Funk" 
> To: python-list@python.org
> Sent: Thursday, 16 October, 2014 9:29:46 PM
> Subject: Permissions on files installed by pip?
> 
> I've been using the python-nltk package on Ubuntu, but I need ntlk
> 3.0
> now.  I used 'sudo aptitude purge python-nltk' to get rid of my
> existing installation, & followed instructions on the nltk website
> [1]
> starting at step 4 (since I already have python-pip & python-numpy
> packages installed).
> 
> $ sudo pip install -U
> 
> I couldn't get it to work, until I realized that the permissions &
> ownership on /usr/local/lib/python2.7/dist-packages were 'drwx--S---
> root staff'.  A 'chmod -R a+rX' on that directory seems to have fixed
> it.  Is it normal for sudo pip install to set the permissions that
> way, or did I do something wrong?

On debian wheezy:

ls -al /usr/local/lib/python2.7/dist-packages  

drwxrwsr-x 5 root staff 4.0K Jun 30 15:16 ./

I'm not sure pip is responsible for this anyway, so my money goes on "you did 
something wrong" :)


JM


-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be 
privileged. If you are not the intended recipient, please notify the sender 
immediately and do not disclose the contents to any other person, use it for 
any purpose, or store or copy the information in any medium. Thank you.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: your mail

2014-10-17 Thread Cameron Simpson

On 17Oct2014 11:45, Dhananjay  wrote:

This might be simple, but I guess I am missing something here.
I have data file as follows:

2.1576318858 -1.8651195165 4.2333428278
2.1681875208 -1.9229968780 4.1989176884
2.3387636157 -2.0376253255 2.4460899122
2.1696565965 -2.6186941271 4.4172007912
2.0848862071 -2.1708981985 3.3404520962
2.0824347942 -1.9142798955 3.3629290206
2.0281685821 -1.8103363482 2.5446721669
2.3309993378 -1.8721153619 2.7006893016
2.0957461483 -1.5379071451 4.5228264441
2.2761376261 -2.5935979811 3.9231744717
(total of 200 lines)

Columns 1,2,3 corresponds to x,y,z axis data points.
This is not a continuous data. I wish to make a plot as a 2D with 3rd
dimension (i.e z-axis data) as a color map with color bar on right hand side.

As a beginner, I tried to follow tutorial with some modification as follows:
http://matplotlib.org/examples/pylab_examples/tricontour_vs_griddata.html

[...]

Initially I've just got comments about the code in general, though they may 
help you find your issues.



# Read data from file:
fl1 = open('flooding-psiphi.dat','r').readlines()


This reads all the lines into memory, into the list "fl1".
For 200 lines this is not a bit issue, but since you process them immediately 
you are usually better off reading the file progressively.



xs = ys = zs = []


This is actually a bug in your code. I would guess you've based it on other 
example code such as:


  x = y = z = 0

The problem is that both these assignment statements assign the _same_ object 
to all 3 variables. With an int or a str this isn't an issue because they are 
immutable; any further math or modification actually makes new objects.


However, you use:

  xs = ys = zs = []

This makes exactly _one_ list, and assigns it ("binds it" in Python terms) to 
all three names.


The result is that when you append to the list, you're appending to the same 
list every time. Effectively this means (1) that xs, ys and zs have the same 
values and (2) they're 3 times as long as they should be.


Do this:

  xs = []
  ys = []
  zs = []

That makes three separate lists.


for line in fl1:
    line = line.split()
    xs.append(float(line[0]))
    ys.append(float(line[1]))
    zs.append(float(line[2]))


Returning to the "reading the file progressively" thing, for a really big file 
(and as a matter of general practice) you're better off writing this like:


  for line in open('flooding-psiphi.dat','r'):
      line = line.split()
      xs.append(float(line[0]))
      ys.append(float(line[1]))
      zs.append(float(line[2]))

which only ever reads one line of text from the file at a time.

Start by fixing the:

  xs = ys = zs = []

assignment and see how the behaviour changes.

Cheers,
Cameron Simpson 
--
https://mail.python.org/mailman/listinfo/python-list


windows log to event viewer

2014-10-17 Thread Arulnambi Nandagoban
Hello, 

 

I am trying to run a tcp server as a windows service. 

The project also includes an application layer protocol somewhat like CoAP
and few soap calls to data base.

There is some moment the code enter into exception during a soap method
call. This exception is not viewed in

Windows event viewer. Should I specify somewhere to log these exception in
windows event viewer. Or, give me some suggestion how to log some

Critical message in windows log. 

 

--

nambi 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help in using grako for parsing

2014-10-17 Thread varun7rs
I'm really sorry for not being clear. I shall explain things in detail from now 
onwards. Really sorry. The output I would like is 










In a similar way I have something like this for every request. This is what I 
intend to get from the input that I had pasted earlier.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help in using grako for parsing

2014-10-17 Thread varun7rs
Oh damn, it turned out really crappy. I could not format it properly
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help in using grako for parsing

2014-10-17 Thread Peter Otten
varun...@gmail.com wrote:

> Hello,
> I am trying to parse a file which ahs the below content. I tried using the
> split function but that wasn't a good programming practice. I had to use
> it repeatedly to split the line and then read my data. I thought of doing
> it in a better way which is when I came across grako. But I have no idea
> whatsoever about the usage of grako in a script. It would be nice if any
> of you could help me understand the usage of grako. I need to extract the
> values beside the variables z, f and x. The numbers represent the request
> ID, virtualNode ID and physical nodeID for x and it varies a bit for f,

We know Python, but not necessarily any terminology you throw at us.

I didn't respond to your previous post because I had no idea what a .sol 
file is and what you're up to. As far as I can see no-one did. Now you make 
it even harder to help you by forcing us to look up "grako" to not (sic!) 
understand your question...

You give sample input below. Perhaps you'll get more/better feedback if you 
provide a sample of the output you need, too, together with a more elaborate 
and accessible explanation of how you think you could get there.

> z_0  1.00
> x_0_0_1  1.00
> x_0_1_5  1.00
> x_0_2_20 1.00
> x_0_3_21 1.00
> x_0_4_8  1.00
> f_0_0(0,1)_(1,5) 1.00
> f_0_1(1,2)_(5,9) 1.00
> f_0_1(1,2)_(9,20)1.00
> f_0_2(2,3)_(2,21)1.00
> f_0_2(3,2)_(2,22)1.00
> f_0_2(2,3)_(20,22)   1.00
> f_0_3(4,3)_(8,10)1.00
> f_0_3(3,4)_(0,10)1.00
> f_0_3(4,3)_(0,14)1.00
> f_0_3(4,3)_(14,21)   1.00
> z_1  1.00
> x_1_0_16 1.00
> x_1_1_6  1.00
> x_1_2_13 1.00
> x_1_3_0  1.00
> x_1_4_25 1.00
> x_1_5_15 1.00
> x_1_6_19 1.00
> f_1_0(1,0)_(6,16)1.00
> f_1_1(0,2)_(6,11)1.00
> f_1_1(0,2)_(11,13)   1.00
> f_1_1(2,0)_(6,16)1.00
> f_1_2(3,1)_(0,6) 1.00
> f_1_3(2,4)_(13,25)   1.00
> f_1_4(5,4)_(15,25)   1.00
> f_1_5(3,6)_(0,1) 1.00
> f_1_5(3,6)_(1,18)1.00
> f_1_5(3,6)_(18,19)   1.00


-- 
https://mail.python.org/mailman/listinfo/python-list


Help in using grako for parsing

2014-10-17 Thread varun7rs
Hello, 
I am trying to parse a file which ahs the below content. I tried using the 
split function but that wasn't a good programming practice. I had to use it 
repeatedly to split the line and then read my data. I thought of doing it in a 
better way which is when I came across grako. But I have no idea whatsoever 
about the usage of grako in a script. It would be nice if any of you could help 
me understand the usage of grako. I need to extract the values beside the 
variables z, f and x. The numbers represent the request ID, virtualNode ID and 
physical nodeID for x and it varies a bit for f,

Thanks a lot

z_0  1.00
x_0_0_1  1.00
x_0_1_5  1.00
x_0_2_20 1.00
x_0_3_21 1.00
x_0_4_8  1.00
f_0_0(0,1)_(1,5) 1.00
f_0_1(1,2)_(5,9) 1.00
f_0_1(1,2)_(9,20)1.00
f_0_2(2,3)_(2,21)1.00
f_0_2(3,2)_(2,22)1.00
f_0_2(2,3)_(20,22)   1.00
f_0_3(4,3)_(8,10)1.00
f_0_3(3,4)_(0,10)1.00
f_0_3(4,3)_(0,14)1.00
f_0_3(4,3)_(14,21)   1.00
z_1  1.00
x_1_0_16 1.00
x_1_1_6  1.00
x_1_2_13 1.00
x_1_3_0  1.00
x_1_4_25 1.00
x_1_5_15 1.00
x_1_6_19 1.00
f_1_0(1,0)_(6,16)1.00
f_1_1(0,2)_(6,11)1.00
f_1_1(0,2)_(11,13)   1.00
f_1_1(2,0)_(6,16)1.00
f_1_2(3,1)_(0,6) 1.00
f_1_3(2,4)_(13,25)   1.00
f_1_4(5,4)_(15,25)   1.00
f_1_5(3,6)_(0,1) 1.00
f_1_5(3,6)_(1,18)1.00
f_1_5(3,6)_(18,19)   1.00
-- 
https://mail.python.org/mailman/listinfo/python-list


[no subject]

2014-10-17 Thread Dhananjay
Hello,

This might be simple, but I guess I am missing something here.
I have data file as follows:

2.1576318858 -1.8651195165 4.2333428278
2.1681875208 -1.9229968780 4.1989176884
2.3387636157 -2.0376253255 2.4460899122
2.1696565965 -2.6186941271 4.4172007912
2.0848862071 -2.1708981985 3.3404520962
2.0824347942 -1.9142798955 3.3629290206
2.0281685821 -1.8103363482 2.5446721669
2.3309993378 -1.8721153619 2.7006893016
2.0957461483 -1.5379071451 4.5228264441
2.2761376261 -2.5935979811 3.9231744717
.
.
.
(total of 200 lines)

Columns 1,2,3 corresponds to x,y,z axis data points.
This is not a continuous data. I wish to make a plot as a 2D with 3rd
dimension (i.e z-axis data) as a color map with color bar on right hand
side.

As a beginner, I tried to follow tutorial with some modification as
follows:
http://matplotlib.org/examples/pylab_examples/tricontour_vs_griddata.html

# Read data from file:
fl1 = open('flooding-psiphi.dat','r').readlines()
xs = ys = zs = []
for line in fl1:
line = line.split()
xs.append(float(line[0]))
ys.append(float(line[1]))
zs.append(float(line[2]))

print xs[0], ys[0], zs[0]
xi = np.mgrid[-5.0:5.0:200j]
yi = np.mgrid[-5.0:5.0:200j]
zi = griddata((x, y), z, (xi, yi), method='cubic')
plt.subplot(221)

plt.contour(xi, yi, zi, 15, linewidths=0.5, colors='k')
plt.contourf(xi, yi, zi, 15, cmap=plt.cm.rainbow,
norm=plt.Normalize(vmax=abs(zi).max(), vmin=-abs(zi).max()))
plt.colorbar()  # draw colorbar
plt.plot(x, y, 'ko', ms=3)
plt.xlim(-5, 5)
plt.ylim(-5, 5)
plt.title('griddata and contour (%d points, %d grid points)' %
  (npts, ngridx*ngridy))
#print ('griddata and contour seconds: %f' % (time.clock() - start))
plt.gcf().set_size_inches(6, 6)
plt.show()


However, I failed and getting long error as follows:

QH6154 qhull precision error: initial facet 1 is coplanar with the interior
point
ERRONEOUS FACET:
- f1
- flags: bottom simplicial upperDelaunay flipped
- normal:0.7071  -0.70710
- offset: -0
- vertices: p600(v2) p452(v1) p304(v0)
- neighboring facets: f2 f3 f4

While executing:  | qhull d Qz Qbb Qt
Options selected for Qhull 2010.1 2010/01/14:
  run-id 1531309415  delaunay  Qz-infinity-point  Qbbound-last  Qtriangulate
  _pre-merge  _zero-centrum  Pgood  _max-width 8.8  Error-roundoff 1.2e-14
  _one-merge 8.6e-14  _near-inside 4.3e-13  Visible-distance 2.5e-14
  U-coplanar-distance 2.5e-14  Width-outside 4.9e-14  _wide-facet 1.5e-13

precision problems (corrected unless 'Q0' or an error)
  2 flipped facets

The input to qhull appears to be less than 3 dimensional, or a
computation has overflowed.

Qhull could not construct a clearly convex simplex from points:
- p228(v3):   2.4   2.4   1.4
- p600(v2):   1.4   1.4   8.8
- p452(v1):   5.7   5.7 8
- p304(v0):  -3.1  -3.1   2.4

The center point is coplanar with a facet, or a vertex is coplanar
with a neighboring facet.  The maximum round off error for
computing distances is 1.2e-14.  The center point, facets and distances
to the center point are as follows:

center point1.5951.5955.173

facet p600 p452 p304 distance=0
facet p228 p452 p304 distance=0
facet p228 p600 p304 distance=0
facet p228 p600 p452 distance=0

These points either have a maximum or minimum x-coordinate, or
they maximize the determinant for k coordinates.  Trial points
are first selected from points that maximize a coordinate.

The min and max coordinates for each dimension are:
  0:-3.134 5.701  difference= 8.835
  1:-3.134 5.701  difference= 8.835
  2:  -2.118e-22 8.835  difference= 8.835

If the input should be full dimensional, you have several options that
may determine an initial simplex:
  - use 'QJ'  to joggle the input and make it full dimensional
  - use 'QbB' to scale the points to the unit cube
  - use 'QR0' to randomly rotate the input for different maximum points
  - use 'Qs'  to search all points for the initial simplex
  - use 'En'  to specify a maximum roundoff error less than 1.2e-14.
  - trace execution with 'T3' to see the determinant for each point.

If the input is lower dimensional:
  - use 'QJ' to joggle the input and make it full dimensional
  - use 'Qbk:0Bk:0' to delete coordinate k from the input.  You should
pick the coordinate with the least range.  The hull will have the
correct topology.
  - determine the flat containing the points, rotate the points
into a coordinate plane, and delete the other coordinates.
  - add one or more points to make the input full dimensional.
Traceback (most recent call last):
  File "./scatter.py", line 43, in 
zi = griddata((x, y), z, (xi, yi), method='linear')
  File "/usr/lib/python2.7/dist-packages/scipy/interpolate/ndgriddata.py",
line 183, in griddata
ip = LinearNDInterpolator(points, values, fill_value=fill_value)
  File "interpnd.pyx", line 192, in
scipy.interpolate.interpnd.LinearNDInterpolator.__init__
(scipy/interpolate/interpnd.c:2598)
  File "qhull.pyx", line

Convert Qstring to string in windows

2014-10-17 Thread C@rlos

I have been tryed to convert a Qstring text to string on python, in linux that 
work fine but in windows when qstring contine á,é,í,ó,ú the converted text is 
not correct, contine extranger characters, 
this qstring text is an url from qdialogtext. 

in linux i do for this way: 
pythonstringtext=qstringtext.text().toUtf8.data() 
and it return a python string correctly. 

i need some help plese... 

.C@rlos 


III Escuela Internacional de Invierno en la UCI del 17 al 28 de febrero del 
2014. Ver www.uci.cu

-- 
https://mail.python.org/mailman/listinfo/python-list