magnet.py 文件源码

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

项目:Auspex 作者: BBN-Q 项目源码 文件源码
def __init__(self, calibration_file, field_getter, current_setter, current_getter, field_averages=5):
        super(Electromagnet, self).__init__()
        self.name = "Composite Magnet Instrument"
        with open(calibration_file) as cf:
            lines = [l for l in cf.readlines() if l[0] != '#']
            if len(lines) != 1:
                raise Exception("Invalid magnet control calibration file, must contain one line.")
            try:
                # Construct the fit
                poly_coeffs = np.array(lines[0].split(), dtype=np.float)
                self.current_vs_field = np.poly1d(poly_coeffs)
            except:
                raise TypeError("Could not convert calibration coefficients into list of floats")

        self.field_getter = field_getter
        self.current_setter = current_setter
        self.current_getter = current_getter

        self.field_averages = field_averages
        self.calibrated_slope = poly_coeffs[0]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号