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

Cdi recon #279

Merged
merged 17 commits into from
Jun 4, 2015
Merged

Cdi recon #279

merged 17 commits into from
Jun 4, 2015

Conversation

licode
Copy link
Contributor

@licode licode commented May 11, 2015

The full version of cdi reconstruction is added.

@licode
Copy link
Contributor Author

licode commented May 11, 2015

This should be ready to review.

@@ -96,6 +98,27 @@ def gauss(dims, sigma):
return y / np.sum(y)


def _fft_helper(x, option='fft'):
Copy link
Member

Choose a reason for hiding this comment

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

I would suggest two functions _fft_helper and _ifft_helper. Switching on a string like this is not a great pattern. If you really want to be able to switch based on a string key, I would implement this as a dictionary look up of lambda functions. This will fail in really surprising ways if option is not 'fft' or 'ifft'.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is actually my original thought. However, the two helper functions are so similar, so I summarized them as one. If you strongly suggest that way, sure.

Copy link
Member

Choose a reason for hiding this comment

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

If these are for internal use only I would just do

_fft_normed = lambda x: np.fft.ifftshift(np.fft.fftn(np.fft.fftshift(x)))
_ifft_normed = lambda x: np.fft.ifftshift(np.fft.ifftn(np.fft.fftshift(x)))

Wouldn't it be simpler to just leave the fft in the natural order and only shift it when needed?

Copy link
Member

Choose a reason for hiding this comment

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

also, why is fftshift being called on real space data on its way in/out?

Copy link
Member

Choose a reason for hiding this comment

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

I also would not call this 'normed' with the amplitude being scaled by something.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would just call it _fft_helper or _ifft_helper

"""
sup = np.zeros(shape_v)
dummy = _dist(shape_v)
sup_index = np.where(dummy <= sup_radius)
Copy link
Member

Choose a reason for hiding this comment

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

sup[dummy < sup_radius] = 1

The pattern in python leans towards open rather than closed intervals.

@licode
Copy link
Contributor Author

licode commented Jun 2, 2015

@tacaswell , any more comments on the update?

@tacaswell
Copy link
Member

Back on my list of things to re-read.

reconstructed pattern in real space
diffracted_pattern : array
diffraction pattern from experiments
offset_v : float
Copy link
Member

Choose a reason for hiding this comment

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

missing , optional

@licode
Copy link
Contributor Author

licode commented Jun 4, 2015

Corrections are made except fft/ifft part. As fft_helper is shown in multiple places, it is better to be a bit cautious when we do the updates.

@tacaswell
Copy link
Member

I don't think you addressed why cdi has it's own version of _dist when I think there is a function in skxray.core which does the same thing.

tacaswell added a commit that referenced this pull request Jun 4, 2015
@tacaswell tacaswell merged commit d063c39 into scikit-beam:master Jun 4, 2015
@licode
Copy link
Contributor Author

licode commented Jun 4, 2015

@licode licode deleted the cdi_recon branch June 5, 2015 18:31
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.

None yet

4 participants