spacepy.pybats.IdlFile¶
- class spacepy.pybats.IdlFile(filename, iframe=0, 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.- Parameters:
- filenamestring
A
*.out
or*.outs
SWMF output file name.
- Other Parameters:
- headerstr or
None
Determine how to interpret the additional header information. Defaults to ‘units’.
- keep_casebool
If set to True, the case of variable names will be preserved. If set to False, variable names will be set to all lower case.
- headerstr or
Notes
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’”.
Changed in version 0.5.0: Unstructured data are presented as in the files. When reading 3D magnetosphere files, this preserves the 3D block structure, as required for the BATSRUS interpolator in the Kamodo Heliophysics model readers package. Before 0.5.0, binary unstructured data were sorted in an attempt to put nearby positions close to each other in the data arrays. This sorting was nondeterministic and has been removed; see
extract()
andQTree
for processing adjacent cells. (ASCII data were never sorted.)- __init__(filename, iframe=0, header='units', keep_case=True, *args, **kwargs)[source]¶
Base class for “Data Model” representation data
Abstract method, reimplement
- Attributes:
- attrsdict
dictionary of the attributes of the SpaceData object
Methods
read
([iframe])This method reads an IDL-formatted BATS-R-US output file and places the data into the object.
switch_frame
(iframe)For files that have more than one data frame (i.e.,
*.outs
files), load data from the iframe-th frame into the object replacing what is currently loaded.Attributes
- read(iframe=0)[source]¶
This method reads an IDL-formatted BATS-R-US output file and places the data into the object. The file read is self.filename which is set when the object is instantiated.
- switch_frame(iframe)[source]¶
For files that have more than one data frame (i.e.,
*.outs
files), load data from the iframe-th frame into the object replacing what is currently loaded.
- attrs: collections.abc.Mapping¶