Hi,
I have problems reading unformatted fortran output (binary) with python.
I have a code in fortran where I write data on a file inside a cycle:
write(11) x,y,z,BA01(i,j,k,1),BA01(i,j,k,2),1
BB01(i,j,k,1),BB01(i,j,k,2),2 BE01(i,j,k,1),3
EC01(i,j,k,1),EC01(i,j,k,2),4 ED01(i,
The second method seem to work.
But how can I know which dtype in Python corresponds to REAL in fortran?
Thanks
On Mon, Jul 13, 2015 at 11:29 AM, Laura Creighton wrote:
> In a message of Mon, 13 Jul 2015 11:14:36 -0400, Gabriele Brambilla writes:
> >Hi,
> >
> >I
number.
I think the problem is that Fortran write 4bytes at the beginning and at
the end of each file.
I found a way to remove the first 4 bytes but not the last.
Do you have any suggestion?
Thanks
On Mon, Jul 13, 2015 at 2:08 PM, Gabriele Brambilla <
gb.gabrielebrambi...@gmail.com> wrot
I solved the issue.
If I need more help I'll send another email.
thanks
GB
On Mon, Jul 13, 2015 at 3:32 PM, Gabriele Brambilla <
gb.gabrielebrambi...@gmail.com> wrote:
> Hi,
>
> sorry for the confusion I understood that the Real(8) I'm using correspond
> to dtype f
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 = 3375000
BxN = np.zeros((tot,tot,tot))
ByN = np.zeros((tot
Hi,
The number was high but it was only a sort of test.now I learned how it
works,
thanks
Gb
On Sep 20, 2016 12:48 PM, "Matt Ruffalo" wrote:
> Hello-
>
> On 2016-09-20 11:48, Gabriele Brambilla wrote:
> > does it mean that my number of points is too high?
>
>
Hi,
how could I read float numbers if the data format is like this (using
readline):
1.0551951.26758123387023-0.314470329249235
-0.293015360064208 6.157957619078221.92919102133526
13.07804596303782.15175351758512e6
the numbers aren't equally spaced and
thanks to everyone, I've used David's method.
Gabriele
2014-01-29 Mark Lawrence
> On 29/01/2014 02:09, Gabriele Brambilla wrote:
>
>> Hi,
>> how could I read float numbers if the data format is like this (using
>> readline):
>>
>
Hi,
I'm very new to Python (just 5 days!)
is there a possibility to write an interactive script?
in the sense that:
- you run your script and it do some things that you don't want to type
everytime you run the program
- but at a certain step I want that it ask me question like "which column
of thi
to simplify the question:
does a command like cin in C++ or scanf in C exist??
thanks
Gabriele
2014-01-31 Gabriele Brambilla :
> Hi,
> I'm very new to Python (just 5 days!)
> is there a possibility to write an interactive script?
> in the sense that:
>
> - you run you
Hi,
sometimes when I try to run a program in Python I obtain some errors.
The strange thing is that sometimes when I run it a second time or when I
turn off the pc and I restart later to try to make it works it gives
different errors.
How could I avoid this problem? I think that it is because it
: (nan, nan)
Thanks
Gabriele
2014-02-02 Alan Gauld :
> On 02/02/14 02:11, Gabriele Brambilla wrote:
>
> sometimes when I try to run a program in Python I obtain some errors.
>>
>
> How are you running the program?
>
> doubly clicking in a file manager/explorer?
> R
No, i'm not using lowlevel stuff...which part of the script do you want to
see?
thanks
Gabriele
2014-02-03 Peter Otten <__pete...@web.de>:
> Gabriele Brambilla wrote:
>
> > an example of errors that I obtain is: I build a matrix (SciPy array)
> > using the sa
otlib\colors.py:568:
RuntimeWarning: overflow encountered in multiply
xa *= self.N
and when I search the maximum and the minimum in a matrix it has returned
me two nan values.
Gabriele
2014-02-03 Jerry Hill :
> On Mon, Feb 3, 2014 at 2:17 PM, Gabriele Brambilla
> wrote:
> > No, i&
Hi,
I'm wondering how I can (if I can) make a for loop in which I don't use all
the elements.
for example
a100 = list(range(100))
for a in a100:
print(a)
it print out to me all the numbers from 0 to 99
But if I want to display only the numbers 0, 9, 19, 29, 39, ...(one every
10 el
Excuse me for the bad english:
not "a random float numbers" but "random float numbers"
Gabriele
2014-02-17 11:13 GMT-05:00 Gabriele Brambilla <
gb.gabrielebrambi...@gmail.com>:
> No sorry,
>
> it's because my problem is not so simple:
> imagine th
ow to define your own iterators.
>
> Regards
>
> 2014-02-17 17:05 GMT+01:00 Gabriele Brambilla <
> gb.gabrielebrambi...@gmail.com>:
> > Hi,
> >
> > I'm wondering how I can (if I can) make a for loop in which I don't use
> all
> > the elements
No sorry,
it's because my problem is not so simple:
imagine that in a100 contains not integer sorted in a good way but a random
float numbers.
How could I display only one item every 10?
thanks
Gabriele
2014-02-17 11:08 GMT-05:00 Oscar Benjamin :
> On 17 February 2014 16:05,
ary 2014 16:13, Gabriele Brambilla
> wrote:
> > No sorry,
> >
> > it's because my problem is not so simple:
> > imagine that in a100 contains not integer sorted in a good way but a
> random
> > float numbers.
> > How could I display only one item eve
Hi,
Is possible on python to running scripts from the command prompt (I'm using
python on windows) and in the end saving all the variables and continue the
analysis in the interactive mode? (the one that you activate typing python
in the command prompt?)
Or to use python in the interactive mode an
Hi,
I'm doing a sum in a for loop:
www is the quantity I add.
MYMAP[i, j, k] = MYMAP[i, j, k] + www
MYMAP is a numpy array
I have strong reasons to think that in this operation happens some
numerical error...Have you suggestions to discover where it is?
thanks
Gabriele
__
3, 2014 at 08:00:52PM -0500, Gabriele Brambilla wrote:
> > Hi,
> >
> > I'm doing a sum in a for loop:
> >
> > www is the quantity I add.
> >
> > MYMAP[i, j, k] = MYMAP[i, j, k] + www
> >
> > MYMAP is a numpy array
> >
> > I
ackets--an ordered collection of
other objects to be introduced later in this chapter):
>>> import random
>>> random.random()
0.7082048489415967
>>> random.choice([1, 2, 3, 4])
1
Could the problem be something like this?
thanks
Gabriele
2014-03-03 22:44 GMT-05:00 Gabrie
Hi,
in the next days I will receive a c++ code that I would like to run in
python (http://docs.python.org/2/extending/index.html).
It should be self consistent (no extraroutines).
I want to be ready to use it... Has someone some C++ code examples
available that I can try to run easily before getti
I answer in the text
2014-03-11 9:32 GMT-04:00 ALAN GAULD :
> CC'ing the list
> Please use ReplyAll when responding.
>
>
> --
> *From:* Gabriele Brambilla
> *To:* Alan Gauld
> *Sent:* Tuesday, 11 March 2014, 12:54
> *Subject:*
Hi,
I have a program that is reading near 60 elements from a file.
For each element it performs 200 times a particular mathematical operation
(a numerical interpolation of a function).
Now these process takes near 8 hours.
Creating a C function and calling it from the code could improve the s
Hi,
2014-04-10 13:05 GMT-04:00 Martin A. Brown :
>
> Hi there Gabriele,
>
> : I have a program that is reading near 60 elements from a
> : file. For each element it performs 200 times a particular
> : mathematical operation (a numerical interpolation of a function).
> : Now these process
I'm trying to profile it adding this code:
import cProfile
import re
import pstats
cProfile.run('re.compile("foo|bar")', 'restats')
p = pstats.Stats('restats')
p.strip_dirs().sort_stats('name')
p.sort_stats('time').print_stats(10)
but where I have to add this in my code?
because I obtain
Thu
Hi,
I get this result:
Thu Apr 10 17:35:53 2014restats
21071736 function calls in 199.883 seconds
Ordered by: internal time
List reduced from 188 to 10 due to restriction <10>
ncalls tottime percall cumtime percall filename:lineno(function)
1 149.479 149.479
but main is the program that contains everything.
I used the profile in this way:
import cProfile
import pstats
def mymain():
#all the code
#end of main indentation
cProfile.run('mymain()', 'restats', 'time')
p = pstats.Stats('restats')
p.strip_dirs().sort_stats('name')
p.sort_stats('time
sure.
def mymain():
def LEstep(n):
Emin=10**6
Emax=5*(10**10)
Lemin=log10(Emin)
Lemax=log10(Emax)
stepE=(Lemax-Lemin)/n
return (stepE, n, Lemin, Lemax)
if __name__ == "__main__
Hi Danny,
I followed your suggestion.
Tomorrow morning I will run this new version of the code.
Now using a sample of 81 elements (instead of 60) the profile returns:
Thu Apr 10 23:25:59 2014restats
18101188 function calls in 1218.626 seconds
Ordered by: internal time
Lis
I think I have Cython already installed with Anaconda.
How it works?
Thanks
Gabriele
2014-04-11 8:16 GMT-04:00 Albert-Jan Roskam :
>
> > From: Gabriele Brambilla
> >To: Danny Yoo
> >Cc: python tutor
> >Sent: Friday, April 11,
Hi Danny,
I'm quiet impressed.
the program takes near 30 minutes instead of more than 8 hours!
this is the profile:
Fri Apr 11 09:14:04 2014restats
19532732 function calls in 2105.024 seconds
Ordered by: internal time
ncalls tottime percall cumtime percall filename:lineno
MYMAP[i,j,w] += www
count = count + 1
when I exit here the MYMAP matrix has all the cells = 0.
Now I will try to fiugre it out why.
Thanks
Gabriele
2014-04-11 9:20 GMT-04:00 Gabriele Brambilla :
> Hi Danny,
> I'm quiet impressed.
>
ok, it seems that the code don't enter in this for loop
for gammar, MYMAP in zip(gmlis, MYMAPS):
I don't understand why.
Thanks
Gabriele
2014-04-11 9:56 GMT-04:00 Gabriele Brambilla :
> Hi, I'm sorry but there is a big problem.
> the code is producing empty file.
dko += 1
count = count + 1
Now I will tell you how much it takes.
Thanks
Gabriele
2014-04-11 10:05 GMT-04:00 Gabriele Brambilla <
gb.gabrielebrambi...@gmail.com>:
> ok, it seems that the code don't enter in this for loop
>
> for gammar, MYMAP
#x27; objects}
1768320.4400.0001.6450.000 polyint.py:102(_set_dtype)
176832 0.426 0.000 4.8300.000 polyint.py:30(__init__)
thanks
Gabriele
2014-04-11 10:18 GMT-04:00 Gabriele Brambilla <
gb.gabrielebrambi...@gmail.com>:
> ok
> modifying the fo
Yes,
but I want to make a C extension to run faster a function from
scipy.interpolate (interp1d)
It woulldn't change anything?
thanks
Gabriele
2014-04-11 14:47 GMT-04:00 Alan Gauld :
> On 11/04/14 09:59, Peter Otten wrote:
>
>> Gabriele Brambilla wrote:
>>
>>
I forget the reply all
-- Forwarded message --
From: Gabriele Brambilla
Date: 2014-04-11 16:03 GMT-04:00
Subject: Re: [Tutor] improving speed using and recalling C functions
To: Peter Otten <__pete...@web.de>
you are right.
probably this is the problem.
thanks
Gabriele
What can I do to speed it up?
Thanks
Gabriele
sent from Samsung Mobile
Il giorno 11/apr/2014 17:00, "Danny Yoo" ha
scritto:
> On Fri, Apr 11, 2014 at 1:01 PM, Gabriele Brambilla
> wrote:
> > Yes,
> > but I want to make a C extension to run faster a function fro
interpolate is a problem
too!
do you agree with me?
Now I will read Peter Otten's code and run the new simulation with it
thanks
Gabriele
2014-04-12 6:21 GMT-04:00 Peter Otten <__pete...@web.de>:
> Gabriele Brambilla wrote:
>
> > Ok guys, when I wrote that email I w
Ok, i just run Peter's code and it seems really faster...I hope to don't
mistake this time!
Thanks
Gabriele
sent from Samsung Mobile
Il giorno 12/apr/2014 08:22, "Gabriele Brambilla" <
gb.gabrielebrambi...@gmail.com> ha scritto:
> Ok guys,
> I'm not expert
x[sel]
kap[sel] = (2.1495 * np.exp(0.3 * np.log(zsel))
- 1.8138 * zsel)
sel = ~ ((x >= 10.0) | (x < 0.001))
zsel = x[sel]
result = my_inter(np.log10(zsel))
kap[sel] = 10**result
2014-04-12 9:34 GMT-0
Hi,
I'm trying to convert a string to a float. It seems a basic thing but I
don't know why I'm getting this erroris
Traceback (most recent call last):
File "phresREADER.py", line 27, in
tra = float(stri)
ValueError: could not convert string to float:
My file has this line
5.5e+000 5.
solved, sorry for the disturb
http://stackoverflow.com/questions/23344345/strings-not-converting-to-float-as-expected/23344830#23344830
bye
Gabriele
2014-04-28 11:13 GMT-04:00 Gabriele Brambilla <
gb.gabrielebrambi...@gmail.com>:
> Hi,
>
> I'm trying to convert a string
Hi,
I'm trying to use glob to read a file of which I don't know the complete
name (but only some parts).
fiLUMOname = 'Lsum_' + period + '_' + parts[2] + '_' + parts[3] + '_' +
parts[4] + '_*.dat'
aaa = glob.glob(fiLUMOname)
print(aaa)
fiLUMO = open(aaa[0], 'r')
where period, and the elements
-- Forwarded message --
From: Gabriele Brambilla
Date: 2014-06-05 22:15 GMT-04:00
Subject: Re: [Tutor] glob and file names
To: Peter Romfeld
thanks,
it works.
Gabriele
2014-06-05 22:10 GMT-04:00 Peter Romfeld :
On Friday, June 06, 2014 10:04 AM, Gabriele Brambilla wrote
No,
I wanted to say that Peter method works!
Thanks anyway and sorry for the html.
Gabriele
sent from Samsung Mobile
Il giorno 05/giu/2014 23:14, "Dave Angel" ha scritto:
> Gabriele Brambilla Wrote in message:
> >
> >
> (missing because you posted in html. Pleas
oh yes! I had a problem inside the file name! (I had a lot of file to open
and I changed the one I was looking at!the one I was trying to open has a
wrong filename...)
Sorry for the misunderstanding.
Gabriele
2014-06-06 3:05 GMT-04:00 Peter Otten <__pete...@web.de>:
> Gabriele Brambi
50 matches
Mail list logo