spacepy.pybats.IdlFile

class spacepy.pybats.IdlFile(filename, format=None, header='units', keep_case=True, *args, **kwargs)[source]

An object class that reads/parses an IDL-formatted output file from the SWMF and places it into a spacepy.pybats.PbData object.

Usage: >>>data = spacepy.pybats.IdlFile(‘binary_file.out’)

See spacepy.pybats.PbData for information on how to explore data contained within the returned object.

This class serves as a parent class to SWMF component-specific derivative classes that do more preprocessing of the data before returning the object. Hence, using this class to read binary files is typically not the most efficient way to proceed. Look for a PyBats sub module that suits your specific needs, or use this base object to write your own.

A note on byte-swapping: PyBats assumes little endian byte ordering because this is what most machines use. However, there is an autodetect feature such that, if PyBats doesn’t make sense of the first read (a record length entry, or RecLen), it will proceed using big endian ordering. If this doesn’t work, the error will manifest itself through the “struct” package as an “unpack requires a string of argument length ‘X’”.