manoharan-lab / holopy

Hologram processing and light scattering in python
GNU General Public License v3.0
131 stars 50 forks source link

Dimensions consistency #392

Closed mdecea closed 3 years ago

mdecea commented 3 years ago

Hello,

I just started using the package, but I came across an issue that I find a bit confusing and that, as far as I am concerned, is not mentioned anywhere: there does not seem to be consistency between dimensions in different functions/accessing operations.

Let me try to explain:

barkls commented 3 years ago

Thanks for the feedback! One reason HoloPy uses xarray is to reduce the importance of dimension ordering, since dimensions can be referred to by name rather than position. Our hope is that users don't need to worry too much about dimensions or constantly checking the shape of different objects. However, this ideal is not implemented everywhere throughout HoloPy.

Allow me to clarify the examples you mentioned:

It turns out the docstring for subimage is actually not quite correct. If center and/or shape are longer than 2, any other elements will be ignored. For example: cropped = hp.core.process.subimage(holo, center=(213, 312), shape=100), will crop a hologram to 100 pixels in each of x & y, regardless of any other dimensions the hologram may have.

You are correct that the zero_filter function assumes x and y dimensions are along axes 0 and 1. This is a bug and the function should be fixed to look at dimension names.