eggd800vis.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:eggd800 作者: rsprouse 项目源码 文件源码
def load_calibration():
    '''Load calibration data and calculate calibration values.'''
# TODO: handle different calibration measurements, not just one for datadir
    global p1_cal, p2_cal
    try:
        # Load the variables in 'calibration.py'.
        calglobals = runpy.run_path(
            os.path.join(datadir, 'calibration.py')
        )

        # Store the calibration data and the linear regression.
        p1_cal = dict(data=calglobals['p1_data'])
        try:
            p1_zero_idx = p1_cal['data']['refinputs'].index(0.0)
            p1_offset = p1_cal['data']['measurements'][p1_zero_idx]
        except IndexError:
            p1_offset = 0.0
        p1_cal['regression'] = stats.linregress(
            np.array(p1_cal['data']['measurements']) - p1_offset,
            np.array(p1_cal['data']['refinputs'])
        )

        p2_cal = dict(data=calglobals['p2_data'])
        try:
            p2_zero_idx = p2_cal['data']['refinputs'].index(0.0)
            p2_offset = p2_cal['data']['measurements'][p2_zero_idx]
        except IndexError:
            p2_offset = 0.0
        p2_cal['regression'] = stats.linregress(
            np.array(p2_cal['data']['measurements']) - p2_offset,
            np.array(p2_cal['data']['refinputs'])
        )
    except Exception as e:
# TODO: print info/warning?
        print(e)
        p1_cal = None
        p2_cal = None
    print('p1_cal: ', p1_cal)
    print('p2_cal: ', p2_cal)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号