float does not parse '0.000000E+00'
Paolo Redaelli
redaelli at inc.it
Sat Jun 3 17:59:48 EDT 2000
Oh, well. It seems I'm missing an obvious thing.
I post here my program and the data that caused the problem
--
______________________________
/ Paolo Redaelli \
| redaelli at inc.it |
| http://gnupaghe.netpedia.net |
\------------------------------/
-------------- next part --------------
1
4 3
1 0.000000E+00 0.000000E+00
2 0.000000E+00 0.300000E+03
3 0.500000E+03 0.300000E+03
4 0.500000E+03 0.000000E+00
1 1 2
2 2 3
3 3 4
1 0.300000E+03 0.000000E+00 0.100000E+01
0.000000E+00 0.000000E+00 0.000000E+00 0.250000E+04 -.146922E+03 0.652654E+04
0.150000E+02 0.478073E-01 -.395235E-04 0.250000E+04 -.146922E+03 0.668798E+04
0.300000E+02 0.956146E-01 -.174419E-03 0.250000E+04 -.146922E+03 0.720229E+04
0.450000E+02 0.143422E+00 -.429172E-03 0.250000E+04 -.146922E+03 0.806948E+04
0.600000E+02 0.191229E+00 -.828271E-03 0.250000E+04 -.146922E+03 0.928954E+04
0.750000E+02 0.239036E+00 -.139620E-02 0.250000E+04 -.146922E+03 0.108625E+05
0.900000E+02 0.286844E+00 -.215745E-02 0.250000E+04 -.146922E+03 0.127883E+05
0.105000E+03 0.334651E+00 -.313651E-02 0.250000E+04 -.146922E+03 0.150670E+05
0.120000E+03 0.382458E+00 -.435786E-02 0.250000E+04 -.146922E+03 0.176985E+05
0.135000E+03 0.430266E+00 -.584599E-02 0.250000E+04 -.146922E+03 0.206830E+05
0.150000E+03 0.478073E+00 -.762539E-02 0.250000E+04 -.146922E+03 0.240203E+05
0.165000E+03 0.525880E+00 -.972055E-02 0.250000E+04 -.146922E+03 0.277105E+05
0.180000E+03 0.573687E+00 -.121559E-01 0.250000E+04 -.146922E+03 0.317535E+05
0.195000E+03 0.621495E+00 -.149561E-01 0.250000E+04 -.146922E+03 0.361495E+05
0.210000E+03 0.669302E+00 -.181454E-01 0.250000E+04 -.146922E+03 0.408983E+05
0.225000E+03 0.717109E+00 -.217484E-01 0.250000E+04 -.146922E+03 0.460000E+05
0.240000E+03 0.764916E+00 -.257897E-01 0.250000E+04 -.146922E+03 0.514546E+05
0.255000E+03 0.812724E+00 -.302936E-01 0.250000E+04 -.146922E+03 0.572620E+05
0.270000E+03 0.860531E+00 -.352846E-01 0.250000E+04 -.146922E+03 0.634223E+05
0.285000E+03 0.908338E+00 -.407874E-01 0.250000E+04 -.146922E+03 0.699355E+05
0.300000E+03 0.956146E+00 -.468262E-01 0.250000E+04 -.146922E+03 0.768016E+05
2 0.500000E+03 0.100000E+01 0.000000E+00
0.000000E+00 -.956146E+00 0.105359E+06 0.000000E+00 -.810241E-12 0.118531E+15
0.250000E+02 -.956146E+00 0.354593E+09 0.000000E+00 -.250000E+03 0.118531E+15
0.500000E+02 -.956146E+00 0.553234E+09 0.000000E+00 -.500000E+03 0.118531E+15
0.750000E+02 -.956146E+00 0.615784E+09 0.000000E+00 -.750000E+03 0.118531E+15
0.100000E+03 -.956146E+00 0.561998E+09 0.000000E+00 -.100000E+04 0.118531E+15
0.125000E+03 -.956146E+00 0.411631E+09 0.000000E+00 -.125000E+04 0.118531E+15
0.150000E+03 -.956146E+00 0.184438E+09 0.000000E+00 -.150000E+04 0.118531E+15
0.175000E+03 -.956146E+00 -.998256E+08 0.000000E+00 -.175000E+04 0.118531E+15
0.200000E+03 -.956146E+00 -.421405E+09 0.000000E+00 -.200000E+04 0.118531E+15
0.225000E+03 -.956146E+00 -.760544E+09 0.000000E+00 -.225000E+04 0.118531E+15
0.250000E+03 -.956146E+00 -.109749E+10 0.000000E+00 -.250000E+04 0.118531E+15
0.275000E+03 -.956146E+00 -.141248E+10 0.000000E+00 -.275000E+04 0.118531E+15
0.300000E+03 -.956146E+00 -.168578E+10 0.000000E+00 -.300000E+04 0.118531E+15
0.325000E+03 -.956146E+00 -.189761E+10 0.000000E+00 -.325000E+04 0.118531E+15
0.350000E+03 -.956146E+00 -.202822E+10 0.000000E+00 -.350000E+04 0.118531E+15
0.375000E+03 -.956146E+00 -.205787E+10 0.000000E+00 -.375000E+04 0.118531E+15
0.400000E+03 -.956146E+00 -.196678E+10 0.000000E+00 -.400000E+04 0.118531E+15
0.425000E+03 -.956146E+00 -.173522E+10 0.000000E+00 -.425000E+04 0.118531E+15
0.450000E+03 -.956146E+00 -.134343E+10 0.000000E+00 -.450000E+04 0.118531E+15
0.475000E+03 -.956146E+00 -.771639E+09 0.000000E+00 -.475000E+04 0.118531E+15
0.500000E+03 -.956146E+00 -.105359E+06 0.000000E+00 -.500000E+04 0.118531E+15
3 0.300000E+03 0.000000E+00 -.100000E+01
0.000000E+00 0.000000E+00 -.129038E+07 0.000000E+00 0.000000E+00 0.000000E+00
0.150000E+02 0.000000E+00 -.156394E+10 0.000000E+00 0.000000E+00 0.161438E+03
0.300000E+02 0.000000E+00 -.243946E+10 0.000000E+00 0.000000E+00 0.675750E+03
0.450000E+02 0.000000E+00 -.271495E+10 0.000000E+00 0.000000E+00 0.154294E+04
0.600000E+02 0.000000E+00 -.247753E+10 0.000000E+00 0.000000E+00 0.276300E+04
0.750000E+02 0.000000E+00 -.181429E+10 0.000000E+00 0.000000E+00 0.433594E+04
0.900000E+02 0.000000E+00 -.812342E+09 0.000000E+00 0.000000E+00 0.626175E+04
0.105000E+03 0.000000E+00 0.441215E+09 0.000000E+00 0.000000E+00 0.854044E+04
0.120000E+03 0.000000E+00 0.185928E+10 0.000000E+00 0.000000E+00 0.111720E+05
0.135000E+03 0.000000E+00 0.335473E+10 0.000000E+00 0.000000E+00 0.141564E+05
0.150000E+03 0.000000E+00 0.484049E+10 0.000000E+00 0.000000E+00 0.174938E+05
0.165000E+03 0.000000E+00 0.622943E+10 0.000000E+00 0.000000E+00 0.211839E+05
0.180000E+03 0.000000E+00 0.743446E+10 0.000000E+00 0.000000E+00 0.252270E+05
0.195000E+03 0.000000E+00 0.836847E+10 0.000000E+00 0.000000E+00 0.296229E+05
0.210000E+03 0.000000E+00 0.894436E+10 0.000000E+00 0.000000E+00 0.343718E+05
0.225000E+03 0.000000E+00 0.907502E+10 0.000000E+00 0.000000E+00 0.394735E+05
0.240000E+03 0.000000E+00 0.867335E+10 0.000000E+00 0.000000E+00 0.449280E+05
0.255000E+03 0.000000E+00 0.765225E+10 0.000000E+00 0.000000E+00 0.507355E+05
0.270000E+03 0.000000E+00 0.592461E+10 0.000000E+00 0.000000E+00 0.568958E+05
0.285000E+03 0.000000E+00 0.340332E+10 0.000000E+00 0.000000E+00 0.634090E+05
0.300000E+03 0.000000E+00 0.129038E+07 0.000000E+00 0.000000E+00 0.702750E+05
-------------- next part --------------
#!/usr/bin/env python
## pyplot
## program to plot'n'show the results of "telaio", a fortran program
##
# Author: Jesper Skov <jskov at cygnus.co.uk>
# A rewite of the C canvas example in the GNOME Developer's Information
import GDK
from gtk import *
from gnome.ui import *
import GdkImlib
import glob # to look for all LCASE.* files
from string import * ## to process informations
from UserList import UserList ## to create lists that starts counting from 1
from math import * ## we need almost everything from math....
def fortran_float(string):
data = [mantissa,exponent] = split(string,"E",2)
print data
map(float,data)
return mantissa*pow(10,exponent)
class CanvasExample:
def __init__(self):
self.width = 600
self.height = 400
self.all = []
self.colors = ("red",
"yellow",
"green",
"cyan",
"blue",
"magenta")
def show_warped(self, widget, event=None):
return
def show_N(self, widget, event=None):
return
def show_T(self, widget, event=None):
return
def show_M(self, widget, event=None):
return
def main(self):
# Open window to hold canvas.
win = GtkWindow()
win.connect('destroy', mainquit)
win.set_title('Telaio')
# Create VBox to hold canvas and buttons.
vbox = GtkVBox()
win.add(vbox)
vbox.show()
# Create canvas.
self.canvas = GnomeCanvas()
self.canvas.set_usize(self.width, self.height)
self.canvas.set_scroll_region(0,0, self.width, self.height)
vbox.pack_start(self.canvas)
self.canvas.show()
# Create buttons.
hbox = GtkHBox()
vbox.pack_start(hbox, expand=FALSE)
hbox.show()
label = GtkLabel('Condizione di carico:')
label.set_alignment(0, 0.5)
hbox.pack_start(label, expand=FALSE)
label.show()
spinner = GtkSpinButton(GtkAdjustment(0,0,10,1,2,0), 0, 0)
hbox.pack_start(spinner)
spinner.show()
b = GtkButton("Deformata")
b.connect("clicked", self.show_warped)
hbox.pack_start(b)
b.show()
b = GtkButton("N")
b.connect("clicked", self.show_N)
hbox.pack_start(b)
b.show()
b = GtkButton("T")
b.connect("clicked", self.show_T)
hbox.pack_start(b)
b.show()
b = GtkButton("M")
b.connect("clicked", self.show_M)
hbox.pack_start(b)
b.show()
b = GtkButton("Quit")
b.connect("clicked", mainquit)
hbox.pack_start(b)
b.show()
win.show()
class Node:
def __init__(self,number,x,y):
self.number = number
self.x = x
self.y = y
class Rod:
def __init__(self, number, node1, node2):
self.number = number
self.node1 = node1
self.node2 = node2
self.sections = range(0,21) ## list of sections. Each section will be a list containg [position, u displacement, v displacement, n, t, m]. From index 0 to index 20
## Lista is a list with preallocated length that starts counting from 1. This is useful to avoid unnecessary mess within file processing expecially regarding the rods and nodes lists
class Lista(UserList):
def __init__(self):
UserList.__init__(self)
self.data = []
def __setattr__(self, attr, value):
if attr == "size" and value>0:
self.data = [None]*value
else:
self.__dict__[attr] = value
def __getitem__(self,index):
if index > 0:
return self.data[index-1]
else:
raise IndexError
def __setitem__(self,index,value):
self.data[index-1] = value
class LoadCase:
def __init__(self):
self.nodes = Lista() ## the list of nodes
self.rods = Lista() ## the list of rods
class Telaio:
def __init__(self):
## Loading all the load cases
## Looking for all LCASE.xxx files
self.filelist = glob.glob("LCASE*")
self.load_cases = Lista()
self.load_cases.size = len(self.filelist) ## Load cases are a list of cases
for filename in self.filelist:
file = open(filename)
## Obtaing case number
case_n = int( split(filename,".")[1] ) ## split filename into fields separated by "."; take the second (0 is the first), translate it in a number
## Creating Load case
loadcase = LoadCase()
self.load_cases[case_n] = loadcase
## Reading the trailing 1
file.readline()
## read nodes and rods numbers
number_list = [nodes_n, rods_n] = split( file.readline() )
[loadcase.nodes_n, loadcase.rods_n] = map(int, number_list) ## Convert them to numbers and assign 'em
## Reading nodes coordinates
for node_i in range(0,loadcase.nodes_n):
[node, x, y] = split( file.readline() )
node = int(node);
print "x(%s)='%s' y(%s)='%s'" % (type(x),x,type(y),y)
x = float(x)
y = float(y) ## Converting in numeric form (could be done in during node creation, but it would generate beastly thing like "loadcase.nodes[int(node)] = Node( float(x), float(y) )" )
loadcase.nodes[node] = Node(node,xx,yy)
## Note: node_i is NOT used!
## Reading rod's end nodes
for rod_i in range(0, loadcase.rods_n):
[rod_n, node1, node2] = split( file.readline() )
map(int, [rod_n, node1, node2]) ## conveting into numeric form applying int to every element of the list.
loadcase.rods[rod_n] = Rod(rod_n,node1,node2)
## Note rod_i is NOT used!
## for each rod, read it's number, length cosine and sine
for rod_i in range(0, loadcase.rods_n):
[rod_n, lenght, cosine, sine] = split( file.readline() )
rod_n = int(rod_n); map(float, [lenght, cosine, sine]) ## Converting into numeric form
current_rod = loadcase.rods[rod_n]
[current_rod.lenght, current_rod.cosine, current_rod.sine]= [lenght, cosine, sine]
## Reading position, displacements and stresses
for i in range(0,21): ## from 0 to 20
section = [x,u,v,n,t,m] = split( file.readline() )
map( float, section) ## Converting list's element into float
current_rod.sections[i] = section
## End reading rod's sections
## End reading rods
## End reading files.
if __name__ == '__main__':
t = Telaio()
c = CanvasExample()
c.main()
mainloop()
More information about the Python-list
mailing list