Parsers¶
The gmat_run.parsers subpackage parses GMAT's output formats into
pandas.DataFrame objects. Each parser exposes a
parse(path) -> pandas.DataFrame function and depends only on the file
layout — no gmatpy import, no GMAT install required. This lets parser logic
be unit-tested against fixture files alone.
You normally do not call these directly:
Mission.run returns a Results whose
.reports, .ephemerides, and .contacts mappings already dispatch to the
right parser based on the file's content. Reach for these functions only when
you have a stand-alone GMAT output file you want to load without driving a
Mission, or when you are writing your own dispatch logic.
ReportFile¶
parse
¶
Parse a GMAT ReportFile into a :class:pandas.DataFrame.
Column names are taken verbatim from the header row (dots preserved, e.g.
Sat.Earth.SMA). Each column is coerced to int64 or float64 if
every value parses as numeric; otherwise the column stays object/str.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | PathLike[str]
|
Path to the |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
A DataFrame with one row per report event and one column per header |
DataFrame
|
field, in header order. |
Raises:
| Type | Description |
|---|---|
GmatOutputParseError
|
The file is empty, or a data row's column count does not match the header. |
EphemerisFile (CCSDS-OEM, text)¶
parse
¶
Parse a CCSDS-OEM ephemeris file into a :class:pandas.DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | PathLike[str]
|
Path to the |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
A DataFrame with one row per state record. Columns are |
DataFrame
|
|
DataFrame
|
|
DataFrame
|
Metadata surfaces on |
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
Raises:
| Type | Description |
|---|---|
GmatOutputParseError
|
The file is empty, no |
EphemerisFile (STK-TimePosVel, text)¶
parse
¶
Parse an STK-TimePosVel ephemeris file into a :class:pandas.DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | PathLike[str]
|
Path to the |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
A DataFrame with one row per state record. Columns are |
DataFrame
|
|
DataFrame
|
plus |
DataFrame
|
Metadata surfaces on |
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
Raises:
| Type | Description |
|---|---|
GmatOutputParseError
|
The file is empty, missing a |
is_stk_ephemeris
¶
Return True if path looks like an STK-TimePosVel ephemeris.
Sniffs the file's first non-blank, non-comment line for an stk.v.X.Y
banner. Used by :mod:gmat_run.results to dispatch to the right parser
without relying on file extension.
EphemerisFile (SPK, binary)¶
parse
¶
Parse an SPK ephemeris file into a :class:pandas.DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | PathLike[str]
|
Path to the |
required |
sampling_step
|
float | None
|
Output cadence in seconds. |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
A DataFrame with one row per state. Columns are |
DataFrame
|
( |
DataFrame
|
|
DataFrame
|
native units, matching the OEM/STK parsers' km defaults). |
DataFrame
|
Metadata surfaces on |
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
Raises:
| Type | Description |
|---|---|
GmatOutputParseError
|
|
is_spk_ephemeris
¶
Return True if path looks like a DAF/SPK kernel.
Reads the first eight bytes and matches the ASCII "DAF/SPK "
magic. Used by :mod:gmat_run.results to dispatch by content rather
than by extension. Pure-bytes — does not import spiceypy.
CCSDS-AEM attitude ephemeris¶
parse
¶
Parse a CCSDS-AEM attitude ephemeris file into a :class:pandas.DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | PathLike[str]
|
Path to the |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
A DataFrame with one row per attitude record. Columns depend on the |
DataFrame
|
file's |
DataFrame
|
|
DataFrame
|
|
DataFrame
|
Common metadata surfaces on |
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
Raises:
| Type | Description |
|---|---|
GmatOutputParseError
|
The file is empty, no |
is_aem_ephemeris
¶
Return True if path looks like a CCSDS-AEM file.
Sniffs the first non-blank, non-comment line for a CCSDS_AEM_VERS = …
header. Cheap enough to run on every candidate file when classifying a
directory's worth of attitude artefacts.
ContactLocator¶
parse
¶
Parse a GMAT ContactLocator report into a :class:pandas.DataFrame.
The returned schema depends on the underlying ContactLocator.ReportFormat:
Legacy→Observer,Start,Stop,Duration.ContactRangeReport→Observer,Duration,Start,Stop,StartRange,StopRange.SiteViewMaxElevationReport→Observer,Start,Stop,Duration,MaxElevation,MaxElevationTime.SiteViewMaxElevationRangeReport→Observer,Start,Stop,Duration,MaxElevation,MaxElevationTime,StartRange,StopRange.AzimuthElevationRangeReport→Pass,Observer,Time,Azimuth,Elevation,Range.AzimuthElevationRangeRangeRateReport→ as above plusRangeRate.
Time columns are datetime64[ns]; Duration is timedelta64[ns];
Pass is int64; Observer is object; numeric value columns
(ranges, angles, rates) are float64.
df.attrs:
target— singlestr, theTargetresource name from the file.report_format— variant name as GMAT spells it (e.g."Legacy").time_scale— always"UTC"in current GMAT releases.epoch_scales—{datetime_column: "UTC"}for every parsed time column.event_counts—{observer: int}. Lifted from Legacy'sNumber of events : Nlines; derived for the per-event variants via a row-count groupby onObserver; derived for the AzEl variants via aPassnuniqueper observer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | PathLike[str]
|
Path to the |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
A DataFrame with one row per event (or per (Pass, tick) for the AzEl |
DataFrame
|
variants), in source order. |
Raises:
| Type | Description |
|---|---|
GmatOutputParseError
|
The file is empty, missing a |
Epoch promotion¶
promote_epochs
¶
Promote recognised epoch columns in df to datetime64[ns] in place.
The DataFrame is mutated and returned so callers can chain. Time scales for
promoted columns are recorded under df.attrs["epoch_scales"] as a
{column_name: scale_string} dict. scale_string is one of
"A1", "TAI", "UTC", "TT", "TDB".
Idempotent: calling this twice on the same frame is a no-op on the second
pass, because promoted columns are already datetime64[ns] and are
skipped.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
DataFrame whose columns follow GMAT's |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
|
Raises:
| Type | Description |
|---|---|
GmatOutputParseError
|
A recognised epoch column contains values that
cannot be parsed (malformed Gregorian text, non-numeric ModJulian,
or a ModJulian value that overflows |