@@ -32,7 +32,7 @@ Some are defined in the associated header file .pxd
3232
3333__author__ = " Jérôme Kieffer"
3434__contact__ = " Jerome.kieffer@esrf.fr"
35- __date__ = " 12 /11/2024 "
35+ __date__ = " 18 /11/2025 "
3636__status__ = " stable"
3737__license__ = " MIT"
3838
@@ -373,16 +373,20 @@ cdef inline floating area4(floating a0,
373373def _sp_area4 (floating a0 , floating a1 , floating b0 , floating b1 , floating c0 , floating c1 , floating d0 , floating d1 ):
374374 return area4(a0, a1, b0, b1, c0, c1, d0, d1)
375375
376- cdef inline position_t _recenter_helper(position_t azim, bint chiDiscAtPi) noexcept nogil:
376+ cdef inline position_t _recenter_helper(position_t azim,
377+ position_t period,
378+ bint chiDiscAtPi = 1 ) noexcept nogil:
377379 """ Helper function
378380 """
379- if (chiDiscAtPi and azim< 0 ) or (not chiDiscAtPi and azim< pi ):
380- return azim + twopi
381+ if (chiDiscAtPi and azim< 0 ) or (not chiDiscAtPi and azim< 0.5 * period ):
382+ return azim + period
381383 else :
382384 return azim
383385
384386
385- cdef inline position_t _recenter(position_t[:, ::1 ] pixel, bint chiDiscAtPi) noexcept nogil:
387+ cdef inline position_t _recenter(position_t[:, ::1 ] pixel,
388+ position_t pos1_period = twopi,
389+ bint chiDiscAtPi = 1 ) noexcept nogil:
386390 cdef position_t a0, a1, b0, b1, c0, c1, d0, d1, center1, area, hi
387391 a0 = pixel[0 , 0 ]
388392 a1 = pixel[0 , 1 ]
@@ -393,27 +397,29 @@ cdef inline position_t _recenter(position_t[:, ::1] pixel, bint chiDiscAtPi) noe
393397 d0 = pixel[3 , 0 ]
394398 d1 = pixel[3 , 1 ]
395399 area = area4p(a0, a1, b0, b1, c0, c1, d0, d1) # check if the quad is crossed
396- if area> 0 :
400+ if pos1_period > 0.0 and area> 0 :
397401 # area are expected to be negative except for pixel on the boundary
398- a1 = _recenter_helper(a1, chiDiscAtPi)
399- b1 = _recenter_helper(b1, chiDiscAtPi)
400- c1 = _recenter_helper(c1, chiDiscAtPi)
401- d1 = _recenter_helper(d1, chiDiscAtPi)
402+ a1 = _recenter_helper(a1, pos1_period, chiDiscAtPi)
403+ b1 = _recenter_helper(b1, pos1_period, chiDiscAtPi)
404+ c1 = _recenter_helper(c1, pos1_period, chiDiscAtPi)
405+ d1 = _recenter_helper(d1, pos1_period, chiDiscAtPi)
402406 center1 = 0.25 * (a1 + b1 + c1 + d1)
403- hi = pi if chiDiscAtPi else twopi
407+ hi = 0.5 * pos1_period if chiDiscAtPi else pos1_period
404408 if center1> hi:
405- a1 -= twopi
406- b1 -= twopi
407- c1 -= twopi
408- d1 -= twopi
409+ a1 -= pos1_period
410+ b1 -= pos1_period
411+ c1 -= pos1_period
412+ d1 -= pos1_period
409413 pixel[0 , 1 ] = a1
410414 pixel[1 , 1 ] = b1
411415 pixel[2 , 1 ] = c1
412416 pixel[3 , 1 ] = d1
413417 area = area4p(a0, a1, b0, b1, c0, c1, d0, d1)
414418 return area
415419
416- def recenter (position_t[:, ::1] pixel , bint chiDiscAtPi = 1 ):
420+ def recenter (position_t[:, ::1] pixel ,
421+ position_t pos1_period = twopi,
422+ bint chiDiscAtPi = True ):
417423 """ This function checks the pixel to be on the azimuthal discontinuity
418424 via the sign of its algebraic area and recenters the corner coordinates in a
419425 consistent manner to have all azimuthal coordinate in
@@ -424,7 +430,7 @@ def recenter(position_t[:, ::1] pixel, bint chiDiscAtPi=1):
424430 :param chiDiscAtPi: set to 0 to indicate the range goes from 0-2π instead of the default -π:π
425431 :return: signed area (approximate & negative)
426432 """
427- return _recenter(pixel, chiDiscAtPi)
433+ return _recenter(pixel, pos1_period, chiDiscAtPi)
428434
429435
430436cdef inline any_t _clip(any_t value, any_t min_val, any_t max_val) noexcept nogil:
0 commit comments