scipy 与Pandas一起寻找逆行的水星

evrscar2  于 2024-01-09  发布在  其他
关注(0)|答案(1)|浏览(162)

我的物体水星在做圆周运动,它的坐标在360度之内,如果它远离360度点(0度),探测它的反转是没有问题的。

  1. an easy case:
  2. 13.08.2010 166.41245
  3. 14.08.2010 167.00584
  4. 15.08.2010 167.53165
  5. 16.08.2010 167.98625
  6. 17.08.2010 168.36589
  7. 18.08.2010 168.66672
  8. 19.08.2010 168.88494
  9. 20.08.2010 169.01682
  10. 21.08.2010 169.05885 This is where the backward movement begins
  11. 22.08.2010 169.00792 I detect it easily
  12. 23.08.2010 168.86147
  13. 24.08.2010 168.61771
  14. 25.08.2010 168.27591
  15. 26.08.2010 167.83665

字符串
我通过寻找极端来做到这一点。

  1. from scipy.signal import argrelextrema


但是如果温度从359度降到1度,我会不断地撞车。
这里有一个系统失败的例子。它认为这是水星的逆转,虽然它只是从359度到0度。这不是倒退的开始。

  1. crash example
  2. 13.03.2010 350.60172
  3. 14.03.2010 352.53184
  4. 15.03.2010 354.47785
  5. 16.03.2010 356.43861
  6. 17.03.2010 358.41273 This is not the beginning of a backward movement (NOT MAXIMUM)
  7. 18.03.2010 0.39843 its just ingression from Pieces to Aries
  8. 19.03.2010 2.39354
  9. 20.03.2010 4.39545
  10. 21.03.2010 6.40106
  11. 22.03.2010 8.40673
  12. 23.03.2010 10.40828
  13. 24.03.2010 12.40098
  14. 25.03.2010 14.37956
  15. 26.03.2010 16.33824


所以,我需要找到一个行星的逆转点,在一个360度的圆周运动。

tv6aics1

tv6aics11#

IIUC,您可以使用阈值来避免误报:

  1. c = df['Coords']
  2. m0 = c.diff().abs().le(1) # limit the gap, threshold=1
  3. m1 = c.gt(c.shift(-1)) & c.gt(c.shift()) & m0 # upper peak ↗↘
  4. m2 = c.lt(c.shift(-1)) & c.lt(c.shift()) & m0 # lower peak ↘↗
  5. df['Reversal'] = m1|m2

字符串
输出量:

  1. >>> df
  2. Date Coords Reversal
  3. 0 13.03.2010 350.60172 False
  4. 1 14.03.2010 352.53184 False
  5. 2 15.03.2010 354.47785 False
  6. 3 16.03.2010 356.43861 False
  7. 4 17.03.2010 358.41273 False
  8. 5 18.03.2010 0.39843 False # ignore this case
  9. 6 19.03.2010 2.39354 False
  10. 7 20.03.2010 4.39545 False
  11. 8 21.03.2010 6.40106 False
  12. 9 22.03.2010 8.40673 False
  13. 10 23.03.2010 10.40828 False
  14. 11 24.03.2010 12.40098 False
  15. 12 25.03.2010 14.37956 False
  16. 13 26.03.2010 16.33824 False
  17. 14 13.08.2010 166.41245 False
  18. 15 14.08.2010 167.00584 False
  19. 16 15.08.2010 167.53165 False
  20. 17 16.08.2010 167.98625 False
  21. 18 17.08.2010 168.36589 False
  22. 19 18.08.2010 168.66672 False
  23. 20 19.08.2010 168.88494 False
  24. 21 20.08.2010 169.01682 False
  25. 22 21.08.2010 169.05885 True # real case
  26. 23 22.08.2010 169.00792 False
  27. 24 23.08.2010 168.86147 False
  28. 25 24.08.2010 168.61771 False
  29. 26 25.08.2010 168.27591 False
  30. 27 26.08.2010 167.83665 False

展开查看全部

相关问题