Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions diffractio/scalar_fields_XZ.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,19 @@
kernelRS, kernelRSinverse)
from .scalar_masks_X import Scalar_mask_X
from .scalar_sources_X import Scalar_source_X
from numba import njit

copyreg.pickle(types.MethodType, _pickle_method, _unpickle_method)

percentage_intensity_config = CONF_DRAWING['percentage_intensity']

@njit(parallel=True, nogil=True)
def _rotate_numba(X, Z, angle, x0, z0):
"""Numba-accelerated rotation computation"""
Xrot = x0 + (X - x0) * np.cos(angle) + (Z - z0) * np.sin(angle)
Zrot = z0 - (X - x0) * np.sin(angle) + (Z - z0) * np.cos(angle)
return Xrot, Zrot

class Scalar_field_XZ():
"""Class for working with XZ scalar fields.

Expand Down Expand Up @@ -300,11 +308,7 @@ def __rotate__(self, angle: float, position=None):
# Definicion de la rotation
x0, z0 = position

Xrot = x0 + (self.X - x0) * np.cos(angle) + (self.Z -
z0) * np.sin(angle)
Zrot = z0 - (self.X - x0) * np.sin(angle) + (self.Z -
z0) * np.cos(angle)
return Xrot, Zrot
return _rotate_numba(self.X, self.Z, angle, x0, z0)


def size(self, verbose: bool = False):
Expand Down