def test_4_getMagnitude(self):
     s = StarCatalog()
     s.loadCatalog("star_file_test.txt")
     try: s.getMagnitude(50, 0, 3.14)
     except: print("Test 4.1 Passed: Invalid RightAscension")
     try: s.getMagnitude(0, 50, 3.14)
     except: print("Test 4.2 Passed: Invalid Centerpoint")
     try: s.getMagnitude(0, 0, 50)
     except: print("Test 4.3 Passed: Invalid fieldOfView")
     try: mag = s.getMagnitude(0, 3, 6)
     except: print("Test 4.4 FAILED!!!!")
     if (mag == 1):
         print("Test 4.4 Passed: Get Magnitude normal work")
     else:
         print("Test 4.4 FAILED!!!!")
 def test_1_catalog(self):
     s = StarCatalog()
     try: s.loadCatalog("ssss")
     except: print("Test 1.1 Passed: invalid file")
     try: s.loadCatalog("star_file_dupTest.txt")
     except: print("Test 1.2 Passed: Duplicate Star Detected")
     try:s.loadCatalog("star_file_test.txt")
     except: print("Test 1.3 FAILED!!!!!!")
     print ("Test 1.3 Passed: Normal functioning.")
Example #3
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
Example #4
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.
 def test_5_loadCatalog(self):
     s = StarCatalog()
     s.loadCatalog("star_file_test.txt")
     if (s.getStarCount(None, None) == 2):
         print"Test 5.1 passed: loaded 2 stars"
 def test_3_getStarCount(self):
     s = StarCatalog()
     s.loadCatalog("star_file_test.txt")
     try: s.getStarCount("hi", 1)
     except: print ("Test 3.1 Passed: Invalid LowerMagnitude")
     try: s.getStarCount(1, "lol")
     except: print ("Test 3.2 Passed: Invalid UpperMagnitude")
     try: s.getStarCount(30, 1)
     except: print ("Test 3.3 Passed: Lower Magnitude > Upper Magnitude")
     if (s.getStarCount() == 3):
         print ("Test 3.4 Passed: No params, returned all stars")
     try: count = s.getStarCount(0, 5)
     except: print("Test 3.5 failed!!!!")
     if (count == 3):
         print ("Test 3.5 passed: Normal getStarCount")
     else:
        print("Test 3.5 failed!!!!") 
 def test_2_emptyCatalog(self):
     s = StarCatalog()
     s.loadCatalog("star_file.txt")
     s.emptyCatalog()
     if (len(s.starList) == 0):
         print ("Test 2.0 Passed: Empty Catalog Worked")
Example #8
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