Utilities
- pyRTX.utilities.export_formatted(accelerations, epochs, filename, units=None)[source]
Export acceleration data to formatted text file with epoch timestamps.
Writes acceleration vectors and their corresponding epochs to a CSV file with descriptive header. The output format is suitable for reading by orbit determination software or data analysis tools.
- Parameters:
accelerations (
ndarray,shape (N,3)) – Array of 3-component acceleration vectors. Each row is [ax, ay, az] at one time step. Must be 2D array with exactly 3 columns.epochs (
ndarray,shape (N,)) – Array of epoch times corresponding to each acceleration vector. Should be in seconds past J2000 (SPICE ephemeris time format).filename (
str) – Path to output file. Typically uses .txt or .csv extension.units (
strorNone, defaultNone) – Optional string describing the units of the acceleration data (e.g., ‘km/s^2’, ‘m/s^2’). Will be added to file header if provided.
- Returns:
Data is written to file at specified filename.
- Return type:
- Raises:
ValueError – If accelerations is not shape (N, 3) or if the number of epochs doesn’t match the number of acceleration vectors.
Notes
Output file format: - CSV format with comma delimiters - Header line with format description and optional units - Data columns: Epoch, X, Y, Z - One row per time step
The file header contains: - Description of data format - Column definitions (Epoch in seconds past J2000, X, Y, Z components) - Units information if provided
Example output file: .. code-block:
# Acceleration file. Columns: Epoch (seconds past J2000), X, Y, Z. Units: km/s^2 0.000000000000000000e+00,1.234567890123456789e-08,2.345678901234567890e-08,3.456789012345678901e-08 6.000000000000000000e+01,1.234567890123456789e-08,2.345678901234567890e-08,3.456789012345678901e-08 ...
The output can be read back using:
data = np.loadtxt(filename, delimiter=',') epochs = data[:, 0] accelerations = data[:, 1:4]
Examples
>>> epochs = np.array([0.0, 60.0, 120.0]) >>> accels = np.array([[1e-8, 2e-8, 3e-8], ... [1.1e-8, 2.1e-8, 3.1e-8], ... [1.2e-8, 2.2e-8, 3.2e-8]]) >>> export_formatted(accels, epochs, 'output.txt', units='km/s^2')
See also
export_exacExport to GEODYN EXAC binary format
numpy.savetxtUnderlying function for text output
- pyRTX.utilities.export_exac(satelliteID, data, tstep, startTime, endTime, outFileName)[source]
Export acceleration data to GEODYN EXAC (External Accelerations) file format.
GEODYN is NASA’s precision orbit determination software. The EXAC format is a Fortran-formatted binary file used to provide time-varying external accelerations (such as solar radiation pressure) to the orbit propagator.
- Parameters:
satelliteID (
int) – Satellite identifier code used in GEODYN processing.data (
ndarray,shape (N,3)) – Acceleration data to be written, in km/s². Each row is [ax, ay, az] at one time step.tstep (
intorfloat) – Time step between data records in seconds (e.g., 60 for 1-minute data).startTime (
datetime.datetime) – Start time of the data series. Must include date and time information down to microseconds.endTime (
datetime.datetime) – End time of the data series. Must be consistent with len(data) and tstep.outFileName (
str) – Path to output EXAC file. Typically uses .exac or .bin extension.
- Returns:
Data is written to binary file at outFileName.
- Return type:
Notes
EXAC File Structure:
Master header record: Control parameters and file type identifier
Satellite-specific header: Satellite ID, time step, start/end times
Data records: Time stamp + 3D acceleration vector + padding zeros
Time Format:
Stored as YYMMDDHHMMSSμμμμμμ (year-month-day-hour-minute-second-microsecond)
Year uses 2-digit format (YY)
Coordinate System:
Accelerations should be in the same reference frame as the GEODYN orbit integration (typically J2000 or ICRF)
Units:
Accelerations: km/s²
Time step: seconds
This format is used for high-precision orbit determination where external non-gravitational forces (solar pressure, atmospheric drag, etc.) need to be accurately modeled.
Requires scipy.io.FortranFile for binary I/O operations.
- pyRTX.utilities.to_datetime(epoch)[source]
Converts a SPICE epoch to a Python datetime object.
- Parameters:
epoch (
float) – The SPICE ephemeris time in seconds past J2000.- Returns:
The corresponding datetime object.
- Return type: