Groupby symmetry equivalent reflections in a rs.DataSet?

Fairly simple question here: let’s say I have a DataSet of h,k,l for a particular unmerged list of reflections with a unit cell and spacegroup (no intensities). Is there a simple way to groupbysymmetry-related reflections (either including Friedel mates or not)? I suppose I could make my own wrapper function with gemmi but if it already can be done in reciprocalspaceship, all the better.

Yes, @aaronfinke, you can accomplish this using the DataSet.groupy method. There’s a good demonstration of this in the “Merging with a Robust Error Model” example.

A simple application would be to compute the mean of the columns for each miller index:

mtz_file = "unmerged.mtz"
anomalous = True #bool
ds = rs.read_mtz(mtz_file).hkl_to_asu(anomalous=anomalous)
averages = ds.groupby(['H', 'K', 'L']).mean()

Not sure what your application is, but if you want to merge observations, we have a method for that in rs.algorithms.merge which will apply inverse variance weights to your observations.

1 Like

@kmdalton makes sense, thanks!

1 Like