當前位置: 首頁>>代碼示例>>Python>>正文


Python Drive.status方法代碼示例

本文整理匯總了Python中drive.Drive.status方法的典型用法代碼示例。如果您正苦於以下問題:Python Drive.status方法的具體用法?Python Drive.status怎麽用?Python Drive.status使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在drive.Drive的用法示例。


在下文中一共展示了Drive.status方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: SRT

# 需要導入模塊: from drive import Drive [as 別名]
# 或者: from drive.Drive import status [as 別名]
class SRT():   
    def __init__(self,mode,device,calibrationSpeeds):
        baud = 9600
        if mode == Mode.SIM:
            self.drive = Drive(device,baud,simulate=1,calibration=calibrationSpeeds)
        elif mode == Mode.LIVE:
            self.drive = Drive(device,baud,simulate=0,calibration=calibrationSpeeds, persist=False)
        self.pos = self.azalt()
        self.getCurrentPos()
        self.location = self.drive.location  #TODO - use this
        self.status = Status.INIT
        self.mode = mode

    def getCurrentPos(self):
        """
        Returns current position in azalt.
        """
        return self.pos
        
    def setCurrentPos(self, pos):
        self.pos = pos
        
    def getMode(self):
        return self.mode

    def setMode(self,mode):
        self.mode = mode

    def skycoord(self):
        """
        Returns the position information of the telescope in an astropy SkyCoord object.

        Returns
        -------
        SkyCoord : An astropy SkyCoord.
        """
        position = self.getCurrentPos()
        observatory = self.drive.location
        time = self.drive.current_time

        coord = SkyCoord(AltAz(az = position[0]*u.degree, alt = position[1]*u.degree, obstime = time, location = observatory))
        return coord
        
        
    def azalt(self):
        """
        Returns the azimuth and altitude of the SRT by calling the status() method of the drive class.
        """
        #status = self.drive.status()
        az,alt = self.drive.az, self.drive.alt
        #print("status " + "%f %f" % (az,alt))
        return (az,alt)

    def radec(self):
        """
        Returns the right ascention and declination of the SRT by calling the status() method of the drive class.
        """
        status = self.drive.status()
        ra,dec = status['ra'],status['dec']
        return (ra,dec)

    def galactic(self):
        """
        """
        return (0.00,0.00)


    def stow(self):
        """
        A wrapper function for Drive.stow().
        """
        self.setStatus(Status.SLEWING)
        if self.mode == Mode.SIM:
            self.slew((0,90))
        elif self.mode == Mode.LIVE:
            self.drive.stow()

    def home(self):
        """
        A wrapper function for Drive.home().
        """
        self.setStatus(Status.SLEWING)
        if self.mode == Mode.SIM:
            self.slew((90,0))
        elif self.mode== Mode.LIVE:
            self.drive.home()

    def calibrate(self):
        """
        A wrapper function for Drive.calibrate().
        """
        if self.mode == Mode.SIM:
            print("Calibration only works in live mode.")
        elif self.mode == Mode.LIVE:
            self.setStatus(Status.CALIBRATING)
            self.drive.calibrate()

    def slew(self,pos):
        """
        Slews to position pos in degrees.
#.........這裏部分代碼省略.........
開發者ID:acrerd,項目名稱:acreroad_1420,代碼行數:103,代碼來源:srt.py


注:本文中的drive.Drive.status方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。