Пример #1
0
 def test_geopack(self):
     """GSE to SM conversion verified by Slava Merkin using GEOPACK."""
     x=0.25
     y = -2.63
     z = -0.4
     # First day of NHL hockey season in '94-95. Stupid strike!
     year = 1995
     month = 1
     day = 20
     hour = 19
     minute = 0
     second = 0
     out = cxform.transform('GSE', 'SM',
                            x,y,z,
                            year,month,day,hour,minute,second)
     self.__assertPercentDiff( 0.025938911859381325,   out[0] )
     self.__assertPercentDiff( -2.3804487166857329, out[1] )
     self.__assertPercentDiff( -1.2134184699432964,  out[2] )
     
     # Check the inverse:
     out = cxform.transform('SM', 'GSE',
                            out[0], out[1], out[2],
                            year,month,day,hour,minute,second)
     self.__assertPercentDiff( 0.25,  out[0] )
     self.__assertPercentDiff( -2.63, out[1] )
     self.__assertPercentDiff( -0.4,  out[2] )
Пример #2
0
 def test_geopack(self):
     """GSE to SM conversion verified by Slava Merkin using GEOPACK."""
     x=0.25
     y = -2.63
     z = -0.4
     year = 2008
     month = 8
     day = 1
     hour = 0
     minute = 0
     second = 0
     out = cxform.transform('GSE', 'SM',
                            x,y,z,
                            year,month,day,hour,minute,second)
     self.__assertPercentDiff( .2830,   out[0] )
     self.__assertPercentDiff( -2.6554, out[1] )
     self.__assertPercentDiff( -.0899,  out[2] )
     
     # Check the inverse:
     out = cxform.transform('SM', 'GSE',
                            out[0], out[1], out[2],
                            year,month,day,hour,minute,second)
     self.__assertPercentDiff( 0.25,  out[0] )
     self.__assertPercentDiff( -2.63, out[1] )
     self.__assertPercentDiff( -0.4,  out[2] )
Пример #3
0
 def test_2SM(self):
     out = cxform.transform('J2000', 'SM',
                            self.x, self.y, self.z,
                            self.year, self.month, self.day, self.hour, self.minute, self.second)
     self.__assertPercentDiff( -915527671.753106, out[0] )
     self.__assertPercentDiff( -52303890.6954846,  out[1] )
     self.__assertPercentDiff( 115531839.327171,  out[2] )
Пример #4
0
 def test_2GSM(self):
     out = cxform.transform('J2000', 'GSM',
                            self.x, self.y, self.z,
                            self.year, self.month, self.day, self.hour, self.minute, self.second)
     self.__assertPercentDiff( -920802840.504282, out[0] )
     self.__assertPercentDiff( -52303890.695484,  out[1] )
     self.__assertPercentDiff( -60503326.877360,  out[2] )
Пример #5
0
 def test_2GSE(self):
     out = cxform.transform('J2000', 'GSE',
                            self.x, self.y, self.z,
                            self.year, self.month, self.day, self.hour, self.minute, self.second)
     self.__assertPercentDiff( -920802840.504282, out[0] )
     self.__assertPercentDiff( -64160872.043671027, out[1] )
     self.__assertPercentDiff(  -46046221.090855, out[2] )
Пример #6
0
    def test_2GEO(self):
        out = cxform.transform('J2000', 'GEO',
                               self.x, self.y, self.z,
                               self.year, self.month, self.day, self.hour, self.minute, self.second)

        self.__assertPercentDiff( -664946479.875617, out[0] )
        self.__assertPercentDiff( -640940392.874836, out[1] )        
        self.__assertPercentDiff(   44869503.669364, out[2] )
Пример #7
0
    def test_merkin(self):
        """
        Slava Merkin was experience strange behavior with cxform on
        certain inputs.  Let's try those inputs here & see if we can
        break cxform!
        """
        x=0.25
        y = -2.63
        z = -0.4
        year = 2008
        month = 8
        day = 1
        hour = 0
        minute = 0
        second = 0

        # Transform twice in a row... make sure we get the same thing:
        out = cxform.transform('GSE', 'GSM',
                               x,y,z,
                               year,month,day, hour,minute,second)
        self.__assertPercentDiff( 0.25, out[0] )
        self.__assertPercentDiff( -2.6556295971324912, out[1] )
        self.__assertPercentDiff( -0.15662516666844989, out[2] )

        out = cxform.transform('GSE', 'GSM',
                               x,y,z,
                               year,month,day, hour,minute,second)
        self.__assertPercentDiff( 0.25, out[0] )
        self.__assertPercentDiff( -2.6556295971324912, out[1] )
        self.__assertPercentDiff( -0.15662516666844989, out[2] )

        # Now do the inverse transform & make sure we get the same thing.
        out = cxform.transform('GSM', 'GSE',
                               out[0], out[1], out[2],
                               year,month,day, hour,minute,second)
        self.__assertPercentDiff( 0.25, out[0] )
        self.__assertPercentDiff( -2.6299999999999994, out[1] )
        self.__assertPercentDiff( -0.39999999999999997, out[2] )
Пример #8
0
def coord(idSatellite, dtList):
    """Calculate spacecraft coordinates in several systems (predefined).
    For performance considerations, the TLE file is only retrieved once per
    coord() call, so if you need to process a very long time interval,
    split it into several shorter ones in order to reduce inaccuracies
    in the TLE file and make the orbital drift negligible.

    """
    res = []
    if len(dtList) == 0:
        return res
    tle = gettle(idSatellite, dtList[0]).split("\n")[:-1] # Strip the newline
    sat = ephem.readtle(tle[0], tle[1], tle[2])
    for dt in dtList:
        sat.compute(dt)
        lat, lon, alt = sat.sublat, sat.sublong, float(sat.elevation) / 1000
        lat, lon = dddmmss2dec(str(lat), str(lon))
        if lon < 0:
            lon += 360
        
        year = dt.year + float(dt.strftime("%j")) / daysinyear(dt.year)
        
        # Cartesian geographic coordinates, magnetic field components,
        # total magnetic field magnitude and the L-shell
        icode, l, b = igrf.lb(lat, lon, alt, year)
        bnorth, beast, bdown, b = igrf.b(lat, lon, alt, year)
        bx, by, bz = enu2ecef(lat, lon, alt, bnorth, beast, bdown)
        x, y, z = geodetic2ecef(lat, lon, alt)
        
        # Local time
        lt = dt + timedelta(hours = (float(lon) / 15))
        lt = lt.hour + lt.minute / 60.0 + lt.second / 3600.0 + \
            lt.microsecond / (3600000000.0)
        
        # Geomagnetic
        x, y, z = cxform.transform("GEO", "MAG", x, y, z,
            dt.year, dt.month, dt.day, dt.hour, dt.minute,
            int(round(dt.second + (dt.microsecond + 0.0) / 1000)))
        mlat, mlon = ecef2geodetic(x, y, z)
        
        res.append((lat, lon, alt, x, y, z, mlat, mlon, l, b, bx, by, bz, lt))
    return res
Пример #9
0
import cxform

def printCoordinates(system, xyz):
    print 'Input Vector (%s):\t %f\t %f\t %f' % (system, xyz[0], xyz[1], xyz[2])

base = 'J2000'
systems = ['GEO', 'GSE', 'GSM', 'SM']
year=2005
month=3
day=2
hour=9
minute=28
second=11

xyzIn = [-896921337.28302002, 220296912.43620300, 44419205.01961136]
printCoordinates(base, xyzIn)

for trans in systems:
    xyzOut = cxform.transform(base, trans, xyzIn[0], xyzIn[1], xyzIn[2], year,month,day, hour,minute,second)
    printCoordinates(trans, xyzOut)

print "Output exepected:"
print """Input Vector (J2000):\t -896921337.283020\t 220296912.436203\t 44419205.019611
Output Vector (GEO):\t -664946479.875617\t -640940392.874836\t 44869503.669364
Output Vector (GSE):\t -920802840.504282\t -70523436.668648\t -46046221.090855
Output Vector (GSM):\t -920802840.504282\t -58593148.345827\t -60503326.877360
Output Vector (SM):\t -915527671.753106\t -58593148.345827\t 115531839.327171
"""