Skip to content

base ¤

Classes:

Name Description
Pulse

Pulse() ¤

Bases: object

Methods:

Name Description
correct

失真校准,从 qlispc.kernel_utils 复制而来。仅测试用,不会在实验中调用。

Source code in quark/interface/base.py
37
38
def __init__(self):
    pass

correct(points: np.ndarray, cali: dict = {}) -> np.ndarray classmethod ¤

失真校准,从 qlispc.kernel_utils 复制而来。仅测试用,不会在实验中调用。

Parameters:

Name Type Description Default
points ndarray

输入信号

required
cali dict

校准所需参数. Defaults to {}.

{}

Returns:

Type Description
ndarray

np.ndarray: 校准后信号

Source code in quark/interface/base.py
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
@classmethod
def correct(cls, points: np.ndarray, cali: dict = {}) -> np.ndarray:
    """失真校准,从 `qlispc.kernel_utils` 复制而来。仅测试用,不会在实验中调用。

    Args:
        points (np.ndarray): 输入信号
        cali (dict, optional): 校准所需参数. Defaults to {}.

    Returns:
        np.ndarray: 校准后信号
    """
    from wath.signal import (correct_reflection, exp_decay_filter,
                             predistort)

    distortion_params = cali.get('distortion', {})
    if not distortion_params:
        return points

    if not isinstance(distortion_params, dict):
        distortion_params = {}

    filters = []
    ker = None
    if 'decay' in distortion_params and isinstance(distortion_params['decay'],
                                                   (list, tuple, np.ndarray)):
        for amp, tau in distortion_params.get('decay', []):
            a, b = exp_decay_filter(amp, tau, cali['srate'])
            filters.append((b, a))

    length = len(points)
    if length > 0:
        last = points[-1]
        try:
            points = predistort(points, filters, ker, initial=last)
        except:
            points = np.hstack([np.full((length, ), last), points])
            points = predistort(points, filters, ker)[length:]
        points[-1] = last

    return points