Skip to content

Grain data update#757

Closed
donald-e-boyce wants to merge 3 commits intoHEXRD:masterfrom
donald-e-boyce:GrainData-update
Closed

Grain data update#757
donald-e-boyce wants to merge 3 commits intoHEXRD:masterfrom
donald-e-boyce:GrainData-update

Conversation

@donald-e-boyce
Copy link
Copy Markdown
Collaborator

This adds some new features to the GrainData class, including saving/reading grains.out files, quaternions attribute, strain attribute and a select method. This also adds user documentation in the docs section.

@classmethod
def from_grains_out(cls, fname):
"""Read hexrd grains output file"""
return cls.from_array(np.loadtxt(fname))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice, Don! This class is looking like it is becoming very useful 🙂

@pytest.fixture
def quats90():
c45, s45 = np.cos(np.pi / 4), np.sin(np.pi /4)
return [[c45, s45, 0, 0], [c45, 0, s45, 0], [c45, 0, 0, s45]]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Constants could also just be global variables like QUATS_90. pytest fixtures often use other things like environment variables or data on disk to make them. But it doesn't hurt to do it this way, and you can keep it.

@donald-e-boyce donald-e-boyce deleted the GrainData-update branch February 12, 2025 16:52
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.

2 participants