import sys, os, math, time
import numpy as np
import pandas as pd
import scipy as sp
'''
wavacc.py for interpolate accelerometer data and extract feature as stroke.
Denosing step is not implemented this module. See addValidDetection function in coordsi.py for denoising.
'''
def openDataframe(path):
    try:
        handletracedf = pd.read_csv(path)
        return handletracedf
        #implement open dataframe here
    except Exception as e:
        print(e)

def interpolation(dataframe, ):
    '''
    1. (frame, isValid, acc)
    2. scatter plot of acc if isValid == 1
    3. interpolate acc of isValid == 1.
    '''
    try:
        df = dataframe
        frame = list(df.index.values)
        acc = pd.Series.tolist(df['acceleration'])
        val = pd.Series.tolist(df['isValid'])

        merged = []
        for i in range(0, len(val)):
            merged.append([frame[i], val[i], acc[i]])
        return merged

        pass
    except Exception as e:
        print(e)
        return df
    
def decomposition(df):
    try:
        #implemnet decompositino with wavelet transform here
        pass
    except Exception as e:
        print(e)
        return df

def getStroke(df):
    try:
        #implement get stroke here
        pass
    except Exception as e:
        print(e)
        return df

def mergeToDataFrame(df):
    try:
        #implement merge to dataframe here
        pass
    except Exception as e:
        print(e)
        return df
