Skip to content

Commit

Permalink
fix: X間距過小問題(#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
Keycatowo committed Jul 26, 2023
1 parent 801b64d commit 419d7f2
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/st_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,20 @@ def show_readme(filename):
st.markdown(f.read())


def get_shift(start_time, end_time):
def get_shift(start_time, end_time, step=5):
"""
回傳從start_time到end_time的時間刻度
開頭為start_time,結尾為end_time
中間每隔1秒一個刻度
中間每隔step秒一個刻度
return: a np.array of time stamps
"""
import numpy as np
step = 1 if step < 1 else step

shift_array = np.arange(start_time, end_time, 1)
if shift_array[-1] != end_time:
shift_array = np.append(shift_array, end_time)
shift_array = np.arange(start_time, end_time, step)
if shift_array[-1] +step > end_time:
shift_array = np.append(shift_array[:-1], end_time)

shift_array = np.round(shift_array, 1)
return start_time, shift_array
Expand Down

0 comments on commit 419d7f2

Please sign in to comment.