def test500_040_ShouldReturnModulo360(self):
     angle1 = Angle.Angle()
     angle1.setDegrees(200)
     angle2 = Angle.Angle()
     angle2.setDegrees(180)
     self.assertEquals(20.0, angle1.add(angle2))
     self.assertEquals(20.0, angle1.getDegrees())
예제 #2
0
    def checkGetSightingParam(self, assLat, assLong):
        if isinstance(assLat, basestring) == False:
            return True
        if isinstance(assLong, basestring) == False:
            return True

        firstChar = assLat[0]

        if firstChar == 'N' or firstChar == 'S':
            if assLat[1:] == "0d0.0":
                return True
        else:
            # If latituade is really on equator, check legal longitude
            if assLat != "0d0.0":
                return True
            else:
                try:
                    myAngle = Angle.Angle()
                    myAngle.setDegreesAndMinutes(assLong)
                except:
                    return True
                return False
        try:
            myAngle = Angle.Angle()
            myAngle.setDegreesAndMinutes(assLat[1:])
            myAngle.setDegreesAndMinutes(assLong)
        except:
            return True

        return False
예제 #3
0
파일: Sighting.py 프로젝트: lzs0070/wbd
    def calculateCorrectedAltitude(self, assumedLatitude):
        angleGeographicLatitude = Angle.Angle()
        angleAssumedLatitude = Angle.Angle()
        angleLHA = Angle.Angle()

        angleGeographicLatitude.setDegreesAndMinutes(
            self.getGeographicLatitude())
        angleAssumedLatitude.setDegreesAndMinutes(assumedLatitude)
        angleLHA.setDegreesAndMinutes(self.getLHA())

        radianGeographicLatitude = self.DtoR(
            angleGeographicLatitude.getDegrees())
        radianAssumedLatitude = self.DtoR(angleAssumedLatitude.getDegrees())
        radianLHA = self.DtoR(angleLHA.getDegrees())

        sinlat1 = math.sin(radianGeographicLatitude)
        sinlat2 = math.sin(radianAssumedLatitude)
        sinlat = sinlat1 * sinlat2
        coslat1 = math.cos(radianGeographicLatitude)
        coslat2 = math.cos(radianAssumedLatitude)
        cosLHA = math.cos(radianLHA)
        coslat = coslat1 * coslat2 * cosLHA
        self.intermediateDistance = sinlat + coslat

        #         radianCorrectedAltitude = math.asin(math.sin(radianGeographicLatitude) * math.sin(radianAssumedLatitude) +
        #                                    math.cos(radianGeographicLatitude) * math.cos(radianAssumedLatitude) * math.cos(radianLHA))
        self.correctedAltitude = math.asin(self.intermediateDistance)

        #         angleCorrectedAltitude = Angle.Angle()
        #         angleCorrectedAltitude.setDegrees(self.RtoD(radianCorrectedAltitude))
        #         self.correctedAltitude = angleCorrectedAltitude.getString()
        #
        #         self.correctedAltitude = radianCorrectedAltitude

        a = 1
 def test600_020_ShouldReturnTotalBetween0And360(self):
     angle1 = Angle.Angle()
     angle1.setDegrees(30.0)
     angle2 = Angle.Angle()
     angle2.setDegrees(20.0)
     self.assertEquals(10.0, angle1.subtract(angle2))
     self.assertEquals(10.0, angle1.getDegrees())
 def test600_030_ShouldReturnTotalEqual0(self):
     angle1 = Angle.Angle()
     angle1.setDegrees(540.0)
     angle2 = Angle.Angle()
     angle2.setDegrees(180.0)
     self.assertEquals(0.0, angle1.subtract(angle2))
     self.assertEquals(0.0, angle1.getDegrees())
 def test500_020_ShouldReturnTotalLessThan360(self):
     angle1 = Angle.Angle()
     angle1.setDegrees(10)
     angle2 = Angle.Angle()
     angle2.setDegrees(10)
     self.assertEquals(20.0, angle1.add(angle2))
     self.assertEquals(20.0, angle1.getDegrees())
예제 #7
0
파일: Star.py 프로젝트: ascherer1993/wbd
 def __init__(self, body, date, siderealHourAngle, geographicPositionLatitude):
     self.body = body
     self.date = date
     self.siderealHourAngle = A.Angle()
     self.siderealHourAngle.setDegreesAndMinutesAllowNegatives(siderealHourAngle)
     self.geographicPositionLatitude = A.Angle()
     self.geographicPositionLatitude.setDegreesAndMinutesAllowNegatives(geographicPositionLatitude)
 def test500_030_ShouldReturnTotalEqual0(self):
     angle1 = Angle.Angle()
     angle1.setDegrees(359.5)
     angle2 = Angle.Angle()
     angle2.setDegrees(0.5)
     self.assertEquals(0.0, angle1.add(angle2))
     self.assertEquals(0.0, angle1.getDegrees())
 def test600_040_ShouldReturnModulo360WhenNegative(self):
     angle1 = Angle.Angle()
     angle1.setDegrees(0.0)
     angle2 = Angle.Angle()
     angle2.setDegrees(0.5)
     self.assertEquals(359.5, angle1.subtract(angle2))
     self.assertEquals(359.5, angle1.getDegrees())
예제 #10
0
 def test200_090_comp_wrongresultreturned(self):
     myAngle = Angle.Angle()
     otherAngle = Angle.Angle()
     myAngle.setDegreesAndMinutes("10d0.0")
     otherAngle.setDegreesAndMinutes("20d0.0")
     self.assertEquals(myAngle.compare(otherAngle), -1)
     myAngle.add(otherAngle)
     self.assertEquals(myAngle.compare(otherAngle), 0)
     myAngle.add(otherAngle)
     self.assertEquals(myAngle.compare(otherAngle), 1)
예제 #11
0
파일: Sighting.py 프로젝트: lzs0070/wbd
    def calculateLHA(self, assumedLongitude):
        angleAssumedLongitude = Angle.Angle()
        angleAssumedLongitude.setDegreesAndMinutes(assumedLongitude)
        angleGeographicLongitude = Angle.Angle()
        angleGeographicLongitude.setDegreesAndMinutes(
            self.getGeographicLongitude())

        #         a = angleGeographicLongitude.subtract(angleAssumedLongitude)
        a = angleGeographicLongitude.add(angleAssumedLongitude)

        self.LHA = angleGeographicLongitude.getString()
예제 #12
0
파일: Fix.py 프로젝트: WenyuZhu/wbd
 def getLongitude(self):
     for sighting in self.sightingList:
         if sighting.valid == True:
             angleGHA=Angle.Angle()
             GHA=angleGHA.setDegreesAndMinutes(sighting.GHA)
             angleSHA=Angle.Angle()
             SHA=angleSHA.setDegreesAndMinutes(sighting.SHA)
             longi=SHA+GHA
             angleLongi=Angle.Angle()
             angleLongi.setDegrees(longi)
             longi=angleLongi.getString()
             sighting.longitude=longi
예제 #13
0
파일: Sighting.py 프로젝트: lzs0070/wbd
    def calculateDistanceAdjustment(self):
        angleAdjustedAltitude = Angle.Angle()
        angleCorrectedAltitude = Angle.Angle()

        angleAdjustedAltitude.setDegreesAndMinutes(self.adjustedAltitude)
        angleCorrectedAltitude.setDegrees(self.RtoD(self.correctedAltitude))

        self.distanceAdjustment = angleCorrectedAltitude.getDegrees(
        ) - angleAdjustedAltitude.getDegrees()
        self.distanceAdjustment = self.RtoD(
            self.correctedAltitude) - angleAdjustedAltitude.getDegrees()
        self.distanceAdjustmentArcMin = int(round(self.distanceAdjustment *
                                                  60))

        b = 1
예제 #14
0
파일: myFixTest.py 프로젝트: lzs0070/wbd
 def test300_310_ShouldAdjustAltitude(self):
     anFix = Fix.Fix()
     anFix.setSightingFile("abc.xml")
     anFix.getSightings()
     Angle1 = Angle.Angle()
     Angle1.setDegreesAndMinutes('15d01.5')
     Angle2 = Angle.Angle()
     Angle2.setDegreesAndMinutes('45d11.9')
     adjustedAltitudes = anFix.getAdjustedAltitudes()
     Angle3 = Angle.Angle()
     Angle3.setDegreesAndMinutes(adjustedAltitudes[0])
     Angle4 = Angle.Angle()
     Angle4.setDegreesAndMinutes(adjustedAltitudes[1])
     self.assertAlmostEquals(Angle1.getDegrees(), Angle3.getDegrees())
     self.assertAlmostEquals(Angle2.getDegrees(), Angle4.getDegrees())
예제 #15
0
 def calcAdjAlt(self):
     sampAngle = Angle.Angle()
     if self.observation == "---":
         self.fullyAdjustedAlt = False
         return ValueError("Fix.setSightingFile:  error inobservartion")
     
     sampAngle.setDegreesAndMinutes(self.observation)
     otherAngle = Angle.Angle()
         
     if sampAngle.getDegrees() < 0.1:
         
         self.fullyAdjustedAlt = False
         return ValueError("Fix.setSightingFile:  Must be greater than 0.1")
    
     dip = 0
     refraction = 0
    
     try:
         if self.horizen.lower() == "natural":
             dip = -0.97/ 60
             dip = dip * math.sqrt(float(self.height))
             
     except:
         
         self.fullyAdjustedAlt = False
         return ValueError("Fix.setSightingFile:  Problems in calc dip ")
    
     try:    
 #        refraction = ( -0.00452 * pressure ) / ( 273 + celsius( temperature ) ) / tangent( altitude )                    
         a = (-0.00452 * float(self.pressure))
         b = (273 + ((float(self.temp) - 32) / 1.8))
         c = math.tan(math.radians(sampAngle.getDegrees()))
         
         refraction = a / b / c
         
     except:
         self.fullyAdjustedAlt = False
         return ValueError("Fix.setSightingFile:  Problems in calc  refraction")
    
     try:        
         otherAngle.setDegrees(dip + refraction)
         sampAngle.add(otherAngle)
         self.fullyAdjustedAlt = sampAngle
         return sampAngle        
     except:
         self.fullyAdjustedAlt = False
         return ValueError("Fix.setSightingFile:  Problems adding angles")
     return ValueError("Fix.setSightingFile:  Problems adding angles")
예제 #16
0
파일: Fix.py 프로젝트: WenyuZhu/wbd
    def getGHA(self,ariesFile):
        ariesFileContent=ariesFile.readlines()
        for dates in range(len(ariesFileContent)):
            ariesFileContent[dates]=ariesFileContent[dates][0:len(ariesFileContent[dates])-1]
        for index in range(len(ariesFileContent)):
            ariesFileContent[index]=ariesFileContent[index].split('\t')
        for sighting in self.sightingList:
            if sighting.valid == True:
                try:
                    date=sighting.date
                    year=date[0:4]
                    year=year[2:4]
                    month=date[5:7]
                    day=date[8:10]
                    time=sighting.time
                    hour=time[0:2]
                    if hour[0]=='0':
                        hour=hour[1:]
                    minute=time[3:5]
                    second=time[6:8]
                    date=month+'/'+day+'/'+year
                    GHA1=''
                    GHA2=''
                    for entry in range(len(ariesFileContent)):
                        if not self.dateNewcheck(ariesFileContent[entry][0] ):
                            raise ValueError('Fix.getSightings: Date violates the parameter specification')
                        if int(ariesFileContent[entry][1]) > 23 or int(ariesFileContent[entry][1]) <0:
                            raise ValueError('Fix.getSightings: Time violates the parameter specification')
                        if date == ariesFileContent[entry][0] and hour == ariesFileContent[entry][1]:
                            if not self.angleNewcheck(ariesFileContent[entry][2]):
                                raise ValueError('Fix.getSightings: Aries angle violates the specification')
                            GHA1=ariesFileContent[(entry)][2]
                            GHA2=ariesFileContent[(entry+1)][2]
                    past=int(minute)*60+int(second)
                    angleGHA1=Angle.Angle()
                    angleGHA2=Angle.Angle()
                    GHA1=angleGHA1.setDegreesAndMinutes(GHA1)
                    GHA2=angleGHA2.setDegreesAndMinutes(GHA2)
                    GHA=GHA1+(abs(GHA2 - GHA1)*(past/3600))
                    angleGHA = Angle.Angle()
                    angleGHA.setDegrees(GHA)
                    GHA=angleGHA.getString()
                    sighting.GHA=GHA
#                     print(sighting.GHA)
                except:
                    self.errorNumber+=1
                    sighting.valid=False
                    continue
예제 #17
0
 def calculate(self, starFileName, ariesFileName, assumedLatitude, assumedLongitude):
     sumDistanceCos = 0
     sumDistanceSin = 0
     for sighting in self.sightings:
         if sighting.getValid() == True and sighting.getReference() == True:
             sighting.calculateGeographicalPosition(starFileName, ariesFileName)
             sighting.calculateLHA(assumedLongitude)
             sighting.calculateCorrectedAltitude(assumedLatitude)
             sighting.calculateDistanceAdjustment()
             sighting.calculateAzimuthAdjustment(assumedLatitude)
             sumDistanceCos = sumDistanceCos + sighting.getDistanceAdjustmentArcMin() * sighting.getCosAzimuth()
             sumDistanceSin = sumDistanceSin + sighting.getDistanceAdjustmentArcMin() * sighting.getSinAzimuth()
     sumDistanceCos = sumDistanceCos/60
     sumDistanceSin = sumDistanceSin/60
     
     anAngle = Angle.Angle()
     anAngle.setDegreesAndMinutes(assumedLatitude)
     radianApproximateLatitude = anAngle.getDegrees() + sumDistanceCos
     if radianApproximateLatitude < 0:
         radianApproximateLatitude = -1 * radianApproximateLatitude
         prefix = '-'
     elif radianApproximateLatitude > 270:
         radianApproximateLatitude = 360 - radianApproximateLatitude
         prefix = '-'
     else:
         prefix = ''
     anAngle.setDegreesAndMinutes(assumedLongitude)
     radianApproximateLongitude = anAngle.getDegrees() + sumDistanceSin
     anAngle.setDegrees(radianApproximateLatitude)
     self.approximateLatitude = prefix + anAngle.getString()
     anAngle.setDegrees(radianApproximateLongitude)
     self.approximateLongitude = anAngle.getString()
예제 #18
0
파일: Fix.py 프로젝트: WenyuZhu/wbd
 def getAppLa(self,assumedLatitude):
     tempSum=0
     angleLa=Angle.Angle()
     asLa=self.transform(assumedLatitude)
     for sighting in self.sightingList:
         if sighting.valid == True:
             disAl=int(sighting.disAl)
             azi=angleLa.setDegreesAndMinutes(sighting.azi)
             azi=azi*math.pi/180
             tempSum=tempSum+disAl*math.cos(azi)
     asLa=tempSum/60+asLa
     if asLa<0:
         dec=asLa%-1
         dec=-dec
     else:
         dec=asLa%1
     dec=dec*60
     dec=round(dec,1)
     degree=int(asLa)
     if dec<10:
         dec='0'+str(dec)
     else:
         dec=str(dec)
     approxLa=str(degree)+'d'+dec
     return approxLa
예제 #19
0
    def __init__(self, body, date, time, observation, height, temperature,
                 pressure, horizon):
        self.body = body

        if not self._isDateFormat(date):
            raise ValueError("Sighting._init_:  Date is not valid.")
        self.date = date

        if not self._isTimeFormat(time):
            raise ValueError("Sighting._init_:  Time is not valid.")
        self.time = time

        self.observation = Angle.Angle()
        self.observation.setDegreesAndMinutes(observation)
        self.height = height

        if temperature != None and not isinstance(temperature, int):
            raise ValueError("Sighting._init_:  Temperature must be an int.")
        if temperature != None and temperature < -20 or temperature > 120:
            raise ValueError(
                "Sighting._init_:  Temperature must be GE -20 degrees and LE to 120 degrees."
            )
        self.temperature = temperature

        if pressure != None and not isinstance(pressure, int):
            raise ValueError("Sighting._init_:  Pressure must be an int.")
        self.pressure = pressure

        if (horizon.lower() != "artificial" and horizon.lower() != "natural"):
            raise ValueError("Sighting._init_:  Horizon has a bad value.")

        self.horizon = horizon
        pass
예제 #20
0
 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
예제 #21
0
 def adjustedAltitude(self, sightingDict):
     for eachSighting in sightingDict:
         attributeDict = sightingDict.get(eachSighting)
         if attributeDict.get('errorflag') == "False":
             observation = attributeDict.get(
                 'observation')  #observation value e.g "045d15.2"
             angleInstance = Angle.Angle()
             observationFloat = angleInstance.setDegreesAndMinutes(
                 observation)
             if observationFloat < 0.1:
                 raise ValueError(
                     "Fix.getSightings:  observed altitude is LT. 0.1arc-minutes!"
                 )  #???sighting error?
             height = attributeDict.get('height')
             horizon = attributeDict.get('horizon')
             dip = self.calcDip(height, horizon)  # 1. calculate dip
             temperature = attributeDict.get('temperature')
             pressure = attributeDict.get('pressure')
             refraction = self.calcRefraction(
                 temperature, pressure,
                 observationFloat)  # 2. calculate refraction
             # 3. adjustedAltitude = observationFloat + dip + refraction
             adjustedAltitude = observationFloat + dip + refraction
             angleInstance.setDegrees(adjustedAltitude)
             adjustedAltitudeFormat = angleInstance.getString()
             attributeDict['adjustedAltitude'] = adjustedAltitudeFormat
         else:
             attributeDict['adjustedAltitude'] = "None"
     return sightingDict
예제 #22
0
    def adjPos(self, geoLong, assLong, assLat, geoLat, mult = 1):        
        lha = geoLong
        lha.add(assLong)
        
        sl1 = math.sin(math.radians(geoLat.getDegrees()))
        sl2 = math.sin(math.radians(assLat.getDegrees()))
        sl = sl1 * sl2
        
        cl1 = math.cos(math.radians(geoLat.getDegrees()))
        cl2 = math.cos(math.radians(assLat.getDegrees()))
        
        coslha = math.cos(math.radians(lha.getDegrees())) 
        cl = coslha * cl1 * cl2* mult
        
        id = sl + cl
        
        corAlt = math.asin(id)
        corAltAng = lha
        
        actDeg = math.degrees(corAlt)
        
        corAltAng.setDegrees(actDeg)
        
        ### azi
        azimuth = Angle.Angle()
        numerator = sl1-(sl2 * id)
        
        denominator = (cl2 * math.cos(corAlt) * mult)
        
        res = numerator / denominator
        res = math.acos(res)
        azimuth.setDegrees(math.degrees(res))

        return (corAltAng,azimuth)
        
예제 #23
0
 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
예제 #24
0
 def test200_060_add_nothandleempty(self):
     expectedString = "Angle.add:"
     myAngle = Angle.Angle()
     with self.assertRaises(ValueError) as context:
         myAngle.add()
     self.assertEquals(expectedString,
                       context.exception.args[0][0:len(expectedString)])
 def test200_910_ShouldRaiseExceptionOnNonIntNonFloatDegrees(self):
     expectedDiag = self.className + "setDegrees:"
     anAngle = Angle.Angle()
     with self.assertRaises(ValueError) as context:
         anAngle.setDegrees("abc")
     self.assertEquals(expectedDiag,
                       context.exception.args[0][0:len(expectedDiag)])
예제 #26
0
파일: Fix.py 프로젝트: WenyuZhu/wbd
 def getLHA(self,assumedLongitude):
     for sighting in self.sightingList:
         if sighting.valid == True:
             angleLo=Angle.Angle()
             asLo=angleLo.setDegreesAndMinutes(assumedLongitude)
             Lo=angleLo.setDegreesAndMinutes(sighting.longitude)
             LHA=Lo+asLo
             sighting.LHA=LHA
예제 #27
0
 def test200_020_setDeg_RaisesTypeError(self):
     expectedString = "Angle.setDegrees:"
     myAngle = Angle.Angle()
     #Should be value errror:
     with self.assertRaises(ValueError) as context:
         myAngle.setDegrees("asdf")
     self.assertEquals(expectedString,
                       context.exception.args[0][0:len(expectedString)])
예제 #28
0
파일: __init__.py 프로젝트: onyiasogwa/wbd
    def test400_030_ShouldSetAngleWithValidXDY(self):
        anAngle = Angle.Angle()

        inputOutput = ["10d5", 10 + 5.0 / 60]

        self.assertAlmostEquals(anAngle.setDegreesAndMinutes(inputOutput[0]),
                                inputOutput[1])
        self.assertAlmostEquals(inputOutput[1], anAngle.getDegrees())
예제 #29
0
 def test400_970_ShouldRaiseExceptionOnMissingY(self):
     expectedDiag = self.className + "setDegreesAndMinutes:"
     anAngle = Angle.Angle()
     originalValue = anAngle.getDegrees()
     with self.assertRaises(ValueError) as context:
         anAngle.setDegreesAndMinutes("10d")
     self.assertEquals(expectedDiag, context.exception.args[0][0:len(expectedDiag)]) 
     self.assertAlmostEquals(originalValue, anAngle.getDegrees())  
예제 #30
0
 def test500_920_ShouldRaiseExceptionOnNonangleParm(self):
     expectedDiag = self.className + "add:"
     anAngle = Angle.Angle()
     anAngle.setDegrees(100.0)
     with self.assertRaises(ValueError) as context:
         anAngle.add(5)
     self.assertEquals(expectedDiag, context.exception.args[0][0:len(expectedDiag)])
     self.assertEquals(100.0, anAngle.getDegrees())