I would like to start managing my Fortran data using the power of python. In Fortran90, it's straightforward to write the results in binary. For instance, I save an array in a binary file and I would like to read it and do some statistics in python. What is the correct way of doing this?
-
3Use NumPy for number crunching in Python.Fred Foo– Fred Foo2013-12-06 19:13:18 +00:00Commented Dec 6, 2013 at 19:13
-
2@larsmans: Your comment appears irrelevant. OP is asking about how to go about reading Fortran "binary" data into Python, not how to process said data.Kyle Kanos– Kyle Kanos2013-12-06 19:18:28 +00:00Commented Dec 6, 2013 at 19:18
-
1@KyleKanos: NumPy also has facilities for I/O and interop with Fortran libraries.Fred Foo– Fred Foo2013-12-06 20:43:25 +00:00Commented Dec 6, 2013 at 20:43
-
1@larsmans: I know it does, but your comment was about "number crunching" not file IO, hence the claim it is irrelevant.Kyle Kanos– Kyle Kanos2013-12-06 21:12:20 +00:00Commented Dec 6, 2013 at 21:12
-
2@larsmans: Again, your initial comment has nothing to do with file IO that the OP is asking for. You are trying to recover a battle you lost 2 hours ago, please stop and admit (to yourself, I don't care for a reply) your comment was irrelevant.Kyle Kanos– Kyle Kanos2013-12-06 21:28:01 +00:00Commented Dec 6, 2013 at 21:28
|
Show 1 more comment
2 Answers
The module fortranfile offers a very convenient way of reading binary Fortran files. Requires numpy.
Comments
This page may help: http://stromberg.dnsalias.org/~strombrg/converting-binary.html
In short, binary data is best avoided, but the page still talks about ways of dealing with it.