from jeputils import *

MODULE = "Diagnostics/sig_process"

def noise_evaluation(noise):
    return call_jep(MODULE, "noise_evaluation", [to_npa(noise),])

def blm_remove_spikes(x):
    ret = call_jep(MODULE, "blm_remove_spikes", [to_npa(x),])
    return ret if ret is None or is_list(ret) else ret.data

def blm_normalize(x, q):
    ret = call_jep(MODULE, "blm_normalize", [to_npa(x), q])
    return ret if ret is None or is_list(ret) else ret.data

def motor_to_wire_cs(pos, ctype = 'u', center_pos = 0.0):
    return call_jep(MODULE, "motor_to_wire_cs", [pos, ctype, center_pos ])

def remove_beam_jitter(pos, bpm1, bpm2, d_b1_w=1, d_w_b2=1):
    ret = call_jep(MODULE, "remove_beam_jitter", [to_npa(pos),to_npa(bpm1), to_npa(bpm2), d_b1_w, d_w_b2 ])
    return ret if ret is None or is_list(ret) else ret.data

def profile_gauss_stats(x, y, off=None, amp=None, com=None, sigma=None):
    ret = call_jep(MODULE, "profile_gauss_stats", [to_npa(x), to_npa(y), off, amp, com, sigma])
    return ret if ret is None or is_list(ret) else ret.data

def profile_rms_stats(x, y, noise_std=0, n_sigma=3.5):
    return call_jep(MODULE, "profile_rms_stats", [to_npa(x), to_npa(y), noise_std, n_sigma])

