You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import sys
from dials.array_family import flex
import pandas as pd
r = flex.reflection_table.from_file(sys.argv[1])
data = { }
for k in r.keys():
if hasattr(r[k], "as_numpy_array"):
a = r[k].as_numpy_array()
if len(a.shape) == 1:
data[k] = a
else:
for n in range(a.shape[1]):
data[f"{k}_{n}"] = a[:,n]
else:
print(f"Cannot convert {k} to numpy")
df = pd.DataFrame(data, columns=[k for k in data])
having reflections.as_pandas_dataframe() or something could be handy for the general user.
I welcome comments.
The text was updated successfully, but these errors were encountered:
This sort of thing would be pretty useful to me -- I had briefly looked into reading .refl files for reciprocalspaceship: rs-station/reciprocalspaceship#78. The linked issue may have a few useful snippets to look at.
I find it quite useful to work with reflection data in this sort of format, and this proposed method would support converting to a reciprocalspaceship.DataSet object because that constructor can take a pandas.DataFrame (along with spacegroup, unitcell, etc) to instantiate a DataSet object. I think this would be a great method to add to the reflection_table.
This issue has been automatically marked as stale because it has not had recent activity. The label will be removed automatically if any activity occurs. Thank you for your contributions.
Perhaps starting from something like this:
having
reflections.as_pandas_dataframe()
or something could be handy for the general user.I welcome comments.
The text was updated successfully, but these errors were encountered: