Access to ephemeris of celestial bodies

Spacecraft, Thruster, Tank, Propagator, CoordinateSystem, etc.

Re: Access to ephemeris of celestial bodies

Postby shughes » Fri Sep 07, 2012 10:01 pm

A separate comment related to the Accuracy =1e-16 setting on the numerical integrator. This is really pushing the limits of the integrator resulting in a very slow propagation for almost no increase in state accuracy over larger (1e-12) settings. See the the section "Best Practices for Using Numerical Integrators" here for further discussion: http://gmat.sourceforge.net/docs/nightl ... gator.html
shughes
 
Posts: 443
Joined: Mon Jun 09, 2008 6:27 pm

Re: Access to ephemeris of celestial bodies

Postby fddilectis » Tue Jan 29, 2013 11:28 pm

Hi, I am very new at using GMAT, but I have had the same problem as the OP, specifically trying to export the ephemeris of the Moon, together with those of my spacecraft. I tried the suggestion by shughes, and I placed a dummy spacecraft at the center of the Moon and subjected it to a propagator that has the Earth as primary body and Sun and Jupiter as point masses. The resulting trajectory however is sensibly different than the "real" Moon trajectory that GMAT uses internally, and the error is of several thousand kilometers, so I don't think it's in integration step issue as mentioned above. I have tried changing the parameters of the propagator but without any noticeable effect.

I would appreciate any help, if possible.

Thanks
fddilectis
 
Posts: 3
Joined: Tue Jan 29, 2013 11:18 pm

Re: Access to ephemeris of celestial bodies

Postby jjkparker » Wed Jan 30, 2013 1:43 pm

Does this script work for you? I haven't double-checked the numbers, but it seems like it's working:

Code: Select all
Create ReportFile r
r.Filename = 'MoonEphem.report'
r.WriteHeaders = off

Create Spacecraft moonSat
moonSat.CoordinateSystem = MoonMJ2000Eq
moonSat.X = 0
moonSat.Y = 0
moonSat.Z = 0
moonSat.VX = 0
moonSat.VY = 0
moonSat.VZ = 0

Create CoordinateSystem MoonMJ2000Eq
MoonMJ2000Eq.Origin = Luna
MoonMJ2000Eq.Axes = MJ2000Eq

Create Variable i

BeginMissionSequence

Report r moonSat.Epoch.TAIModJulian moonSat.EarthMJ2000Eq.X moonSat.EarthMJ2000Eq.Y moonSat.EarthMJ2000Eq.Z moonSat.EarthMJ2000Eq.VX moonSat.EarthMJ2000Eq.VY moonSat.EarthMJ2000Eq.VZ

For i = 1:1:1440
   moonSat.Epoch.TAIModJulian = moonSat.Epoch.TAIModJulian + 60/86400
   moonSat.X = 0
   moonSat.Y = 0
   moonSat.Z = 0
   moonSat.VX = 0
   moonSat.VY = 0
   moonSat.VZ = 0
   Report r moonSat.Epoch.TAIModJulian moonSat.EarthMJ2000Eq.X moonSat.EarthMJ2000Eq.Y moonSat.EarthMJ2000Eq.Z moonSat.EarthMJ2000Eq.VX moonSat.EarthMJ2000Eq.VY moonSat.EarthMJ2000Eq.VZ
EndFor
Attachments
MoonEphem.script
(963 Bytes) Downloaded 208 times
Joel J. K. Parker
Flight dynamics engineer, GMAT team
http://gmatcentral.org
jjkparker
 
Posts: 617
Joined: Thu Jan 07, 2010 9:48 pm
Location: NASA Goddard Space Flight Center, Greenbelt, MD

Re: Access to ephemeris of celestial bodies

Postby fddilectis » Thu Jan 31, 2013 11:32 pm

Thanks for your reply. This approach gives results correct enough for my applications. However now I need to find a way to obtain the position of the Moon at the same JDs at which my propagator provides the coordinates of the satellite. I would like to use the same "for cycle" approach of your example, but I don't know how can I access the times at which the propagator generates its results.
fddilectis
 
Posts: 3
Joined: Tue Jan 29, 2013 11:18 pm

Re: Access to ephemeris of celestial bodies

Postby jjkparker » Sat Feb 02, 2013 6:06 pm

We really need to add this as a built-in feature...

Are you propagating for a duration? Or to some other stopping condition?

If you're propagating for a duration, something like this might work, but it won't hit the exact end time.

Code: Select all
Create ReportFile r
r.Filename = 'MoonEphem.report'
r.WriteHeaders = off

Create Spacecraft mySat
mySat.DateFormat = TAIModJulian
mySat.Epoch = 21545

Create Spacecraft moonSat
moonSat.CoordinateSystem = MoonMJ2000Eq
moonSat.X = 0
moonSat.Y = 0
moonSat.Z = 0
moonSat.VX = 0
moonSat.VY = 0
moonSat.VZ = 0

Create Propagator myProp

Create CoordinateSystem MoonMJ2000Eq
MoonMJ2000Eq.Origin = Luna
MoonMJ2000Eq.Axes = MJ2000Eq

BeginMissionSequence

stopTime = 21546
While mySat.Epoch.TAIModJulian < stopTime
    Propagate myProp(mySat)  % take one propagation step
    moonSat.Epoch.TAIModJulian = mySat.Epoch.TAIModJulian    % sync epochs

    % put MoonSat back at the moon
    moonSat.X = 0
    moonSat.Y = 0
    moonSat.Z = 0
    moonSat.VX = 0
    moonSat.VY = 0
    moonSat.VZ = 0

    % report data (add mySat data to this line also)
    Report r moonSat.Epoch.TAIModJulian moonSat.EarthMJ2000Eq.X moonSat.EarthMJ2000Eq.Y moonSat.EarthMJ2000Eq.Z moonSat.EarthMJ2000Eq.VX moonSat.EarthMJ2000Eq.VY moonSat.EarthMJ2000Eq.VZ
EndWhile



EDIT: typo
Joel J. K. Parker
Flight dynamics engineer, GMAT team
http://gmatcentral.org
jjkparker
 
Posts: 617
Joined: Thu Jan 07, 2010 9:48 pm
Location: NASA Goddard Space Flight Center, Greenbelt, MD

Re: Access to ephemeris of celestial bodies

Postby jjkparker » Sat Feb 02, 2013 6:11 pm

I checked in GMT-3516 to track this feature request.
Joel J. K. Parker
Flight dynamics engineer, GMAT team
http://gmatcentral.org
jjkparker
 
Posts: 617
Joined: Thu Jan 07, 2010 9:48 pm
Location: NASA Goddard Space Flight Center, Greenbelt, MD

Re: Access to ephemeris of celestial bodies

Postby fddilectis » Mon Feb 11, 2013 11:30 pm

Thanks again for your help. To answer your question, I am propagating until a certain stopping condition is verified, namely the satellite reaches the aposelene. However for now I decided to export the ephemeris of the Moon for a time interval that will surely cover my mission time, and then interpolate those data in Matlab to match the integration times of the propagator.
fddilectis
 
Posts: 3
Joined: Tue Jan 29, 2013 11:18 pm

Re: Access to ephemeris of celestial bodies

Postby jjkparker » Tue Feb 12, 2013 1:27 pm

Another option is to split the two out:

  1. In GMAT, propagate your spacecraft and report data at integration steps (using the ReportFile.Add field).
  2. In MATLAB, read in the GMAT report file and send the times to MICE to give you the ephemeris

That should give you exact ephemeris at GMAT's integration steps.
Joel J. K. Parker
Flight dynamics engineer, GMAT team
http://gmatcentral.org
jjkparker
 
Posts: 617
Joined: Thu Jan 07, 2010 9:48 pm
Location: NASA Goddard Space Flight Center, Greenbelt, MD

Re: Access to ephemeris of celestial bodies

Postby marchand » Thu May 02, 2013 6:06 pm

I was able to implement Steve's suggestion successfully to extract cartesian states of a planetary body, but I can't seem to use it get orbital elements.

In the attached example, I am trying to use the method proposed to first get the Earth heliocentric state, though eventually what I want is the heliocentric eccentricity. I was able to get the state and validate it against the MATLAB ephemeris reader using DE405, which expects a Julian Date = TDBModJulian + 2430000.0, as per the conversion in the mathematical specification. These are the results of that comparison:

Code: Select all
From GMAT:

From GMAT:

earthSC.SunMJ2000Eq.X   earthSC.SunMJ2000Eq.Y   earthSC.SunMJ2000Eq.Z   earthSC.SunMJ2000Eq.VX   earthSC.SunMJ2000Eq.VY   earthSC.SunMJ2000Eq.VZ   
-111952540.371195       -92670675.63547888      -40174606.10513786      19.46131271331472        -20.40118294028324       -8.844418610754932       

From DE405 Ephemeris Reader in MATLAB:
-111952540.3709442      -92670675.63574182      -40174606.10525182      19.46131271337087        -20.40118294023733e+01   -8.844418610734984


So, that bit works great. What I can't get to work is the orbital parameter bit. Here's what's happening.

I define two coordinate systems:

Code: Select all
Create CoordinateSystem SunMJ2000Eq;
GMAT SunMJ2000Eq.Origin = Sun;
GMAT SunMJ2000Eq.Axes = MJ2000Eq;

Create CoordinateSystem myEarthMJ2000Eq;
GMAT myEarthMJ2000Eq.Origin = Earth;
GMAT myEarthMJ2000Eq.Axes = MJ2000Eq;


I then define two spacecraft, earthSC linked to myEarthMJ2000Eq, and helioEarthSC, linked to SunMJ2000Eq. Inside the mission sequence, I reset the cartesian SunMJ2000Eq coordinates of helioEarthSC to match those I extract from EarthSC as follows:

Code: Select all
GMAT helioEarthSC.X = earthSC.SunMJ2000Eq.X;
GMAT helioEarthSC.Y = earthSC.SunMJ2000Eq.Y;
GMAT helioEarthSC.Z = earthSC.SunMJ2000Eq.Z;
GMAT helioEarthSC.VX = earthSC.SunMJ2000Eq.VX;
GMAT helioEarthSC.VY = earthSC.SunMJ2000Eq.VY;
GMAT helioEarthSC.VZ = earthSC.SunMJ2000Eq.VZ;


The problem is that, for some reason, the coordinates I recorded above are not updating internally. I can confirm this through the next report line:

Code: Select all
Report rf helioEarthSC.X helioEarthSC.Y helioEarthSC.Z helioEarthSC.VX helioEarthSC.VY helioEarthSC.VZ;


That line reports zeros across the board. As a result, I am unable to report the last line:

Code: Select all
Report rf helioEarthSC.ECC;


because it sees the state of helioEarthSC as zero still. That line returns this error:

Code: Select all
Parameter exception: *** Error *** Cannot convert from Cartesian to Keplerian because position vector is a zero vector.


Any ideas as to why this is happening?
Attachments
Ex_default_example.script
(2.43 KiB) Downloaded 206 times
marchand
 
Posts: 86
Joined: Tue Feb 21, 2012 2:42 pm

Re: Access to ephemeris of celestial bodies

Postby jjkparker » Tue May 07, 2013 12:50 pm

I think this is just a matter of unhelpful defaults.

When you do this:
Report rf helioEarthSC.X

GMAT sees this:
Report rf helioEarthSC.EarthMJ2000Eq.X

If I change it as follows, the report looks correct to me:
Report rf helioEarthSC.SunMJ2000Eq.X

The general rule is that when accessing spacecraft parameters, always specify the coordinate system or central body dependency. Otherwise GMAT will default to EarthMJ2000Eq and Earth, respectively.
Joel J. K. Parker
Flight dynamics engineer, GMAT team
http://gmatcentral.org
jjkparker
 
Posts: 617
Joined: Thu Jan 07, 2010 9:48 pm
Location: NASA Goddard Space Flight Center, Greenbelt, MD

PreviousNext

Return to GMAT Resources

Who is online

Users browsing this forum: No registered users and 1 guest

cron