Possible To Import Two Line Element (TLE) Sets??

General help that does not fall into a more specific category

Possible To Import Two Line Element (TLE) Sets??

Postby CharlesInHouston » Wed Jan 28, 2015 4:58 am

All -

Hmmm. I thought I already submitted this, if this is a duplicate forgive me.

I would like to import Two Line Element (TLE) sets, the most common format that I have come across. They are commonly available from the JSpOC, Space-track.org. I would like to go to Space-track.org, download some TLEs, and import them into GMAT. Otherwise you have to convert them and type them in by hand.
Charles D Phillips
CEO
Intelligent Commercial Spaceflight, LLC
CharlesInHouston
 
Posts: 9
Joined: Sat Aug 30, 2014 9:59 pm

Re: Possible To Import Two Line Element (TLE) Sets??

Postby bg2k6 » Sat Jan 31, 2015 8:08 am

You have to be careful, as it is not as simple as just plugging in elements.

http://www.celestrak.com/columns/v04n05/index.asp#FAQ05

So you probably can't use the data for high precision work.

However, I think it would be interesting to have this capability as well.
bg2k6
 
Posts: 5
Joined: Wed Jan 21, 2015 11:15 pm

Re: Possible To Import Two Line Element (TLE) Sets??

Postby CharlesInHouston » Sun Feb 01, 2015 4:45 pm

bg2k6 said:

bg2k6 wrote:You have to be careful, as it is not as simple as just plugging in elements.

http://www.celestrak.com/columns/v04n05/index.asp#FAQ05

So you probably can't use the data for high precision work.

However, I think it would be interesting to have this capability as well.


And I certainly understand the concern - but this is for generating an approximate answer. The TLEs are not high quality (not that I am disparaging them, they do what they are designed for) and cannot be used to propagate very far.

I guess I will post another question - where can you get GMAT-friendly Keplerian (etc) orbital elements for common spacecraft like ISS??
Charles D Phillips
CEO
Intelligent Commercial Spaceflight, LLC
CharlesInHouston
 
Posts: 9
Joined: Sat Aug 30, 2014 9:59 pm

Re: Possible To Import Two Line Element (TLE) Sets??

Postby CharlesInHouston » Sun Feb 01, 2015 7:46 pm

Ok, I feel foolish. I had seen the JSC Human Spaceflight page:

http://spaceflight.nasa.gov/realdata/elements/

but had not realized that you have to click on the little, gray and green, planet looking thing on the right. There you will find various versions of the ISS Keplerian elements.
Charles D Phillips
CEO
Intelligent Commercial Spaceflight, LLC
CharlesInHouston
 
Posts: 9
Joined: Sat Aug 30, 2014 9:59 pm

Re: Possible To Import Two Line Element (TLE) Sets??

Postby bg2k6 » Mon Feb 02, 2015 12:14 pm

Here is a FORTRAN code that I wrote to read a TLE from a text file and calculate everything that GMAT would need for Keplerian elements. I haven't fully tested it yet, so please use at your own risk.

Obviously, I can improve it to output to a text file in the GMAT Script language.

Should I output only the relevant lines, or should it generate an entire default script using the elements from the TLE?

Code: Select all
!Converts data from a NORAD TLE to orbital elements in the NASA GMAT format (eventually)
! USE AT YOUR OWN RISK


program TLEtoGMAT

implicit none

 integer, parameter  :: ikind=selected_real_kind(p=15)
 character :: File*100, Title*24,Line1*69,Line2*69
 integer EpochY
 real (kind=ikind) :: EpochD, Inc, RAAN, ECC, AoP, MA, MM, TA, SMA, MJD, degrees, radians, TAfromMA, SMAfromMM, MJDfromEpoch 


print *, 'Enter the name of the file that contains the TLE set'
print *, 'Include the file extension'
print *, ''


read *, File
!File = 'ISSTLE.txt'

print *, ''
!open(10,file= File)
   !read(10,100) Title , Line1, Line2
    !100 FORMAT (A24,/,A69,/,A69)
   !print 100, Title, Line1, Line2
   !print *, ''

open(11,file= File)
   read(11, 101) EpochY,EpochD,Inc,RAAN,ECC,AoP,MA,MM
   
   101 FORMAT(/,18x,I2,F12.8,/,8x,F8.4,1x,F8.4,1x,F7.7,1x,F8.4,1x,F8.4,1X,F11.8)
    102 FORMAT(F8.4)
    103 FORMAT(I4)
   104 FORMAT(F12.8)
   105 FORMAT(F8.7)
    106 FORMAT(F11.8)
    107 FORMAT(F15.4)

   !If Epoch year is from 00-56, then a 21st century date is assumed (2000-2056)
   !If Epoch year is from 57-99, then a 20th century date is assumed (1957-1999)
   !(There were no known artificial satellites before 1957)
   IF (EpochY <= 56) THEN      
      EpochY = 2000+EpochY
       
       ELSE
      
       EpochY = 1900+EpochY
   END IF
   
   PRINT *, 'The Epoch Year is'
   PRINT 103, EpochY
   
   PRINT *, 'The Epoch Day is'
    PRINT 104, EpochD

   PRINT *, 'The inclination is'
   PRINT 102, INC
   
   PRINT *, 'The right ascension of the ascending node is'
   PRINT 102, RAAN

   PRINT *, 'The Eccentricity is'
   PRINT 105, ECC
   
   PRINT *, 'The arguement of perigee is'
   PRINT 102, AoP
   
   PRINT *, 'The mean anomaly is'
   PRINT 102, MA

    PRINT *, 'The mean motion is'
   PRINT 106, MM

   !Get True Anomaly
    TA = TAfromMA(MA, ECC)
    PRINT *, 'The true anomaly is'
   PRINT 102, TA

    ! Get semi-major axis
    SMA = SMAfromMM(MM)
   PRINT *, 'The semi-major axis is'
   PRINT 107, SMA

   !Get the MJD of the Epoch in GMAT format
      MJD = MJDfromEpoch(EpochY, EpochD)
   PRINT *, 'The Epoch MJD (GMAT version)is '
   PRINT *,  MJD

 end program TLEtoGMAT

!#################################################################################
!---------------------------------------------------------------------------------
! Calculate True Anomaly given Mean Anomaly
! Mean Anomaly is a transendental function of True Anomaly
! True Anomaly cannot be solved for directly   
! True Anomaly is calculated here using a numerical method by Newton   
 function TAfromMA(ma,ecc)
    implicit none

   integer, parameter  :: ikind=selected_real_kind(p=15)
    integer :: i
      real (kind=ikind) ::  ma,ecc,ta,ea,TAfromMA,numerator,denominator,degrees,radians,pi
   
   pi=4.0*atan(1.0)

   ! Initialize Eccentric Anomaly with Mean Anomaly Value
   ! Use radians to do trig
   ma = radians(ma)
   ea = ma
   
    do i = 0, 6
      numerator = ea-(ecc*sin(ea))-ma
        denominator = 1-(ecc*cos(ea))
      ea = ea-(numerator/denominator)
    end do

   numerator = cos(ea)-ecc
   denominator = 1-(ecc*cos(ea))
   
   ta = acos(numerator/denominator) 

   
   ! A correction is needed for true anomalies greater than 180 degrees
   IF (ma > pi) THEN
      
   ta = pi+(pi-ta)      
   
   END IF

   TAfromMA = degrees(ta)
   
 end function TAfromMA
 !---------------------------------------------------------------------------------
 !---------------------------------------------------------------------------------
 function radians(degrees)
   implicit none
   !    returns radians
   integer, parameter  :: ikind=selected_real_kind(p=15)
   real (kind=ikind) ::  pi,degrees,radians
   pi=4.0*atan(1.0)
   radians=(degrees*pi/180.0)
end function radians
!---------------------------------------------------------------------------------
!---------------------------------------------------------------------------------
function degrees(radians)
   implicit none
   !    returns degrees
   integer, parameter  :: ikind=selected_real_kind(p=15)
   real (kind=ikind) ::  pi,degrees,radians
   pi=4.0*atan(1.0)
   degrees=(radians*180.0/pi)
end function degrees
!---------------------------------------------------------------------------------
!---------------------------------------------------------------------------------
function SMAfromMM(mm)
   implicit none
   
   integer, parameter  :: ikind=selected_real_kind(p=15)
   real (kind=ikind) :: pi,mm,mu, SMAfromMM

pi=4.0*atan(1.0)

! Standard Gravitational Parameter for Earth (km^3/s^2)
mu = 398600.4418

! Convert Mean motion from revs/day to rad/s 
mm = mm*((2*pi)/86400)


SMAfromMM = (mu/(mm**2))**(1.0/3.0)

end function SMAfromMM
!---------------------------------------------------------------------------------
!---------------------------------------------------------------------------------
function MJDfromEpoch (epochY, epochD)
   implicit none
   
    integer, parameter  :: ikind=selected_real_kind(p=15)
   real (kind=ikind) :: MJDfromEpoch, epochD, JD, offset
    ! a,y,and m as defined in algorithm
    ! mFunc, y_4, y_100, y_400 are terms used to calculate JDN but must be truncated to integers first
   integer :: epochY, a ,y, m, JDN, mFunc, y_4, y_100, y_400
 
   ! First compute the Julian Day (JD) of the start of January 1 of the Epoch year   
   ! Algorithm by Computer Science Department at the University of Texas, San Antonio
   ! http://www.cs.utsa.edu/~cs1063/projects/Spring2011/Project1/jdn-explanation.html
     
   a = (14-1)/12
    y = epochY + 4800 - a
    m = 1 + (12*a)-3
   
   mFunc = (153*m+2)/5
   y_4 = y/4
    y_100 = y/100
    y_400 = y/400

    JDN = 1 + mFunc + (365*y) + y_4 - y_100 + y_400 - 32045
    JD = JDN + ((0-12.0)/24.0)

    ! In TLE format, the Epoch day for January 1 is 001.xxx
    ! Need 000.xxx to be January 1 in JD format
   epochD = epochD-1.0
   
   ! The Julian Day of the Epoch
   JD = JD + epochD

   ! The "standard" MJD offset is  2400000.5
    !offset = 2400000.5   

   !   GMAT uses a non-standard MJD offset of 2430000.0
   offset = 2430000.0

      MJDfromEpoch = JD - offset

end function MJDfromEpoch
!---------------------------------------------------------------------------------
 
bg2k6
 
Posts: 5
Joined: Wed Jan 21, 2015 11:15 pm

Re: Possible To Import Two Line Element (TLE) Sets??

Postby CharlesInHouston » Mon Feb 02, 2015 3:51 pm

bg2k6 said:

bg2k6 wrote:Here is a FORTRAN code that I wrote to read a TLE from a text file and calculate everything that GMAT would need for Keplerian elements. I haven't fully tested it yet, so please use at your own risk.

Obviously, I can improve it to output to a text file in the GMAT Script language.

Should I output only the relevant lines, or should it generate an entire default script using the elements from the TLE?

Code: Select all
!Converts data from a NORAD TLE to orbital elements in the NASA GMAT format (eventually)
! USE AT YOUR OWN RISK


program TLEtoGMAT

implicit none

 integer, parameter  :: ikind=selected_real_kind(p=15)
 character :: File*100, Title*24,Line1*69,Line2*69
 integer EpochY
 real (kind=ikind) :: EpochD, Inc, RAAN, ECC, AoP, MA, MM, TA, SMA, MJD, degrees, radians, TAfromMA, SMAfromMM, MJDfromEpoch 

snip



So far I am just typing the Keplerians in - a laborious and error prone task - and have not looked at what the script language could do. That does sound appealing, if we could just point GMAT to another file and have it automatically suck up the new object.

That is what I do with Predict, just save a TLE in another file and have GPredict import it.

Perhaps later you could do something that imported the higher accuracy vectors that I have found for ISS, for PlanetLabs, etc. But there will always be a need to import the JSpOC TLEs since there are TLEs for so many spacecraft.
Charles D Phillips
CEO
Intelligent Commercial Spaceflight, LLC
CharlesInHouston
 
Posts: 9
Joined: Sat Aug 30, 2014 9:59 pm

Re: Possible To Import Two Line Element (TLE) Sets??

Postby bg2k6 » Wed Feb 04, 2015 11:17 am

You can try this, but again, it is yet to be fully tested. It is a stand-alone FORTRAN program for now. It will read a TLE from a user specified file (only one and it must include the header). Then, it can create a script file that can be opened normally by GMAT. The mission created will be exactly the same as the default GMAT mission, except that the Epoch and orbital elements will come from the TLE.

This might save you some time.


Code: Select all
!Converts data from a NORAD TLE to orbital elements in the NASA GMAT format
! USE AT YOUR OWN RISK

!#################################################################################
program TLEtoGMAT

   implicit none

   integer, parameter  :: ikind=selected_real_kind(p=15)
   character :: File*100,Script*100 !, Title*24,Line1*69,Line2*69
   integer :: EpochY, writeToScript
   real (kind=ikind) :: EpochD, Inc, RAAN, ECC, AoP, MA, MM, TA, SMA, MJD, TAfromMA, SMAfromMM, MJDfromEpoch 


   print *, 'Enter the name of the file that contains the TLE set'
   print *, 'Include the file extension'
   print *, ''


   read *, File
   !File = 'ISSTLE.txt'

   print *, ''
   
   !open(10,file= File)
   !read(10,100) Title , Line1, Line2
    !100 FORMAT (A24,/,A69,/,A69)
   !print 100, Title, Line1, Line2
   !print *, ''

   open(11,file = File)
   read(11, 101) EpochY,EpochD,Inc,RAAN,ECC,AoP,MA,MM
   
   101 FORMAT(/,18x,I2,F12.8,/,8x,F8.4,1x,F8.4,1x,F7.7,1x,F8.4,1x,F8.4,1X,F11.8)
    102 FORMAT(F8.4)
    103 FORMAT(I4)
   104 FORMAT(F12.8)
   105 FORMAT(F8.7)
    106 FORMAT(F11.8)
    107 FORMAT(F15.4)
    108 FORMAT(F15.9)

   !If Epoch year is from 00-56, then a 21st century date is assumed (2000-2056)
   !If Epoch year is from 57-99, then a 20th century date is assumed (1957-1999)
   !(There were no known artificial satellites before 1957)
   IF (EpochY <= 56) THEN      
      EpochY = 2000+EpochY
       
       ELSE
      
       EpochY = 1900+EpochY
   END IF
   
   PRINT *, 'The Epoch Year is'
   PRINT 103, EpochY
   
   PRINT *, 'The Epoch Day is'
    PRINT 104, EpochD

   PRINT *, 'The inclination is'
   PRINT 102, INC
   
   PRINT *, 'The right ascension of the ascending node is'
   PRINT 102, RAAN

   PRINT *, 'The Eccentricity is '
   PRINT 105, ECC
   
   PRINT *, 'The argument of perigee is'
   PRINT 102, AoP
   
   PRINT *, 'The mean anomaly is'
   PRINT 102, MA

    PRINT *, 'The mean motion is'
   PRINT 106, MM

   !Get True Anomaly
    TA = TAfromMA(MA, ECC)
    PRINT *, 'The true anomaly is'
   PRINT 102, TA

    ! Get semi-major axis
    SMA = SMAfromMM(MM)
   PRINT *, 'The semi-major axis is'
   PRINT 107, SMA

   !Get the MJD of the Epoch in GMAT format
      MJD = MJDfromEpoch(EpochY, EpochD)
   PRINT *, 'The Epoch MJD (GMAT version)is '
   PRINT 108,  MJD

    PRINT *, '*******************************'

    PRINT *, ''
   
   PRINT *, '%General Mission Analysis Tool(GMAT) Script'
    PRINT *, '%Created by TLEtoGMAT'
   

    PRINT *, ''
    PRINT *, ''

    PRINT *, '%----------------------------------------'
    PRINT *, '%---------- Spacecraft'
    PRINT *, '%----------------------------------------'

   PRINT *, ''
   
   PRINT *, 'Create Spacecraft DefaultSC;'
   PRINT *, 'GMAT DefaultSC.DateFormat = UTCModJulian;'
 
   109 FORMAT(A23, 1x, A1, F14.8,A1, A1)
   PRINT 109, 'GMAT DefaultSC.Epoch =' , '''', MJD, '''', ';'

   
   PRINT *, 'GMAT DefaultSC.CoordinateSystem = EarthMJ2000Eq;'
   PRINT *, 'GMAT DefaultSC.DisplayStateType = Keplerian;'

   110 FORMAT(A21, 1x, F13.5, A1)
   PRINT 110,' GMAT DefaultSC.SMA =', SMA, ';'

   111 FORMAT(A21, 1x, F9.7, A1)
    PRINT 111, 'GMAT DefaultSC.ECC =', ECC, ';'

   112 FORMAT(A21, 1x, F8.4, A1)
   PRINT 112, 'GMAT DefaultSC.INC =', INC, ';'

    113 FORMAT(A22, 1x, F8.4, A1)
   PRINT 113, 'GMAT DefaultSC.RAAN =', RAAN, ';'
 
    PRINT 112, 'GMAT DefaultSC.AOP =', AOP, ';'

   114 FORMAT(A20, 1x, F8.4, A1)
    PRINT 114, 'GMAT DefaultSC.TA =', TA, ';' 
   

   PRINT *,''
    PRINT *,''
   
   PRINT *,'Enter 1 to output GMAT script to file'
    PRINT *,'Anything else to quit'
   READ *, writeToScript

    IF (writeToScript == 1) THEN
       
      PRINT *, 'Enter name of script file to create'
       READ *, Script
      OPEN(12,file = Script)

      WRITE(12,*)'%General Mission Analysis Tool(GMAT) Script'
      WRITE(12,*)'%Created by TLEtoGMAT'
   

       WRITE(12,*) ''
          WRITE(12,*) ''

       WRITE(12,*) '%----------------------------------------'
       WRITE(12,*) '%---------- Spacecraft'
       WRITE(12,*) '%----------------------------------------'

      WRITE(12,*) ''
   
      WRITE(12,*) 'Create Spacecraft DefaultSC;'
      WRITE(12,*) 'GMAT DefaultSC.DateFormat = UTCModJulian;'
 
      WRITE(12,109) 'GMAT DefaultSC.Epoch =' , '''', MJD, '''', ';'

      WRITE(12,*) 'GMAT DefaultSC.CoordinateSystem = EarthMJ2000Eq;'
      WRITE(12,*) 'GMAT DefaultSC.DisplayStateType = Keplerian;'

      ! This Block is orbital elements as read from the TLE
      WRITE(12,110)' GMAT DefaultSC.SMA =', SMA, ';'
       WRITE(12,111) 'GMAT DefaultSC.ECC =', ECC, ';'
      WRITE(12,112) 'GMAT DefaultSC.INC =', INC, ';'
      WRITE(12,113) 'GMAT DefaultSC.RAAN =', RAAN, ';'
       WRITE(12,112) 'GMAT DefaultSC.AOP =', AOP, ';'
       WRITE(12,114) 'GMAT DefaultSC.TA =', TA, ';'

      ! This block sets up the rest of the default mission
      WRITE(12,*)'GMAT DefaultSC.DryMass = 850;'
      WRITE(12,*)'GMAT DefaultSC.Cd = 2.2;'
      WRITE(12,*)'GMAT DefaultSC.Cr = 1.8;'
      WRITE(12,*)'GMAT DefaultSC.DragArea = 15;'
      WRITE(12,*)'GMAT DefaultSC.SRPArea = 1;'
      WRITE(12,*)'GMAT DefaultSC.NAIFId = -123456789;'
      WRITE(12,*)'GMAT DefaultSC.NAIFIdReferenceFrame = -123456789;'
      WRITE(12,*)'GMAT DefaultSC.OrbitColor = Red;'
      WRITE(12,*)'GMAT DefaultSC.TargetColor = Teal;'
      WRITE(12,*)'GMAT DefaultSC.Id = ''SatId'';'
      WRITE(12,*)'GMAT DefaultSC.Attitude = CoordinateSystemFixed;'
      WRITE(12,*)'GMAT DefaultSC.SPADSRPScaleFactor = 1;'
      WRITE(12,*)'GMAT DefaultSC.ModelFile = ''../data/vehicle/models/aura.3ds'';'
      WRITE(12,*)'GMAT DefaultSC.ModelOffsetX = 0;'
      WRITE(12,*)'GMAT DefaultSC.ModelOffsetY = 0;'
      WRITE(12,*)'GMAT DefaultSC.ModelOffsetZ = 0;'
      WRITE(12,*)'GMAT DefaultSC.ModelRotationX = 0;'
      WRITE(12,*)'GMAT DefaultSC.ModelRotationY = 0;'
      WRITE(12,*)'GMAT DefaultSC.ModelRotationZ = 0;'
      WRITE(12,*)'GMAT DefaultSC.ModelScale = 3;'
      WRITE(12,*)'GMAT DefaultSC.AttitudeDisplayStateType = ''Quaternion'';'
      WRITE(12,*)'GMAT DefaultSC.AttitudeRateDisplayStateType = ''AngularVelocity'';'
      WRITE(12,*)'GMAT DefaultSC.AttitudeCoordinateSystem = EarthMJ2000Eq;'
      WRITE(12,*)'GMAT DefaultSC.EulerAngleSequence = ''321'';'

        WRITE(12,*) ''

      WRITE(12,*)'%----------------------------------------'
      WRITE(12,*)'%---------- ForceModels'
      WRITE(12,*)'%----------------------------------------'

      WRITE(12,*) ''
       
      WRITE(12,*)'Create ForceModel DefaultProp_ForceModel;'
      WRITE(12,*)'GMAT DefaultProp_ForceModel.CentralBody = Earth;'
      WRITE(12,*)'GMAT DefaultProp_ForceModel.PrimaryBodies = {Earth};'
      WRITE(12,*)'GMAT DefaultProp_ForceModel.Drag = None;'
      WRITE(12,*)'GMAT DefaultProp_ForceModel.SRP = Off;'
      WRITE(12,*)'GMAT DefaultProp_ForceModel.RelativisticCorrection = Off;'
      WRITE(12,*)'GMAT DefaultProp_ForceModel.ErrorControl = RSSStep;'
      WRITE(12,*)'GMAT DefaultProp_ForceModel.GravityField.Earth.Degree = 4;'
      WRITE(12,*)'GMAT DefaultProp_ForceModel.GravityField.Earth.Order = 4;'
      WRITE(12,*)'GMAT DefaultProp_ForceModel.GravityField.Earth.PotentialFile = ''JGM2.cof'';'
      WRITE(12,*)'GMAT DefaultProp_ForceModel.GravityField.Earth.EarthTideModel = ''None'';'

      WRITE(12,*) ''
       
      WRITE(12,*)'%----------------------------------------'
      WRITE(12,*)'%---------- Propagators'
      WRITE(12,*)'%----------------------------------------'

      WRITE(12,*) ''
       
      WRITE(12,*)'Create Propagator DefaultProp;'
      WRITE(12,*)'GMAT DefaultProp.FM = DefaultProp_ForceModel;'
      WRITE(12,*)'GMAT DefaultProp.Type = RungeKutta89;'
      WRITE(12,*)'GMAT DefaultProp.InitialStepSize = 60;'
      WRITE(12,*)'GMAT DefaultProp.Accuracy = 9.999999999999999e-012;'
      WRITE(12,*)'GMAT DefaultProp.MinStep = 0.001;'
      WRITE(12,*)'GMAT DefaultProp.MaxStep = 2700;'
      WRITE(12,*)'GMAT DefaultProp.MaxStepAttempts = 50;'
      WRITE(12,*)'GMAT DefaultProp.StopIfAccuracyIsViolated = true;'

      WRITE(12,*)''

      WRITE(12,*)'%----------------------------------------'
      WRITE(12,*)'%---------- Burns'
      WRITE(12,*)'%----------------------------------------'

      WRITE(12,*)''

      WRITE(12,*)'Create ImpulsiveBurn DefaultIB;'
      WRITE(12,*)'GMAT DefaultIB.CoordinateSystem = Local;'
      WRITE(12,*)'GMAT DefaultIB.Origin = Earth;'
      WRITE(12,*)'GMAT DefaultIB.Axes = VNB;'
      WRITE(12,*)'GMAT DefaultIB.Element1 = 0;'
      WRITE(12,*)'GMAT DefaultIB.Element2 = 0;'
      WRITE(12,*)'GMAT DefaultIB.Element3 = 0;'
      WRITE(12,*)'GMAT DefaultIB.DecrementMass = false;'
      WRITE(12,*)'GMAT DefaultIB.Isp = 300;'
      WRITE(12,*)'GMAT DefaultIB.GravitationalAccel = 9.810000000000001;'
      
      WRITE(12,*)''
       
      WRITE(12,*)'%----------------------------------------'
      WRITE(12,*)'%---------- Subscribers'
      WRITE(12,*)'%----------------------------------------'

      WRITE(12,*)''

      WRITE(12,*)'Create OrbitView DefaultOrbitView;'
      WRITE(12,*)'GMAT DefaultOrbitView.SolverIterations = Current;'
      WRITE(12,*)'GMAT DefaultOrbitView.UpperLeft = [ 0 0 ];'
      WRITE(12,*)'GMAT DefaultOrbitView.Size = [ 0 0 ];'
      WRITE(12,*)'GMAT DefaultOrbitView.RelativeZOrder = 0;'
      WRITE(12,*)'GMAT DefaultOrbitView.Maximized = false;'
      WRITE(12,*)'GMAT DefaultOrbitView.Add = {DefaultSC, Earth};'
      WRITE(12,*)'GMAT DefaultOrbitView.CoordinateSystem = EarthMJ2000Eq;'
      WRITE(12,*)'GMAT DefaultOrbitView.DrawObject = [ true true ];'
      WRITE(12,*)'GMAT DefaultOrbitView.DataCollectFrequency = 1;'
      WRITE(12,*)'GMAT DefaultOrbitView.UpdatePlotFrequency = 50;'
      WRITE(12,*)'GMAT DefaultOrbitView.NumPointsToRedraw = 0;'
      WRITE(12,*)'GMAT DefaultOrbitView.ShowPlot = true;'
      WRITE(12,*)'GMAT DefaultOrbitView.ShowLabels = true;'
      WRITE(12,*)'GMAT DefaultOrbitView.ViewPointReference = Earth;'
      WRITE(12,*)'GMAT DefaultOrbitView.ViewPointVector = [ 30000 0 0 ];'
      WRITE(12,*)'GMAT DefaultOrbitView.ViewDirection = Earth;'
      WRITE(12,*)'GMAT DefaultOrbitView.ViewScaleFactor = 1;'
      WRITE(12,*)'GMAT DefaultOrbitView.ViewUpCoordinateSystem = EarthMJ2000Eq;'
      WRITE(12,*)'GMAT DefaultOrbitView.ViewUpAxis = Z;'
      WRITE(12,*)'GMAT DefaultOrbitView.EclipticPlane = Off;'
      WRITE(12,*)'GMAT DefaultOrbitView.XYPlane = On;'
      WRITE(12,*)'GMAT DefaultOrbitView.WireFrame = Off;'
      WRITE(12,*)'GMAT DefaultOrbitView.Axes = On;'
      WRITE(12,*)'GMAT DefaultOrbitView.Grid = Off;'
      WRITE(12,*)'GMAT DefaultOrbitView.SunLine = Off;'
      WRITE(12,*)'GMAT DefaultOrbitView.UseInitialView = On;'
      WRITE(12,*)'GMAT DefaultOrbitView.StarCount = 7000;'
      WRITE(12,*)'GMAT DefaultOrbitView.EnableStars = On;'
      WRITE(12,*)'GMAT DefaultOrbitView.EnableConstellations = On;'

        WRITE(12,*)''

      WRITE(12,*)'Create GroundTrackPlot DefaultGroundTrackPlot;'
      WRITE(12,*)'GMAT DefaultGroundTrackPlot.SolverIterations = Current;'
      WRITE(12,*)'GMAT DefaultGroundTrackPlot.UpperLeft = [ 0 0 ];'
      WRITE(12,*)'GMAT DefaultGroundTrackPlot.Size = [ 0 0 ];'
      WRITE(12,*)'GMAT DefaultGroundTrackPlot.RelativeZOrder = 0;'
      WRITE(12,*)'GMAT DefaultGroundTrackPlot.Maximized = false;'
      WRITE(12,*)'GMAT DefaultGroundTrackPlot.Add = {DefaultSC};'
      WRITE(12,*)'GMAT DefaultGroundTrackPlot.DataCollectFrequency = 1;'
      WRITE(12,*)'GMAT DefaultGroundTrackPlot.UpdatePlotFrequency = 50;'
      WRITE(12,*)'GMAT DefaultGroundTrackPlot.NumPointsToRedraw = 0;'
      WRITE(12,*)'GMAT DefaultGroundTrackPlot.ShowPlot = true;'
      WRITE(12,*)'GMAT DefaultGroundTrackPlot.CentralBody = Earth;'
      WRITE(12,*)'GMAT DefaultGroundTrackPlot.TextureMap = ''../data/graphics/texture/ModifiedBlueMarble.jpg'';'

      WRITE(12,*)''
      WRITE(12,*)''

      WRITE(12,*)'%----------------------------------------'
      WRITE(12,*)'%---------- Mission Sequence'
      WRITE(12,*)'%----------------------------------------'

      WRITE(12,*)''

      WRITE(12,*)'BeginMissionSequence;'
      WRITE(12,*)'Propagate DefaultProp(DefaultSC) {DefaultSC.ElapsedSecs = 12000.0};'
   
      PRINT *,''
        PRINT *, 'GMAT script written to file ', Script

    END IF
   
END PROGRAM TLEtoGMAT

!#################################################################################
!---------------------------------------------------------------------------------
! Calculate True Anomaly given Mean Anomaly
! Mean Anomaly is a transendental function of True Anomaly
! True Anomaly cannot be solved for directly   
! True Anomaly is calculated here using a numerical method by Newton   
 function TAfromMA(ma,ecc)
    implicit none

   integer, parameter  :: ikind=selected_real_kind(p=15)
    integer :: i
      real (kind=ikind) ::  ma,ecc,ta,ea,TAfromMA,numerator,denominator,degrees,radians,pi
   
   pi=4.0*atan(1.0)

   ! Initialize Eccentric Anomaly with Mean Anomaly Value
   ! Use radians to do trig
   ma = radians(ma)
   ea = ma
   
    do i = 0, 6
      numerator = ea-(ecc*sin(ea))-ma
        denominator = 1-(ecc*cos(ea))
      ea = ea-(numerator/denominator)
    end do

   numerator = cos(ea)-ecc
   denominator = 1-(ecc*cos(ea))
   
   ta = acos(numerator/denominator) 

   
   ! A corecction is needed for true anolamlies greater than 180 degrees
   IF (ma > pi) THEN
      
   ta = pi+(pi-ta)      
   
   END IF

   TAfromMA = degrees(ta)
   
end function TAfromMA
!---------------------------------------------------------------------------------
!---------------------------------------------------------------------------------
function radians(degrees)
   implicit none
      !    returns radians
      integer, parameter  :: ikind=selected_real_kind(p=15)
      real (kind=ikind) ::  pi,degrees,radians
      pi=4.0*atan(1.0)
      radians=(degrees*pi/180.0)
end function radians
!---------------------------------------------------------------------------------
!---------------------------------------------------------------------------------
function degrees(radians)
   implicit none
   !    returns degrees
   integer, parameter  :: ikind=selected_real_kind(p=15)
   real (kind=ikind) ::  pi,degrees,radians
   pi=4.0*atan(1.0)
   degrees=(radians*180.0/pi)
end function degrees
!---------------------------------------------------------------------------------
!---------------------------------------------------------------------------------
function SMAfromMM(mm)
   implicit none
   
   integer, parameter  :: ikind=selected_real_kind(p=15)
   real (kind=ikind) :: pi,mm,mu, SMAfromMM

   pi=4.0*atan(1.0)

   ! Standard Gravitational Parameter for Earth (km^3/s^2)
   mu = 398600.4418
   
   ! Convert Mean motion from revs/day to rad/s 
   mm = mm*((2*pi)/86400)


   SMAfromMM = (mu/(mm**2))**(1.0/3.0)

end function SMAfromMM
!---------------------------------------------------------------------------------
!---------------------------------------------------------------------------------
function MJDfromEpoch (epochY, epochD)
   implicit none
   
    integer, parameter  :: ikind=selected_real_kind(p=15)
   real (kind=ikind) :: MJDfromEpoch, epochD, JD, offset
    ! a,y,and m as defined in algorithm
    ! mFunc, y_4, y_100, y_400 are terms used to calculate JDN but must be truncated to integers first
   integer :: epochY, a ,y, m, JDN, mFunc, y_4, y_100, y_400
 
   ! First compute the Julian Day (JD) of the start of January 1 of the Epoch year   
   ! Algorithm by Computer Science Department at the University of Texas, San Antonio
   ! http://www.cs.utsa.edu/~cs1063/projects/Spring2011/Project1/jdn-explanation.html
     
   a = (14-1)/12
    y = epochY + 4800 - a
    m = 1 + (12*a)-3
   
   mFunc = (153*m+2)/5
   y_4 = y/4
    y_100 = y/100
    y_400 = y/400

    JDN = 1 + mFunc + (365*y) + y_4 - y_100 + y_400 - 32045
    JD = JDN + ((0-12.0)/24.0)

    ! In TLE format, the Epoch day for January 1 is 001.xxx
    ! Need 000.xxx to be January 1 in JD format
   epochD = epochD-1.0
   
   ! The Julian Day of the Epoch
   JD = JD + epochD

   ! The "standard" MJD offset is  2400000.5
    !offset = 2400000.5   

   !   GMAT uses a non-standard MJD offset of 2430000.0
   offset = 2430000.0

      MJDfromEpoch = JD - offset

end function MJDfromEpoch
!---------------------------------------------------------------------------------
 
bg2k6
 
Posts: 5
Joined: Wed Jan 21, 2015 11:15 pm

Re: Possible To Import Two Line Element (TLE) Sets??

Postby slhaze » Tue Mar 17, 2015 10:01 am

Hi, I think this might be of some help:

http://tleanalyser.blogspot.com/
http://sourceforge.net/projects/tleanalyser/

Basically it converts TLEs into Keplerian elements (and other info), plus there's also an "Export to GMAT" function.

My only issue with it is that the Keplerian elements generated don't necessarily match the corresponding fields in the TLE (e.g. for inclination). Even the Julian epoch is usually a bit off, and I can't tell if that's some deliberate correction or not.

In any case, I haven't been able to get very accurate results with TLEs in GMAT, probably because GMAT doesn't use the SGP4 model, as mentioned earlier.
slhaze
 
Posts: 1
Joined: Tue Mar 17, 2015 9:44 am

Re: Possible To Import Two Line Element (TLE) Sets??

Postby markstylo » Wed Oct 26, 2016 5:52 pm

I think, it does possible, why not? I choose http://bigpaperwriter.com/blog/elements-of-an-argumentative-essay as the best service where I can get to know some elements of an argumentative essay!
markstylo
 
Posts: 1
Joined: Wed Oct 26, 2016 5:44 pm

Re: Possible To Import Two Line Element (TLE) Sets??

Postby Sash » Fri Mar 10, 2017 6:35 pm

Hi,

If you want to import TLE, there is a pretty nicce proggi called TLE Analyser:
Link: https://sourceforge.net/projects/tleanalyser/

It allows to export TLE to celestia and GMAT R2014 script file, but i have already tested and
i can confirm that it works also with GMAT2016.


By the way:
---------------
If you want to generate TLE from your simulation (this is the other way) go look for a DOS-
proggi called RV2TLE_KM.exe.
Link: http://sat.belastro.net/satelliteorbitd ... ation.com/

HowTo:
First put in all the data needed for your orbit state type "keplerian" and Coordinate System "EarthMJ2000Eq",
then put your target Gregorian UTC epoch
then change the state type to "Cartesian"
then change Coordinate System to "EarthICRF"

Copy all the vector components for position and velocity and paste in the textfile RV2TLE_KM.txt (the first 6 rows of that textfile) and save
now run RV2TLE_KM.exe using cmd and type in satname, ssn, designator, bstar, issueday of the TLE (yr month, day, hour, minute, second)
like shown in the attached picture.

Last step: compare with an existing TLE and align the TLE items of your new generated TLE, because the RV2TLE misposition some elements
some times (not always, its just to be sure)


It worked for me in exact this sequence. I veryfied several times and it works all the time (10times)
Attachments
RV2TLE.JPG
Sash
 
Posts: 11
Joined: Tue Dec 15, 2015 10:10 am

Next

Return to General

Who is online

Users browsing this forum: No registered users and 2 guests