Debug assignment of segments to rows

notes
Primoz 2022-10-19 13:35:04 +00:00
parent cea451d344
commit 0d81ad5756
5 changed files with 55 additions and 4 deletions

BIN
NaN.png 100644

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -5,7 +5,7 @@ PHONE:
START_DATE: 2021-05-21 09:21:24 START_DATE: 2021-05-21 09:21:24
END_DATE: 2021-07-12 17:32:07 END_DATE: 2021-07-12 17:32:07
EMPATICA: EMPATICA:
DEVICE_IDS: [empatica1] DEVICE_IDS: [uploader_53573]
LABEL: test01 LABEL: uploader_53573
START_DATE: START_DATE: 2021-05-21 09:21:24
END_DATE: END_DATE: 2021-07-12 17:32:07

View File

@ -5,15 +5,28 @@ options(scipen=999)
assign_rows_to_segments <- function(data, segments){ assign_rows_to_segments <- function(data, segments){
# This function is used by all segment types, we use data.tables because they are fast # This function is used by all segment types, we use data.tables because they are fast
print(nrow(data))
print(ncol(data))
data <- data.table::as.data.table(data) data <- data.table::as.data.table(data)
data[, assigned_segments := ""] data[, assigned_segments := ""]
for(i in seq_len(nrow(segments))) { for(i in seq_len(nrow(segments))) {
segment <- segments[i,] segment <- segments[i,]
print(segment)
print(data[segment$segment_start_ts<= timestamp & segment$segment_end_ts >= timestamp])
data[segment$segment_start_ts<= timestamp & segment$segment_end_ts >= timestamp, data[segment$segment_start_ts<= timestamp & segment$segment_end_ts >= timestamp,
assigned_segments := stringi::stri_c(assigned_segments, segment$segment_id, sep = "|")] assigned_segments := stringi::stri_c(assigned_segments, segment$segment_id, sep = "|")]
} }
data[,assigned_segments:=substring(assigned_segments, 2)] data[,assigned_segments:=substring(assigned_segments, 2)]
data data
test <- # print multiple columns
data %>%
dplyr::filter(is.na(assigned_segments))
test %>% as_tibble() %>% print(n=50)
} }
assign_to_time_segment <- function(sensor_data, time_segments, time_segments_type, include_past_periodic_segments, most_common_tz){ assign_to_time_segment <- function(sensor_data, time_segments, time_segments_type, include_past_periodic_segments, most_common_tz){

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -0,0 +1,38 @@
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import sys
df = pd.read_csv(f"/rapids/data/raw/p03/empatica_accelerometer_raw.csv")
df['date'] = pd.to_datetime(df['timestamp'],unit='ms')
df.set_index('date', inplace=True)
print(df)
df = df['double_values_0'].resample("31ms").mean()
print(df)
st='2021-05-21 12:28:27'
en='2021-05-21 12:59:12'
df = df.loc[(df.index > st) & (df.index < en)]
plt.plot(df)
plt.savefig(f'NaN.png')
sys.exit()
plt.plot(df)
esm = pd.read_csv(f"/rapids/data/raw/p03/phone_esm_raw.csv")
esm['date'] = pd.to_datetime(esm['timestamp'],unit='ms')
esm = esm[esm['date']]
esm.set_index('date', inplace=True)
print(esm)
esm = esm['esm_session'].resample("2900ms").mean()
plt.plot(esm)
plt.savefig(f'NaN.png')