Closed DHekstra closed 1 year ago
Huh yeah I'm pretty surprised at this default behavior when providing more labels than there are columns, but neat, should be easy to make use of! (This is the same as here https://github.com/rs-station/reciprocalspaceship/blob/2d6fa0e676d02576af691373bc146fbc9191bda0/reciprocalspaceship/io/precognition.py#L31 minus the usecols
argument).
Just a note -- that HKL file may have been post-processed (for example with cut
to remove the extra columns) or from an older version of Precognition (<5.0). According to the Precognition manual (see P. 129), .hkl
files have 7 columns, and the extra columns are filled with 0 and 1, respectively, when the Friedel pairs are merged.
I'm ok with removing the usecols
because this is a rather targeted user base, but it is there to ensure that the .hkl
file is compatible with the Precognition output format.
In general, raw text formats can be read in using df = pd.read_csv()
as @dennisbrookner did above, and can then be converted to a DataSet by passing the DataFrame to rs.DataSet(df)
, and setting the relevant arguments.
OK, fair enough--I am unaware of the history of Precognition's output choices.
I'm fine with either approach. My workaround was already based on pd.read_csv
and works.
Ready to close?
Feel free to close if you're fine with the current state. If you think rs.read_precognition()
should be a bit more flexible to support the 5-column .hkl
format, I am happy to consider that further as well.
OK, will close. We can revisit this if it turns out that current versions of Precognition do still output five-column hkl files under some conditions.
Test-20DC_off_3sig.hkl.txt
Under some circumstances, like in this hkl file provided by Vukica, Precognition uses five columns (h, k, l, FP, SIGFP) rather than 7. Currently, I get an error
ParserError: Too many columns specified: expected 7 and found 5
when trying to read the attached file withrs.read_precognition
. I am usingrs
version 1.0.0. I am currently using a workaround, but it isn't exactly tidy.Perhaps just removing the
usecols
argument will do the trick?