class spacepy.pybats.SatOrbit(filename=None, *args, **kwargs)[source]

An class to load, read, write, and handle BATS-R-US satellite orbit input files. These files are used to fly virtual satellites through the MHD domain. Note that the output files should be handled by the LogFile and not this satorbit object. The object’s required and always present attributes are:




A list of header lines for the file that contain comments.


The three-letter code (see SWMF doc) of the coord system.


Location of the file to read/write.

The object should always have the following two data keys:




A list or numpy vector of datetime objects


A 3 x len(time) numpy array of x,y,z coordinates associated with the time vector.

A “blank” instantiation will create an empty object for the user to fill. This is desired if the user wants to create a new orbit, either from data or from scratch, and save it in a properly formatted file. Here’s an example with a “stationary probe” type orbit where the attributes are filled and then dropped to file:

>>> from spacepy.pybats import SatOrbit
>>> import datetime as dt
>>> import numpy as np
>>> sat = SatOrbit()
>>> sat['time'] = [ dt.datetime(2000,1,1), dt.datetime(2000,1,2) ]
>>> pos = np.zeros( (3,2) )
>>> pos[:,0]=[6.6, 0, 0]
>>> pos[:,1]=[6.6, 0, 0]
>>> sat['xyz'] = pos
>>> sat.attrs['coor'] = 'SMG'
>>> sat.attrs['file'] = 'noon_probe.dat'
>>> sat.write()

If instantiated with a file name, the name is loaded into the object. For example,

>>> sat=SatOrbit('a_sat_orbit_file.dat')

…will populate all fields with the data in a_sat_orbit_file.dat.