Simple SPK / SPICE Question

Post here for assistance in troubleshooting a problem using GMAT

Simple SPK / SPICE Question

Postby rdo » Tue May 13, 2014 3:28 am

Hi!

I've been reading the GMAT forums since the start of the year, and learning everything I can about this brilliant software!

Now it has caught me out!

I am trying to learn how to use imported ephemeris data, and to that end, created a simple type 5 SPICE setup file, and an input data file of 3 lines of data to generate an SPK file using JPL's MKSPK utility. I deliberately kept the input data file as small as I could, to minimise the risk of it not working, and likewise, I tried to avoid changing the setup file as much as possible. Running this through MKSPK successfully gave me the binary .bsp file, which I then imported into GMAT using the SPICE tab for the defaultSC. In the Mission section, I set the propagator to the SPICE setting, and tried to Run GMAT. This was the message I got:

GMAT Error

Utility Exception: Error getting state for body "DefaultSC"> Message received from CSPICE is: [Insufficient ephemeris data has been loaded to compute the state of -123456789 compared to 399 (EARTH) for the ephemeris epoch 2000 JAN 01 12:00:32.149.]

The error message is clear enough, so my question is, what is the minimum set of data that can be imported into GMAT as a .bsp file?

Thanks in advance for any answers anyone can provide :-)
rdo
 
Posts: 3
Joined: Tue May 13, 2014 3:07 am

Re: Simple SPK / SPICE Question

Postby jjkparker » Tue May 13, 2014 1:35 pm

Can you run brief (included with SPICE) on the .bsp file and post the results? Or simply post the .bsp file?

You'll need to make sure the .bsp file includes the correct NAIFID and the correct timespan.

Joel
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: Simple SPK / SPICE Question

Postby rdo » Fri May 16, 2014 2:42 pm

Dear Joel,

First of all thank you very much for such a rapid response!

I have included the latest output from my short .bsp file, which is still returning the same error, although I have tried it various times. I had to rename it as a .txt file to attach it, so it will need to be set back to .bsp from .txt. The epoch is deliberately set to be simple, and when I looked at the NAIF ID, I could see nothing to provide guidance on what to actually set it to, so have tried to come up with a logical NAIF ID.

I have had a colleague replicate the same set of files, and he gets the same answer. This was working on Windows 8 PCs BTW, although I have also tried creating the file by running mkspk on a Mac too.

Any advice you, or anyone else an give would be wonderful! :-)
Attachments
OutputEarthSPK03.txt
(46 KiB) Downloaded 275 times
rdo
 
Posts: 3
Joined: Tue May 13, 2014 3:07 am

Re: Simple SPK / SPICE Question

Postby jjkparker » Mon May 19, 2014 1:18 pm

Hi rdo,

I recommend you download the SPICE toolkit from http://naif.jpl.nasa.gov/naif/toolkit.html. It has several useful utilities (in the exe directory) that let you manipulate and get information about .bsp files.

One of those utilities is brief, which shows basic information about a .bsp file. When I run brief on your attached file, I get this:

Code: Select all
C:\Users\jjparker\Desktop>brief OutputEarthSPK03.bsp

BRIEF -- Version 3.0.0, January 14, 2008 -- Toolkit Version N0064


Summary for: OutputEarthSPK03.bsp

Body: -399399
      Start of Interval (ET)              End of Interval (ET)
      -----------------------------       -----------------------------
      2014 JAN 01 00:01:07.183            2014 JAN 01 00:01:47.183



Here the problem seems pretty clear: the file contains a single instant in time! So GMAT's message becomes very clear: the epoch "2000 JAN 01 12:00:32.149" is actually not on the file, so GMAT can't request the state at that epoch.

Also, above the "Body:" line contains the NAIF ID ("-399399"). You'll need to set that value in GMAT so it can search for the correct ID in the .bsp file.

Once you think you've corrected these issues, if you send over your script, I can maybe help some more.
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: Simple SPK / SPICE Question

Postby rdo » Tue May 20, 2014 3:50 am

Once again, thank you ever so much for such a rapid response!

OK, first of all, yes, I had already downloaded the SPICE Toolkit, and in fact, that's the set of files I used to generate my .bsp file (using mkspk). I had run brief, but wasn't sure whether the output was correct or not. I have modified the input file (which to keep it simple, I have initially gone for a 40 second set of data, with each row being at 2 second intervals), and running brief, now get the output:

BRIEF -- Version 3.0.0, January 14, 2008 -- Toolkit Version N0064


Summary for: OutputEarthSPK04.bsp

Body: -399399
Start of Interval (ET) End of Interval (ET)
----------------------------- -----------------------------
2014 JAN 01 00:01:07.183 2014 JAN 01 00:01:47.183

I have also attached the original input data file, and as you can see, it is not a complex file. Again, this is deliberate, since if I can get something so basic working for import into GMAT, there are a whole range of ideas I would like to test using imported SPICE data into GMAT.

The question is, with the Input Data File and output from brief, showing the correct epoch, what am I missing?
Attachments
InputDataFileEarth02.txt
(2.42 KiB) Downloaded 262 times
rdo
 
Posts: 3
Joined: Tue May 13, 2014 3:07 am

Re: Simple SPK / SPICE Question

Postby jjkparker » Tue May 20, 2014 1:00 pm

Ok, I see the confusion now. Your ephem is actually 40 seconds long; I had thought the begin times and end times were the same, which would cause problems.

I made a quick script that propagates your SPK file. See attached. This script will run in R2013a.

A few things to note:
  • Make sure you're using the SPK propagator type.
  • I had to set the propagator step size to 1s; the default was 5 min.
  • SPICE's ET is roughly equivalent to GMAT's TDB. I had to manipulate the start time by a few milliseconds to get it to work.
  • I also had to prop for 38s instead of the full 40s, or GMAT would complain about stepping over the final time. I'm not quite sure why this is, but it probably has to do with the step size and the time precision issue.

The process is a little cumbersome; there's a lot to configure to get it working. I'll be checking in an enhancement request soon to track some of it.
Attachments
spkprop.script
(5.32 KiB) Downloaded 289 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: Simple SPK / SPICE Question

Postby jjkparker » Mon Jun 02, 2014 12:52 pm

We're migrating forums to http://forums.gmatcentral.org, and this message slipped through the cracks. I migrated it manually from the old page.

rdo wrote:Dear Joel,

That was brilliant, and lightning fast, thank you very much!

Your script worked, and I expanded my SPK file, read it into the same script, and it runs! I have been working away at it, and singing GMAT's praises to all I can.

I have been tweaking my expanded file, but I'm not happy with the output data. the file should describe an ascending arc, to an ascent transfer orbit, but whilst it runs, I don't seem to be seeing any track on the output, and the command summary data isn't what I would have thought it should be. Given it is an extension from the original file, this strikes me as strange.

I have included the .bsp file as an attachment. As per the previous file, this one needs the .txt extension changing for .bsp. It has been successfully generated using the SPICE toolkit, and I ran brief on it and everything was fine, which is why I am baffled.

As usual, any light you or anyone else can shed on this would be wonderful!
Attachments
OutputSPK07c.txt
(52 KiB) Downloaded 241 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


Return to Troubleshooting

Who is online

Users browsing this forum: No registered users and 2 guests

cron