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

Issue with datacube reciprocal space calibration #708

Open
alouiset opened this issue Feb 27, 2025 · 0 comments
Open

Issue with datacube reciprocal space calibration #708

alouiset opened this issue Feb 27, 2025 · 0 comments

Comments

@alouiset
Copy link

Hi!
I want to recover the reciprocal space grid of a DataCube instance in $Å^{-1}$ with the k-space origin at the center of the diffraction pattern. But it looks like there is a problem with the DataCube.calibrate() method in reciprocal space.
After

datacube.get_probe_size()

qx0_mean and qy0_mean are well stored in datacube.calibration

Calibration( A Metadata instance called 'calibration', containing the following fields:

             Q_pixel_size:      0.00814368
             R_pixel_size:      1.04527
             Q_pixel_units:     A^-1
             R_pixel_units:     nm
             QR_flip:           False
             probe_semiangle:   2.0042072631527734
             qx0_mean:          127.4822069952262
             qy0_mean:          127.39945750064858
)

Then, when I set the pixel sizes:

Q_pixel_size = 0.00814368 # in Å^-1, calibrated on Si sample.
datacube.calibration.set_Q_pixel_size(Q_pixel_size)
datacube.calibration.set_Q_pixel_units('A^-1')

datacube.calibration.set_R_pixel_size(1.04527)
datacube.calibration.set_R_pixel_units('nm')

The reciprocal space grid is not centered at the origin like I expected:

print(datacube)
--> DataCube( A 4-dimensional array of shape (20, 160, 256, 256) called 'datacube',
          with dimensions:

              Rx = [0.0,1.04527,2.09054,...] nm
              Ry = [0.0,1.04527,2.09054,...] nm
              Qx = [-127.4822069952262,-127.4740633152262,-127.4659196352262,...] A^-1  (*non-linear*)
              Qy = [-127.39945750064858,-127.39131382064858,-127.38317014064857,...] A^-1  (*non-linear*)
)

print(datacube.qxx.min(), datacube.qxx.max())
--> -127.4822069952262 -125.40556859522621

Here, I expected datacube.qxx.min() and datacube.qxx.max() to be around -1 and +1, respectively, in $Å^{-1}$.

It looks like the problem comes from the DataCube.calibrate() method in datacube.py.
Lines 94 and 95

        dim_qx = -origin[0] + np.arange(self.Q_Nx) * qpixsize
        dim_qy = -origin[1] + np.arange(self.Q_Ny) * qpixsize

should be:

        dim_qx = ( -origin[0] + np.arange(self.Q_Nx) ) * qpixsize
        dim_qy = ( -origin[1] + np.arange(self.Q_Ny) ) * qpixsize

so qpixsize is taken into account after centering the reciprocal space origin in pixel unit.

This modification fixed the issue for me, but maybe the method is not intended to work as I want it to.
Is there something I misunderstood here or is it a problem indeed?

Thanks!

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

No branches or pull requests

1 participant