Ptrskay3 / PySprint

Spectrally resolved interferometry for Python
https://pysprint.readthedocs.io/en/latest/
MIT License
5 stars 2 forks source link

correct_sign makes mistake on the boundaries sometimes #6

Closed Ptrskay3 closed 4 years ago

Ptrskay3 commented 4 years ago
import numpy as np
import pysprint

delays = np.array([101.855, 154.174, 240.735, 306.499, 379.487, 435.505, 483.322, 544.94, 598.399, 649.76,
                   36.709, 107.42, 188.68, 227.404, 282.263, 356.59, 430.65, 513.33 ,555.052, 627.69])
positions = np.array([8.513, 8.514, 8.515, 8.516, 8.517, 8.518, 8.519, 8.520, 8.521, 8.522, 8.511, 8.510, 8.509,
                     8.508, 8.507, 8.506, 8.505, 8.504, 8.503, 8.502])

idx = np.argsort(positions)
delays, positions = delays[idx], positions[idx]
delays = pysprint.utils.correct_sign(delays, flip_increasing=False)
print(delays)

Returns

[-627.69  -555.052 -513.33  -430.65  -356.59  -282.263 -227.404 -188.68
 -107.42    36.709  101.855  154.174  240.735  306.499  379.487  435.505  < - -
  483.322  544.94   598.399  649.76 ]
               ^
               |
               |

but it should return

[-627.69  -555.052 -513.33  -430.65  -356.59  -282.263 -227.404 -188.68
 -107.42    -36.709  101.855  154.174  240.735  306.499  379.487  435.505 < - -
  483.322  544.94   598.399  649.76 ]
               ^
               |
               |