def test600_030_ShouldReturnCorrectSeconds(self): observation = Angle.Angle() sighting = Sighting.Sighting("test", "2005-09-15", "13:30:00", observation.getString(), 0, 72, 100, "Natural") entry = AriesEntry.AriesEntry("09/15/05", 13, observation.getString()) ariesFile = AriesEntriesList.AriesEntriesList("aries.txt") self.assertEquals(ariesFile._calculateSecondsSinceSighting(sighting, entry), 1800) pass
def test600_050_ShouldReturnCorrectAngle(self): angletest = Angle.Angle() sighting = Sighting.Sighting("test", "2017-01-01", "2:30:00", angletest.getString(), 0, 72, 100, "Natural") ariesFile = AriesEntriesList.AriesEntriesList("aries.txt") ariesGHA = ariesFile.getGreenWichHourAngle(sighting) self.assertEquals(ariesGHA.getString(), "7d31.2") pass
def test600_940_ShouldFailWhenCreatingSightingsList(self): angletest = Angle.Angle() #01/01/17 2 130d10.4 sighting = Sighting.Sighting("test", "2017-01-01", "2:30:00", angletest.getString(), 0, 72, 100, "Natural") ariesFile = AriesEntriesList.AriesEntriesList("brokenAries.txt") with self.assertRaises(ValueError) as context: ariesFile.createAriesSightingList() pass
def test600_040_ShouldReturnCorrectAngle(self): angletest = Angle.Angle() #01/01/17 2 130d10.4 sighting = Sighting.Sighting("test", "2017-01-01", "2:30:00", angletest.getString(), 0, 72, 100, "Natural") ariesFile = AriesEntriesList.AriesEntriesList("aries.txt") ariesFile.createAriesSightingList() GHA = ariesFile._getGreenWichHourAngleFromFile(sighting).getString() self.assertEquals(GHA, "130d10.4") pass
def test700_030_ShouldReturnStar(self): starsList = StarsList.StarsList("stars.txt") starsList.createStarList() angletest = Angle.Angle() sighting = Sighting.Sighting("Ankaa", "2017-01-01", "2:30:00", angletest.getString(), 0, 72, 100, "Natural") star = starsList.getStar(sighting) sidewichHourAngle = star.getSiderealHourAngle().getString() geographicPositionLatitude = star.getGeographicPositionLatitude().getString() self.assertEqual(sidewichHourAngle, "353d14.1") self.assertEqual(geographicPositionLatitude, "-42d13.4")
def _extractSighting(self, xmlSighting): height = None temperature = None pressure = None horizon = "Natural" try: body = xmlSighting.find("body").text date = xmlSighting.find("date").text time = xmlSighting.find("time").text observation = xmlSighting.find("observation").text except: raise ValueError( "SightingsList._extractSighting: The xml file did not contain a mandatory tag (body, date, time, or observation)" ) try: if xmlSighting.find("height") != None: height = float(xmlSighting.find("height").text) if xmlSighting.find("temperature") != None: temperature = int(xmlSighting.find("temperature").text) if xmlSighting.find("pressure") != None: pressure = int(xmlSighting.find("pressure").text) if xmlSighting.find("horizon") != None: horizon = xmlSighting.find("horizon").text except: raise ValueError( "SightingsList._extractSighting: There was an error in one of the tags" ) return Sighting.Sighting(body, date, time, observation, height, temperature, pressure, horizon)
def getGreenWichHourAngle(self, sighting): sighting1 = sighting self.createAriesSightingList() GHA1 = self._getGreenWichHourAngleFromFile(sighting1) sightingTimeArray = sighting.getTime().split(':') newHourValue = int(sightingTimeArray[0]) + 1 sightingTwoTime = str(newHourValue) + ":" + sightingTimeArray[1] + ":" + sightingTimeArray[2] sighting2 = S.Sighting(sighting.getBody(), sighting.getDate(), sightingTwoTime, sighting.getObservation().getString(), sighting.getHeight(), sighting.getTemperature(), sighting.getPressure(), sighting.getHorizon()) GHA2 = self._getGreenWichHourAngleFromFile(sighting2) entry = self._getClosestEntry(sighting) seconds = self._calculateSecondsSinceSighting(sighting, entry) newAngle = GHA2.getDegrees() - GHA1.getDegrees() returnValue = abs(newAngle) * (seconds / 3600.0) returnAngle = A.Angle() returnAngle.setDegrees(returnValue) return returnAngle
def setUp(self): self.className = "Fix." self.logStartString = "Start of log" self.logSightingString = "Start of sighting file" # set default log file name self.DEFAULT_LOG_FILE = "log.txt" if(os.path.isfile(self.DEFAULT_LOG_FILE)): os.remove(self.DEFAULT_LOG_FILE) # generate random log file name self.RANDOM_LOG_FILE = "log" + str(uuid.uuid4())[-12:] + ".txt" self.fix = F.Fix() self.sighting = Sighting.Sighting("BodyName", "2016-03-15", "23:15:01", "60d0.0", 10, 70, 1200, "Natural"); self.height_1 = 10 self.pressure_1 = 1200 self.temperature_1 = 70 self.altitude_1 = "60d0.0" self.horizon_1 = "natural" self.horizon_2 = "artificial"