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

Add array trimming before reshaping #731

Merged
merged 4 commits into from
Aug 5, 2019

Conversation

ronpandolfi
Copy link
Contributor

Following discussion of areaDetector/ADFastCCD#13 with @mrakitin and @stuwilkins, it was decided that it is possible for EPICS to transmit more elements than the product of its shape, as with the FastCCD and "overscan rows".

To accommodate this, the image array must be trimmed before reshaping.

(cherry picked from commit 4673d19)
@stuwilkins
Copy link
Contributor

@ronpandolfi I wonder if this will blow up if the array is < the product of the array dimensions? I just have a question if we should trap that? This is very possible if the IOC is not configured correctly.

array_shape = self.derived_shape[:self.derived_ndims]
if not any(array_shape):
raise RuntimeError(f"Invalid array size {self.derived_shape}")

array = self._derived_from.get()
return np.array(array).reshape(array_shape)
return np.array(value[:np.prod(array_shape)]).reshape(array_shape)
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't it be np.array(array[... using the array from L108? Not sure there the input value was used before.

Copy link
Member

Choose a reason for hiding this comment

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

What type is value here? If it already an array (at least sometimes, in some circumstances) using np.asarray in place of np.array will save us from making a copy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shouldn't it be np.array(array[... using the array from L108? Not sure there the input value was used before.

The array value is actually passed into this method as the value arg; there's no need to get it again, so I've removed that line.

Copy link
Member

@mrakitin mrakitin left a comment

Choose a reason for hiding this comment

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

Left my comment regarding the use of array vs. value.

It would be nice to have a test to poke this functionality. Do you think it's possible with the simulated devices?

@ronpandolfi
Copy link
Contributor Author

ronpandolfi commented Jun 19, 2019

Qingteng Zhang has also encountered this issue with a Pilatus detector:
Screen Shot 2019-06-19 at 4 29 45 PM

@danielballan
Copy link
Member

@ronpandolfi I'm up for tagging a patch release to get this out. Can you look at @mrakitin's and my comments above when you get a chance?

@ronpandolfi ronpandolfi reopened this Jun 24, 2019
@ronpandolfi
Copy link
Contributor Author

@danielballan Above comments have been addressed.

Copy link
Member

@mrakitin mrakitin left a comment

Choose a reason for hiding this comment

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

Looks good to me as long as the existing tests pass.

Is there a way to add a new test covering this fix?

@tacaswell
Copy link
Contributor

Restarted the failed test.

@mrakitin We don't have a good enough test rig for AD stuff to be worth reproducing this issue.

@mrakitin mrakitin merged commit 691193f into bluesky:master Aug 5, 2019
@ronpandolfi ronpandolfi deleted the shaped_image_truncate branch August 15, 2019 04:04
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.

5 participants