# Path: sensbiotk/algorithms/basic.py
# def find_peaks(sig_raw, min_peak_height, min_peak_distance, max_peak_distance):
# def find_static_periods(sig_raw, static_threshold, min_sample_duration):
# def find_static_periods_3D(sig_raw, static_threshold, min_sample_duration):
# def cut_signal(sig_time, sig_raw, time0, timef):
# def lowpass_filter(sig_raw, cuttoff_freq, samp_freq):
# def lowpass_filter2(sig_raw, cuttoff_freq, samp_freq):
# def window_mean(sig_time, sig_raw, time0, timef):
# def moving_average(sig_raw, fen):
# def moving_average2(sig_raw, fen):
# def search_maxpeak(sig_raw):
# def threshold_signal(sig_time, sig_raw, threshold):
# def threshold_under_signal(sig_time, sig_raw, threshold):
# def compute_norm(sig_raw):
# 
# Path: sensbiotk/calib/calib_acc.py
# SEP = ";"
# def scale_fit(data, constant):
# def scale_fit_norm(data, constant):
# def compute(data):
# def errorf(v_x, v_y, v_z, mxx, mxy, mxz, myy, myz, mzz, b_x, b_y, b_z):
# def jac1(v_x, v_y, v_z, mxx, mxy, mxz, b_x, b_y, b_z):
# def jac2(v_x, v_y, v_z, mxx, mxy, mxz, myy, myz, b_x, b_y, b_z):
# def jac3(v_x, v_y, v_z, mxx, mxy, mxz, myz, mzz, b_x, b_y, b_z):
# def jac4(v_x, v_y, v_z, mxy, myy, myz, b_x, b_y, b_z):
# def jac5(v_x, v_y, v_z, mxy, mxz, myy, myz, mzz, b_x, b_y, b_z):
# def jac6(v_x, v_y, v_z, mxz, myz, mzz, b_x, b_y, b_z):
# def jac7(v_x, v_y, v_z, mxx, mxy, mxz, myy, myz, mzz, b_x, b_y, b_z):
# def jac8(v_x, v_y, v_z, mxx, mxy, mxz, myy, myz, mzz, b_x, b_y, b_z):
# def jac9(v_x, v_y, v_z, mxx, mxy, mxz, myy, myz, mzz, b_x, b_y, b_z):
# def compute_simple(data):
# 
# Path: sensbiotk/calib/calib_mag.py
# SEP = ";"
# def unit_sphere_fit(data):
# def compute(data):
# 
# Path: sensbiotk/calib/calib_gyr.py
# def offset_fit(data):
# def compute(data):


import numpy as np
    import pylab as py
from sensbiotk.algorithms import basic as algo
from sensbiotk.calib import calib_acc as calib_acc
from sensbiotk.calib import calib_mag as calib_mag
from sensbiotk.calib import calib_gyr as calib_gyr
    from sensbiotk.io import iofox_deprec as fox
    from sensbiotk.io import viz
    from sensbiotk.io import iofox_deprec as fox
    from sensbiotk.io import iofox_deprec as fox
    from sensbiotk.io.uigetfile import uigetfile
    from sensbiotk.algorithms.basic import find_static_periods_3D
    from sensbiotk.io.iofox import load_foxcsvfile
    from os.path import split
    mag : numpy array of float
                 magnetometers in motion containing all the acquisition
                 on three axis
    gyr : numpy array of float
                 gyrometers data motionless containing all the acquisition
                 on three axis

    Returns
    -------
     params : numpy array of float
             [ [off_accx off_accy off_accz], offset for accelerometers
             [sca_accx sca_accy sca_accz], scale for accelerometers
             [off_magx off_magy off_magz], offset for magnetometers
             [sca_magx sca_magy sca_magz], scale for magnetometers
             [off_gyrx off_gyry off_gyrz], offset for gyrometers
             [sca_gyrx sca_gyry sca_gyrz]] scale for gyrometers

    """

    # Accelerometers calibration parameters
    offset, scale = calib_acc.compute(acc)
    params_acc = np.append([offset], [scale[0, :]], axis=0)
    params_acc = np.append(params_acc, [scale[1, :]], axis=0)
    params_acc = np.append(params_acc, [scale[2, :]], axis=0)
    # Magnetometers calibration parameters
    offset, scale = calib_mag.compute(mag)
    params_mag = np.append([offset], [scale[0, :]], axis=0)
    params_mag = np.append(params_mag, [scale[1, :]], axis=0)
    params_mag = np.append(params_mag, [scale[2, :]], axis=0)
    # Gyrometers calibration parameters

# Path: sensbiotk/algorithms/basic.py
# def find_peaks(sig_raw, min_peak_height, min_peak_distance, max_peak_distance):
# def find_static_periods(sig_raw, static_threshold, min_sample_duration):
# def find_static_periods_3D(sig_raw, static_threshold, min_sample_duration):
# def cut_signal(sig_time, sig_raw, time0, timef):
# def lowpass_filter(sig_raw, cuttoff_freq, samp_freq):
# def lowpass_filter2(sig_raw, cuttoff_freq, samp_freq):
# def window_mean(sig_time, sig_raw, time0, timef):
# def moving_average(sig_raw, fen):
# def moving_average2(sig_raw, fen):
# def search_maxpeak(sig_raw):
# def threshold_signal(sig_time, sig_raw, threshold):
# def threshold_under_signal(sig_time, sig_raw, threshold):
# def compute_norm(sig_raw):
# 
# Path: sensbiotk/calib/calib_acc.py
# SEP = ";"
# def scale_fit(data, constant):
# def scale_fit_norm(data, constant):
# def compute(data):
# def errorf(v_x, v_y, v_z, mxx, mxy, mxz, myy, myz, mzz, b_x, b_y, b_z):
# def jac1(v_x, v_y, v_z, mxx, mxy, mxz, b_x, b_y, b_z):
# def jac2(v_x, v_y, v_z, mxx, mxy, mxz, myy, myz, b_x, b_y, b_z):
# def jac3(v_x, v_y, v_z, mxx, mxy, mxz, myz, mzz, b_x, b_y, b_z):
# def jac4(v_x, v_y, v_z, mxy, myy, myz, b_x, b_y, b_z):
# def jac5(v_x, v_y, v_z, mxy, mxz, myy, myz, mzz, b_x, b_y, b_z):
# def jac6(v_x, v_y, v_z, mxz, myz, mzz, b_x, b_y, b_z):
# def jac7(v_x, v_y, v_z, mxx, mxy, mxz, myy, myz, mzz, b_x, b_y, b_z):
# def jac8(v_x, v_y, v_z, mxx, mxy, mxz, myy, myz, mzz, b_x, b_y, b_z):
# def jac9(v_x, v_y, v_z, mxx, mxy, mxz, myy, myz, mzz, b_x, b_y, b_z):
# def compute_simple(data):
# 
# Path: sensbiotk/calib/calib_mag.py
# SEP = ";"
# def unit_sphere_fit(data):
# def compute(data):
# 
# Path: sensbiotk/calib/calib_gyr.py
# def offset_fit(data):
# def compute(data):


# Path: sensbiotk/calib/calib.py
import numpy as np
    import pylab as py
from sensbiotk.algorithms import basic as algo
from sensbiotk.calib import calib_acc as calib_acc
from sensbiotk.calib import calib_mag as calib_mag
from sensbiotk.calib import calib_gyr as calib_gyr
    from sensbiotk.io import iofox_deprec as fox
    from sensbiotk.io import viz
    from sensbiotk.io import iofox_deprec as fox
    from sensbiotk.io import iofox_deprec as fox
    from sensbiotk.io.uigetfile import uigetfile
    from sensbiotk.algorithms.basic import find_static_periods_3D
    from sensbiotk.io.iofox import load_foxcsvfile
    from os.path import split

    mag : numpy array of float
                 magnetometers in motion containing all the acquisition
                 on three axis
    gyr : numpy array of float
                 gyrometers data motionless containing all the acquisition
                 on three axis

    Returns
    -------
     params : numpy array of float
             [ [off_accx off_accy off_accz], offset for accelerometers
             [sca_accx sca_accy sca_accz], scale for accelerometers
             [off_magx off_magy off_magz], offset for magnetometers
             [sca_magx sca_magy sca_magz], scale for magnetometers
             [off_gyrx off_gyry off_gyrz], offset for gyrometers
             [sca_gyrx sca_gyry sca_gyrz]] scale for gyrometers

    """

    # Accelerometers calibration parameters
    offset, scale = calib_acc.compute(acc)
    params_acc = np.append([offset], [scale[0, :]], axis=0)
    params_acc = np.append(params_acc, [scale[1, :]], axis=0)
    params_acc = np.append(params_acc, [scale[2, :]], axis=0)
    # Magnetometers calibration parameters
    offset, scale = calib_mag.compute(mag)
    params_mag = np.append([offset], [scale[0, :]], axis=0)
    params_mag = np.append(params_mag, [scale[1, :]], axis=0)
    params_mag = np.append(params_mag, [scale[2, :]], axis=0)
    # Gyrometers calibration parameters

    offset, scale = calib_gyr.compute(gyr)