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

Small simulator improvements for v0.3 #114

Merged
merged 25 commits into from
Sep 3, 2020
Merged

Small simulator improvements for v0.3 #114

merged 25 commits into from
Sep 3, 2020

Conversation

pc494
Copy link
Member

@pc494 pc494 commented Sep 2, 2020


name: Small simulator improvements for v0.3
about: Some housekeeping from recent PR's and also addressing #110


Release Notes

improvement
Summary: Various simulator API changes

What does this PR do? Please describe and/or link to an open issue.
Makes a number of internal changes to improve code a readability
Changes the function signatures of the methods of DiffractionGenerator as well as that classes' __init__, moves some args over to being keyword arguments

@pc494 pc494 added enhancement New feature, request, or improvement dev labels Sep 2, 2020
@pc494 pc494 added this to the v0.3.0 milestone Sep 2, 2020
@pc494
Copy link
Member Author

pc494 commented Sep 2, 2020

Will deal with #23 here too, adding "binary" and (potentially) "sinc" as options

@pc494
Copy link
Member Author

pc494 commented Sep 2, 2020

This is good to review now, coveralls fails (and coverage "falls") because I've managed to drag the number of code lines down (and thus reduced our percentage coverage).

@pc494 pc494 marked this pull request as ready for review September 2, 2020 18:11
Copy link
Member

@dnjohnstone dnjohnstone left a comment

Choose a reason for hiding this comment

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

Basically looks good except I'm not totally sold on the name "excitation_function" - I've suggested "shape_factor_model"? But feel free to merge yourself @pc494 either with or without that change at your discretion.

@@ -106,9 +113,16 @@ def calculate_ed_data(
rotation : tuple
Euler angles, in degrees, in the rzxz convention. Default is (0,0,0)
which aligns 'z' with the electron beam
excitation_function : function or str
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be called the "shape_factor" or maybe "shape_factor_model" given that we use "shape_factor" in the code already? I.e. I would teach that the diffracted wave amplitude is the product of the structure factor (evaluated at the reciprocal lattice vector, g) and the shape factor (evaluated at the excitation error, s_g). E.g. also done in this book. https://www.springer.com/gp/book/9783642297601

Do you see where I'm coming from, or think I'm being silly?

Copy link
Member Author

Choose a reason for hiding this comment

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

on consideration I would agree that shape_factor_model is better, will change and merge.

Copy link
Contributor

Choose a reason for hiding this comment

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

Any preference for whether I define the shape_factor_model as an option in the shape_factor list (line c. 165), or whether it should have it's own generator of some form and then get imported into the diffraction generator?

Copy link
Member Author

Choose a reason for hiding this comment

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

shape_factor_models should be defined by users in their notebooks. I hadn't anticipated adding others to the code base in the short term. If you do want to add them, I would opt for functions defined in this file, with an example in the docstrings. Making linear and binary work as they do is only really acceptable because they are so short (and have no parameters).

Copy link
Member

Choose a reason for hiding this comment

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

I think we probably want some "standard" shape_factor_model functions to be available to users - if only because it's a way that bugs could be introduced and by standardizing them we can iron that out over time. I.e. I thought the plan was to at least add a basic sinc function that many users may want?

We don't want everyone within the community, or even within one research group, ending up with slightly different functions written for the same purpose, I think. Obviously it's different if it's a very niche implementation.

But I agree with @pc494 that these should be defined as functions in this file with examples and docstrings if they're going to go in, and I'd be ambivalent about instead creating a demo notebook that defines a few functions for shape factors so that it's "documented" and "standard" but also not in the code.

Do we have opinions on which of those options would be the happier compromise?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've been swung, we should provide models for users as part of the code. I have some thoughts about the exact syntax but I think I'll raise a separate issue to clear that up, as it'll also illustrate why "binary" and "linear" are not just simpler but also different from many of the other functions we might consider

@dnjohnstone dnjohnstone mentioned this pull request Sep 3, 2020
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev enhancement New feature, request, or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants