Input / Output Framework

Introduction

The reading and writing of the files is done by subclasses of the FileFormatProcessor class.

Extending

class amuse.io.FileFormatProcessor(filename=None, set=None, format=None)

Abstract base class of all fileformat processors

All classes providing loading or storing of files should be subclasses of this base class.

Every subclass must support the filename, set and format arguments. The arguments must all be optional.

Parameters:
  • filename – name of the file the read the data from
  • set – set (of particles or entities) to store in the file
  • format – format of the file, will be a string or class
Attribute provided_formats:
 

list of strings of the formats provided by the processor

extra_attributes

Extra attributes to store with the data set. Some formats (moste notably the amuse native format) can store extra attributes with the set in file. The ‘write_set_to_file’ function will collect all keyword arguments that do not match to an option into the extra attributes dictionary.

get_description_of_options()

Yields tuples, each tuple contains the name of the option, a description of the option and the default values

load()

Loads the set from the file and returns the set.

classmethod register()

Register this class, so that it can be found by name int the write_set_to_file() and read_set_from_file() functions.

store()

Stores the set in the file. The set and the file are both properties of the processor.

class amuse.io.FullTextFileFormatProcessor(filename=None, set=None, format=None)

Abstract base class of all fileformat processors that process their data by first reading the complete text string

Subclasses need to implement the store_string() and load_string() methods.

load()

Loads the set from the file and returns the set.

load_string(string)

Return a particle set, read from the string

store()

Stores the set in the file. The set and the file are both properties of the processor.

store_string()

Return a string representation of the particle set