Files
past-project-past_code_cc2650/python_test_code/uni/briefly_data_analysis.py
T
YiChin2018 3f0aeb68ea Merge branch 'release/neulive' of https://gitlab.com/s880782002/bioprocc2650 into release/neulive
# Conflicts:
#	python_test_code/uni/briefly_data_analysis.py
2019-08-08 13:11:17 +08:00

52 lines
1.8 KiB
Python

import pandas as pd
import numpy as np
def main():
'''
purpose:
in order to analyze the data loss of bluetooth, a small code is needed.
Guess that there are three type of data loss. In order to prove this idea,
several tests are needed
types of data loss:
1. packet loss:
bluetooth notification does not need any negotiation.
if there is any packet loss during the connection,
it will not be lost forever
2. program delay causes loss in client(headstage):
too many effort on data packaging, it would cause
data delay
3. program delay causes loss in host(controller):
...todo and need to define
Assume that we have lost several bytes data. We want to analyze the type of data lost.
method:
compare ramp data with time stamp, there are several conditions
if data_delta * 1 / sampling rate == time_delta:
this should be packet loss
else
this should be program delay
method to coped with the corresponding problem:
1. try 'Indication' to check data loss is reduced or not.
2. modified the procedure of data packaging
3. after the upper two problems are excluded, this problem should be left over
:return:
'''
# skip header information
df = pd.read_csv("C:/Users/yichin/Downloads/last-2019-07-18-16-30-15-7.csv", sep=",", skiprows=12, header=None)
sel_df = pd.DataFrame(df)
column, row = sel_df.shape
sel_df = sel_df.fillna(value=0)
delta_df = sel_df.diff(periods=1)
delta_df = delta_df.fillna(value=0)
delta_df = delta_df.drop(column-1)
delta_df.set_axis(['time_delta', 'data_delta'], axis='columns', inplace=True)
if __name__ == '__main__':
main()