Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add utilities so that freud.diffraction.Diffractometer can be used like bitbucket diffractometer code #8

Merged
merged 9 commits into from
Jun 16, 2021

Conversation

jennyfothergill
Copy link
Member

@jennyfothergill jennyfothergill commented Jun 11, 2021

The compute method for rhe freud.diffraction.Diffractomer class takes a quaternion as the view_orientation kwarg. In order to use this module the same way the old diffractometer code was used, we need to convert the rotation matrices to quaternions.

Thoughts/TODO

  • should this go here or in gixstapose? -- Now that it is so simple, I think here.
  • needs unit tests

@codecov
Copy link

codecov bot commented Jun 11, 2021

Codecov Report

Merging #8 (982f1f5) into master (814e971) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master        #8   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            3         3           
  Lines           76        93   +17     
=========================================
+ Hits            76        93   +17     
Impacted Files Coverage Δ
cmeutils/__init__.py 100.00% <100.00%> (ø)
cmeutils/structure.py 100.00% <100.00%> (ø)

Copy link
Contributor

@gwenwhite gwenwhite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall think this is great, just a couple of suggestions added.

cmeutils/structure.py Outdated Show resolved Hide resolved
environment.yml Show resolved Hide resolved
@jennyfothergill
Copy link
Member Author

Example snippet using this code to calculate diffraction patterns:

import freud
import gsd.hoomd
import matplotlib.pyplot as plt

from cmeutils.structure import get_quaternions


gsdfile = "sc10.gsd"

with gsd.hoomd.open(gsdfile) as f:
    snap = f[-1]
    
points = snap.particles.position
box = freud.Box.from_box(snap.configuration.box)
dp = freud.diffraction.DiffractionPattern(grid_size=1024, output_size=1024)

for q in get_quaternions():
    fig, ax = plt.subplots(figsize=(5, 5), dpi=150)
    qx,qy,qz,qw = q
    dp.compute((box, points), view_orientation=q)
    dp.plot(ax=ax)
    ax.set_title(f"Diffraction Pattern\nq=[{qx:.2f} {qy:.2f} {qz:.2f} {qw:.2f}]")

Copy link
Member

@chrisjonesBSU chrisjonesBSU left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@jennyfothergill jennyfothergill merged commit a806ed7 into cmelab:master Jun 16, 2021
@jennyfothergill jennyfothergill deleted the feat/diffraction-utils branch June 16, 2021 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants