Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix start and end times for reading csv files #51

Merged
merged 3 commits into from
Jul 16, 2024
Merged
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
7 changes: 5 additions & 2 deletions src/asleep/get_sleep.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
NON_WEAR_THRESHOLD = 3 # H
NON_WEAR_PREDICTION_FLAG = -1

START_TIME_IDX = 0
END_TIME_IDX = -1


def load_model(model_path, force_download=False):
""" Load trained model. Download if not exists. """
Expand Down Expand Up @@ -69,8 +72,8 @@ def get_parsed_data(raw_data_path, info_data_path, resample_hz, args):
data = data.reset_index()

# apply time shift
start_time = pd.to_datetime(info['StartTime'])
end_time = pd.to_datetime(info['EndTime'])
start_time = pd.to_datetime(info.get("StartTime", data["time"].iloc[START_TIME_IDX]))
end_time = pd.to_datetime(info.get("EndTime", data["time"].iloc[END_TIME_IDX]))
info['StartTime'] = start_time + datetime.timedelta(hours=time_shift)
info['EndTime'] = end_time + datetime.timedelta(hours=time_shift)
info['StartTime'] = info['StartTime'].strftime('%Y-%m-%d %H:%M:%S')
Expand Down
Loading