-
Notifications
You must be signed in to change notification settings - Fork 27
Improve DiffractionSimulation #175
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
Conversation
|
Coveralls is not accessible at the moment which seems to be the reason why CI is failing |
|
FYI, Coveralls now works! Edit: At least the workflows don't fail. See the reduced coverage. |
|
Think this should be ok for review, if you agree with the features I've added I'll update the changelog |
|
I'll have a look tomorrow, but since I haven't used this part of diffsims, someone else who has should have a look as well before merging. |
hakonanes
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like solid additions! I've made general comments and suggestions on the structure of added functionality, which I believe could make it less error prone and easier to maintainable.
(Would be great to have a user guide notebook or something to see the added functionality in action, but that is for another time, and other people perhaps.)
hakonanes
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I'll leave it up to @pc494 or @dnjohnstone to merge.
|
Thanks for the contribution @din14970 and the review @hakonanes, apologies for my slowness. |
name: Fix DiffractionSimulation
about: see #174
Release Notes
Reworked the way
DiffractionSimulationbehaves, thereby fixing issues setting properties likecoordinates,indicesandintensities.What does this PR do? Please describe and/or link to an open issue.
This PR aims to fix #174 but also reworks the class a bit
The changes mainly pertain to the property/setter behavior of the
coordinates,indicesandintensitiesattributes. PreviouslyDiffractionSimulationcould exist as an empty shell without any diffraction spots, and coordinates, indices and intensities could be set to anything. This can cause all kinds of issues with the getters, that relied on_coordinates, etc. to be either all arrays of the same size orNone. But this was not enforced anywhere, plus one ran into trouble with thewith_direct_beammasking.I have changed
coordinatesto a mandatory argument in the__init__. My reasoning is that a diffraction pattern without any spots doesn't make much sense. A completely empty array can still be passed. Indices and intensities can be left empty but appropriately sized arrays of zeros will be automatically created based on the size ofcoordinates. In theinitmethod, the shape of all these arrays is verified, and_coordinates,_indicesand_intensitiesare set based on what is passed in. The getters and setters ofindicesintensitiesandcoordinatescan then be substantially simplified, both rely onself.direct_beam_maskand stay consistent in shape amongst each other since I use numpy slicing to update the values. Changing the number of spots is no longer allowed, for this one should simply create a newDiffractionSimulation. What can be done instead now is slicing into the pattern, for examplein order to filter out spots based on some condition. This makes sense as long as
coordinates,indices, andintensitiesare the same size. note that on a slice like this, information about the direct beam is lost if it was already "filtered out" bywith_direct_beamOther changes I've made were mainly as a consequence of the previous changes and also make sense in my opinion.
calibrated_coordinatesonly makes sense in the x-y plane, there is no reason it should return the z-coordinate since there is no calibration value for it. One might consider renaming thisdetector_coordinates?30/09/21
I have tried to clean up this class a bit more and add a couple more features:
Will produce another
DiffractionSimulationobject with the combined spots of the original two. With theextendmethod, spots can be added from another pattern in-place, just like it exists in ASE.calibrated_coordinatesor a method that depends on it, an exception is raised telling the user the calibration should be set.Describe alternatives you've considered
Are there any known issues? Do you need help?
Work in progress?
For reviewers
later.
__init__.py.the unreleased section in
CHANGELOG.md.