예제 #1
0
     def setUp(self):
         # Inputs inspired by unit tests for my Python bindings to cxform
         self.d = datetime.datetime(year=2005, month=3, day=2,
                                    hour=9, minute=28, second=11)
 
         # Pre-calculated values in a variety of coordinate systems:
         self.geo = ( -664946479.875617,  -640940392.874836,     44869503.669364 )
         self.gse = ( -920803133.4333384,  -70514255.353478357, -46054423.548106655)        
         self.gsm = ( -920803133.4333384,  -58583041.626907118, -60508655.332473055)        
         self.sm =  ( -915530691.724154,   -58583041.626907118, 115513031.39425668 )
 
         # GEOPACK constants.  These should probably be added to the GEOPACK module itself. 
         self.iGSMtoGSE = 1
         self.iGSEtoGSM = -1
 
         self.iSMtoGSM = 1
         self.iGSMtoSM = -1
 
         self.iGEOtoGSM = 1
         self.iGSMtoGEO = -1
 
         self.PERCENT_DIFFERENCE = 0.02
 
         # Must set the date & time prior to carrying out a transformation.
         geopack.recalc(self.d.year,
                        self.d.timetuple().tm_yday,
                        self.d.hour,
                        self.d.minute,
                        self.d.second)
예제 #2
0
        def test_cxform(self):
            d = datetime.datetime(year=2008,
                                  month=8,
                                  day=1,
                                  hour=0,
                                  minute=0,
                                  second=0)

            geopack.recalc(d.year,
                           d.timetuple().tm_yday, d.hour, d.minute, d.second)

            gse = (0.25, -2.63, -0.4)

            out = geopack.gsmgse(0., 0., 0., gse[0], gse[1], gse[2],
                                 self.iGSEtoGSM)
            out = geopack.smgsm(0., 0., 0., out[0], out[1], out[2],
                                self.iGSMtoSM)

            self.__assertPercentDiff(.2830, out[0])
            self.__assertPercentDiff(-2.6554, out[1])
            self.__assertPercentDiff(-0.087301346866137039, out[2])

            # Check the inverse:
            out = geopack.smgsm(out[0], out[1], out[2], 0., 0., 0.,
                                self.iSMtoGSM)
            out = geopack.gsmgse(out[3], out[4], out[5], 0., 0., 0.,
                                 self.iGSMtoGSE)

            self.__assertPercentDiff(gse[0], out[3])
            self.__assertPercentDiff(gse[1], out[4])
            self.__assertPercentDiff(gse[2], out[5])
예제 #3
0
        def test_1990s(self):
            # First day of NHL hockey season in '94-95. Stupid strike!
            d = datetime.datetime(year=1995,
                                  month=1,
                                  day=20,
                                  hour=19,
                                  minute=0,
                                  second=0)

            geopack.recalc(d.year,
                           d.timetuple().tm_yday, d.hour, d.minute, d.second)

            gse = (0.25, -2.63, -0.4)

            out = geopack.gsmgse(0., 0., 0., gse[0], gse[1], gse[2],
                                 self.iGSEtoGSM)
            out = geopack.smgsm(0., 0., 0., out[0], out[1], out[2],
                                self.iGSMtoSM)

            self.__assertPercentDiff(0.02189803712013394, out[0])
            self.__assertPercentDiff(-2.3804487166857329, out[1])
            self.__assertPercentDiff(-1.2134184699432964, out[2])

            # Check the inverse:
            out = geopack.smgsm(out[0], out[1], out[2], 0., 0., 0.,
                                self.iSMtoGSM)
            out = geopack.gsmgse(out[3], out[4], out[5], 0., 0., 0.,
                                 self.iGSMtoGSE)

            self.__assertPercentDiff(gse[0], out[3])
            self.__assertPercentDiff(gse[1], out[4])
            self.__assertPercentDiff(gse[2], out[5])
예제 #4
0
        def test_merkin(self):
            """
            Slava Merkin experienced strange behavior with cxform on
            certain inputs.  Compare those inputs here against GEOPACK.
            """
            d = datetime.datetime(year=2008,
                                  month=8,
                                  day=1,
                                  hour=0,
                                  minute=0,
                                  second=0)

            geopack.recalc(d.year,
                           d.timetuple().tm_yday, d.hour, d.minute, d.second)

            gse = (0.25, -2.63, -0.4)

            out = geopack.gsmgse(0., 0., 0., gse[0], gse[1], gse[2],
                                 self.iGSEtoGSM)
            self.__assertPercentDiff(0.25, out[0])
            self.__assertPercentDiff(-2.6556295971324912, out[1])
            self.__assertPercentDiff(-0.15662516666844989, out[2])

            out = geopack.gsmgse(out[0], out[1], out[2], 0., 0., 0.,
                                 self.iGSMtoGSE)
            self.__assertPercentDiff(gse[0], out[3])
            self.__assertPercentDiff(gse[1], out[4])
            self.__assertPercentDiff(gse[2], out[5])