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

Maclariz ddf patch 1 #665

Merged
merged 25 commits into from
Aug 29, 2024
Merged

Maclariz ddf patch 1 #665

merged 25 commits into from
Aug 29, 2024

Conversation

maclariz
Copy link
Contributor

Here are my functions for Digital Dark Field Imaging. The one thing you might want to change is what progress bar you use to make it consistent with things you use elsewhere. I just used the progress bar library I have been using for a while now. Other than that, it's all just numpy and base python and py4dstem.

Add a new section under process for Digital Dark Field imaging
All DDF functions added
@maclariz maclariz marked this pull request as draft July 4, 2024 16:06
@maclariz maclariz marked this pull request as ready for review July 5, 2024 15:57
@maclariz
Copy link
Contributor Author

maclariz commented Jul 5, 2024

Some minor changes to variable naming in one of the functions, and improvement of the inline comments to make them fully consistent with the function variable names

@maclariz maclariz marked this pull request as draft July 8, 2024 06:46
Adding in the import numpy as np that seems to have triggered the build errors.  I foolishly assumed that this was fine as numpy is standard throughout py4dstem.
@maclariz maclariz marked this pull request as ready for review July 8, 2024 06:53
@maclariz
Copy link
Contributor Author

maclariz commented Jul 8, 2024

I presume reading the errors that it was just import numpy as np that was killing things. I have still used an imported progress bar function as I don't understand yours and don't see any code definition for this anywhere to call. You may wish to advise me about this before running another attempt to merge.

@gvarnavi
Copy link
Member

gvarnavi commented Jul 8, 2024

Thanks for the contribution!

Approved the automatic workflow runs, linted the code with black, and switched the progress bar to the internal tqdmnd (the documentation of which can be found here). You might want to check the code still runs as you expect it to, since I did no checking.

I'll leave the reviewing for others who work with virtual imaging more, but here's some quick comments:

  • The code is now not imported in any namespaces. This can be achieved by adding a __init__.py file in the digitaldarkfield directory, and an appropriate line in the process directory __init__.py. You can see an example here
  • More generally, I suspect a conversation on where this would best fit is warranted. This is now implemented as functions and not its own class. This is fine, but perhaps then it's appropriate to expose these functions as a DataCube method? See e.g. how virtual imaging is implemented
  • We're trying to switch to using docstrings to document functions, with a style similar to the numpy docs one - you can see an example here

@maclariz
Copy link
Contributor Author

maclariz commented Jul 8, 2024

@gvarnavi I don't understand what the init.py is doing. I am not a great programmer and certainly not well up on what the conventions are being used by everyone. And there is little in the way of suitable training at my university to help with that. What I am good at is problem solving and finding mathematically and computationally efficient ways to do stuff that is physically meaningful (i.e. doing physics in a reasonably short amount of time). Quite happy to be educated as to how to make things better fit the larger ecosystem.

@maclariz
Copy link
Contributor Author

maclariz commented Jul 8, 2024

@gvarnavi @cophus the wider conversation on fit is welcomed!

I don't know enough about classes yet.

It is not a Datacube method, per se. It is a pointslists method...

@maclariz
Copy link
Contributor Author

maclariz commented Jul 8, 2024

@gvarnavi changing to your docsstrings comments is easy. Will test the approved version, and provided that is now okay, I will make another fork and then edit and make a pull request.

@gvarnavi
Copy link
Member

gvarnavi commented Jul 8, 2024

@maclariz We're very happy to help with adding __init__.py files / importing the module according to our conventions!

Perhaps the easiest thing to do is for @cophus (or similar) to review the code for scientific content and once that is sorted, and we've decided on where the best fit is, I'm happy to help with massaging the code structure to fit our conventions.

Re: your comment on making a new fork/pull-request: You can simply keep working on your maclariz-DDF-patch-1 branch, and any commits you push there will be added to this pull request.

@maclariz
Copy link
Contributor Author

maclariz commented Jul 8, 2024

@gvarnavi I have now requested that our sysadmin (not me, but someone far more suitable) makes a new venv with a suitable python version for me to run my own fork of py4dstem on for testing. I'll test any further updates in there.

Creating the init file to make the directory discoverable
Adding the correct imports
updated the comments to better suit style used elsewhere in repository

Some slight variable renaming for consistency
@cophus
Copy link
Member

cophus commented Aug 12, 2024

Testing notebook using the new DDF syntax:

https://drive.google.com/file/d/1WA7DAjBEYpIOk24T7y4NqRPvJj5_Kfpg/view?usp=sharing

@smribet
Copy link
Collaborator

smribet commented Aug 28, 2024

Hi Ian and Colin,

Thank you for this PR! I think this will be very helpful for a number of experiments. I am happy to merge but have two small requested changes:

  1. Can you please add doc strings? They are missing for a few functions. aperture_array_generator has docstrings twice (although I do appreciate the extra notes about mode).
  2. bplist.cal will apply all calibrations attached to the braggpeaks, which will create problems if the pixel size of the braggpeaks is calibrated (or it inherits a calibration from a datacube). I would suggest instead of using bplist.cal to follow the design pattern in ACOM and pass those options to the user as flags.

~Steph

@maclariz
Copy link
Contributor Author

maclariz commented Aug 28, 2024 via email

@smribet
Copy link
Collaborator

smribet commented Aug 28, 2024

Hi Ian,

Thanks for making these changes! I agree that all the information in the doc strings is helpful!

As you point out, it would be straightforward to account for pixel sizes. Unfortunately, braggvector calibrations are especially confusing, so I tweaked the code to make this a bit more explicit and to give a user more control. The default behavior should match what you had. Let me know if this looks ok to you, and I can merge!

~Steph

Copy link
Contributor Author

@maclariz maclariz left a comment

Choose a reason for hiding this comment

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

Seems fine to me

@smribet smribet merged commit 3407f8b into py4dstem:dev Aug 29, 2024
6 checks passed
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.

4 participants