[AstroPy] Fast ASCII reader with Fortran notation

Derek Homeier derek at astro.physik.uni-goettingen.de
Tue Mar 31 17:33:34 EDT 2015


Hi all,

first thanks to everyone who contributed to the fast C parser framework in 1.0’s io.ascii,
having decent speed when dealing with cumbersome text files has been on my wish list
for some time!
My next highest priority was always being able to read in Fortran-written ascii files with
its standard double-precision notation (1.495978707D+13…) without further processing,
which required setting up converters for each column with np.loadtxt or np.genfromtxt.
I decided to take a shot at the fast_reader module to enable the c parser to directly
recognise the ‘D’ as exponential character, a branch from the stable tree is here

https://github.com/dhomeier/astropy/tree/fortranio

which adds ‘fortran_dexp’ as new option to the fast_reader arguments.
Is there general interest for a pull request against stable or master? I’d also like to put
some questions on refinements for discussion:

1. This patch automatically activates the fast_converter, as changing the call to xstrtod was
by far the simplest implementation. I guess it would be possible to add it to the more
precise parser as well, but don’t know how big the demand for this is. I have yet to see
a case where use_fast_converter gave a different result.

2. Currently ‘fortran_dexp’=True changes the recognised exponential character to ‘d’ or ‘D’ only,
it’s easy to add any other character or an ‘automatic’ option that will both recognise ‘e’ and ‘d’
in the same file, at a seemingly small performance penalty of 5-10 %.

If there is interest I could definitely add the second option.

Cheers,
					Derek




More information about the AstroPy mailing list