-
Notifications
You must be signed in to change notification settings - Fork 26
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
Remove unnecessary variables, clean up warp_image #625
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -233,42 +233,35 @@ def warp_image(self, image_dict, pad_with_nans=False, | |||||||||||||||
|
||||||||||||||||
""" | ||||||||||||||||
|
||||||||||||||||
angpts = self.angular_grid | ||||||||||||||||
dummy_ome = np.zeros((self.ntth*self.neta)) | ||||||||||||||||
gvec_angs = np.vstack([ | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moving |
||||||||||||||||
self.angular_grid[1].flatten(), | ||||||||||||||||
self.angular_grid[0].flatten(), | ||||||||||||||||
Comment on lines
+236
to
+238
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Since |
||||||||||||||||
np.zeros((self.ntth*self.neta))]).T | ||||||||||||||||
xypts = np.empty((len(gvec_angs), 2)) | ||||||||||||||||
|
||||||||||||||||
# lcount = 0 | ||||||||||||||||
img_dict = dict.fromkeys(self.detectors) | ||||||||||||||||
for detector_id, panel in self.detectors.items(): | ||||||||||||||||
_project_on_detector = self._func_project_on_detector(panel) | ||||||||||||||||
img = image_dict[detector_id] | ||||||||||||||||
|
||||||||||||||||
gvec_angs = np.vstack([ | ||||||||||||||||
angpts[1].flatten(), | ||||||||||||||||
angpts[0].flatten(), | ||||||||||||||||
dummy_ome]).T | ||||||||||||||||
args, kwargs = self._args_project_on_detector(gvec_angs, panel) | ||||||||||||||||
|
||||||||||||||||
args, kwargs = self._args_project_on_detector(gvec_angs, | ||||||||||||||||
panel) | ||||||||||||||||
|
||||||||||||||||
xypts = np.nan*np.ones((len(gvec_angs), 2)) | ||||||||||||||||
valid_xys, rmats_s, on_plane = _project_on_detector(*args, | ||||||||||||||||
**kwargs) | ||||||||||||||||
valid_xys, _, on_plane = _project_on_detector(*args, **kwargs) | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we just pass Can you verify that you get the same result that way? It might be faster also...
Correction: it looks like the original However, I think it still might be better to just pass the |
||||||||||||||||
xypts[on_plane, :] = valid_xys | ||||||||||||||||
|
||||||||||||||||
if do_interpolation: | ||||||||||||||||
this_img = panel.interpolate_bilinear( | ||||||||||||||||
xypts, img, | ||||||||||||||||
xypts, image_dict[detector_id], | ||||||||||||||||
pad_with_nans=pad_with_nans).reshape(self.shape) | ||||||||||||||||
else: | ||||||||||||||||
this_img = panel.interpolate_nearest( | ||||||||||||||||
xypts, img, | ||||||||||||||||
xypts, image_dict[detector_id], | ||||||||||||||||
pad_with_nans=pad_with_nans).reshape(self.shape) | ||||||||||||||||
nan_mask = np.isnan(this_img) | ||||||||||||||||
img_dict[detector_id] = np.ma.masked_array( | ||||||||||||||||
data=this_img, mask=nan_mask, fill_value=0. | ||||||||||||||||
) | ||||||||||||||||
maimg = np.ma.sum(np.ma.stack(img_dict.values()), axis=0) | ||||||||||||||||
return maimg | ||||||||||||||||
|
||||||||||||||||
return np.ma.sum(np.ma.stack(img_dict.values()), axis=0) | ||||||||||||||||
|
||||||||||||||||
def tth_to_pixel(self, tth): | ||||||||||||||||
""" | ||||||||||||||||
|
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.
Removing unnecessary variables isn't always helpful, because they can help with readability (in this case,
dummy_ome
indicates that we are making dummy omega values).