当前位置: 首页>>代码示例>>Python>>正文


Python Protocol.get_calib方法代码示例

本文整理汇总了Python中protocol.Protocol.get_calib方法的典型用法代码示例。如果您正苦于以下问题:Python Protocol.get_calib方法的具体用法?Python Protocol.get_calib怎么用?Python Protocol.get_calib使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在protocol.Protocol的用法示例。


在下文中一共展示了Protocol.get_calib方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from protocol import Protocol [as 别名]
# 或者: from protocol.Protocol import get_calib [as 别名]
class Pointer:
    def __init__(self, device='/dev/ttyUSB0', baud=115200):
        self.__hw = Protocol(device, baud)
        self.hid = self.get_id()
        self.calib = self.__get_calib()
        self.__pm = PointingModel(z1=self.calib[0], z2=self.calib[1],
                                  z3=self.calib[2])
        self.target = EqCoords(0, 0)
        self.home()

    def get_id(self):
        return self.__hw.get_id()

    def home(self):
        return self.__hw.home()

    def __get_calib(self):
        return [self.__hw.get_calib(i) for i in range(3)]

    def set_calib(self, calib):
        if len(calib) != 3:
            raise ValueError("Wrong number of calibration values")

        for i, v in enumerate(calib):
            self.__hw.set_calib(i, v)

    def set_ref(self, eq=None, inst=None, t=0):
        self.__pm.set_ref(eq or self.target, inst or self.get_inst_coords(), t)

    def get_refs(self):
        """Return a list of dictionaries, each containing the observation time,
        equatorial and instrumental coordinates of a reference star"""
        eq = self.__pm.eq_refs
        inst = self.__pm.inst_refs
        t = self.__pm.t_refs

        refs = []
        for i in range(self.__pm.get_nrefs()):
            refs.append({'eq': eq[i], 'inst': inst[i], 't': t[i]})
        return refs

    def steps(self, ha, el):
        self.__hw.move(ha, el)

    def run(self, ha_dir, el_dir):
        if not -1 <= ha_dir <= 1:
            raise ValueError("ha_dir must be between -1 and 1")
        if not -1 <= el_dir <= 1:
            raise ValueError("el_dir must be between -1 and 1")
        half = STEPS/2 - 1
        self.__hw.move(ha_dir*half, el_dir*half)

    def stop(self):
        self.__hw.stop()

    def enable_laser(self, enable):
        self.__hw.enable_laser(enable)

    def get_coords(self):
        return self.__pm.inst_to_eq(steps2rad(*self.__hw.get_pos()))

    def get_inst_coords(self):
        return Coords(*steps2rad(*self.__hw.get_pos()))

    def get_motor_pos(self):
        return self.__hw.get_pos()

    def goto(self, eq):
        self.target = eq
        self.__hw.goto(*rad2steps(*self.__pm.eq_to_inst(eq)))

    def close(self):
        self.__hw.close()
开发者ID:juanmb,项目名称:SkyPointer,代码行数:75,代码来源:pointer.py


注:本文中的protocol.Protocol.get_calib方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。