If I want to import a Nastran Deck into a Python Array, in one fell swoop using numpy. How can I go about it? Where am I going wrong?
I have a file with only Grids in it. Grids are all equally spaced with Nastran's Short translator (8 characters)
$ MH Nodes
$2345678$2345678$2345678$2345678$2345678$2345678
GRID 25601 58.50002-57.749923.05
GRID 25602 58.81002-57.749923.05
using the dtype command from Numpy, is great if I understand it correctly. Here is my code:
fileMH = "Gnodes.bdf"
dtyp = np.dtype([
("Grid",(np.void,8)),
("GN",(np.int,8)),
("Prop",(np.void,8)),
("X",(np.float,8)),
("Y",(np.float,8)),
("Z",(np.float,8)),
])
f = np.loadtxt(fileMH,dtyp,comments="$")
The error I get is a float error, however I was expecting dtype to extract 8 characters at a time out of the string. Here is the error:
ValueError: invalid literal for float(): 58.50002-57.749923.05
Help is appreciated.
P.S. Can some please make a nastran tag, huge amounts of data crunching is done in nastran, that requires smart programing. It would be helpful.