Ejemplo n.º 1
0
 def initializeSensor(self, starFile=None):
     if(starFile==None)|(type(starFile) is not str):
         raise ValueError("StarSensor.initializeSensor:  An input text file is required to load stars.")
     #Handling Exception when file doesn't exist.
     if(os.path.isfile(starFile)):
         pass
     else:
         raise ValueError("StarSensor.initializeSensor:  No such file exist. Please check whether the name is correct.")
     
     self.starsCatalog = StarCatalog.StarCatalog()
     count = self.starsCatalog.loadCatalog(starFile)
     self.isInitialized = True
     return count
Ejemplo n.º 2
0
'''
Created on Sep 7, 2015

@author: XING
'''

import CA01.prod.StarCatalog as StarCatalog

# -------------- __init__ -----------------------------
# Instantiate a star catalog
stars = StarCatalog.StarCatalog()

# -------------- loadCatalog -----------------------------
# Load the catalog with a valid file
# The return value will be a count of the number of stars loaded
starCount = stars.loadCatalog(starFile="SaoChart.txt")  #(starFile="try.txt")
print starCount
# Attempts to load the catalog using a non-existent file or
# a file that does not contain legitimate star information
# should result in a ValueError exception bearing a
# diagnostic message.
try:
    stars.loadCatalog(starFile="aValidStarFile.txt")
except ValueError as e:
    diagnosticString1 = e.args[0]

# -------------- getStarCount -----------------------------
# Get a count of stars with magnitudes between 2 and 5, inclusive.
starsBetween2And5 = stars.getStarCount(2, 5)
print starsBetween2And5
# Get a count of stars with magnitudes .LE. 5.
Ejemplo n.º 3
0
'''
import CA02.prod.StarSensor as StarSensor
from CA02.prod import Environment
import CA01.prod.StarCatalog as StarCatalog
import math

ss = StarSensor.StarSensor(0.034906585)
a = ss.initializeSensor(starFile='SaoCharts.txt')

env = Environment.Environment()
a = env.getTime()
env.setRotationalPeriod(microseconds=1000000)

c = ss.configure(env)

sCat = StarCatalog.StarCatalog()
sCat.loadCatalog(starFile='SaoCharts.txt')
s = sCat.getMagnitude(0, math.pi / 2, 0.034906585)
print 24 * 60 * 60 * 1000000 / 2
print env.getTime()
print 'yo'
x = ss.serviceRequest()
print 'yo'
print x
print env.getTime()
env.incrementTime(21600000000 * 3 - env.getTime())
print 'yo'
print env.getTime()
x = ss.serviceRequest()
print x