fastoad.io.variable_io module¶
- class fastoad.io.variable_io.VariableIO(data_source: Union[str, IO], formatter: Optional[fastoad.io.formatter.IVariableIOFormatter] = None)[source]¶
Bases:
object
Class for reading and writing variable values from/to file.
The file format is defined by the class provided as formatter argument.
- Parameters
data_source – the I/O stream, or a file path, used for reading or writing data
formatter – a class that determines the file format to be used. Defaults to a VariableBasicXmlFormatter instance.
- read(only: Optional[List[str]] = None, ignore: Optional[List[str]] = None) → fastoad.openmdao.variables.VariableList[source]¶
Reads variables from provided data source.
Elements of only and ignore can be real variable names or Unix-shell-style patterns. In any case, comparison is case-sensitive.
- Parameters
only – List of variable names that should be read. Other names will be ignored. If None, all variables will be read.
ignore – List of variable names that should be ignored when reading.
- Returns
an VariableList instance where outputs have been defined using provided source
- write(variables: fastoad.openmdao.variables.VariableList, only: Optional[List[str]] = None, ignore: Optional[List[str]] = None)[source]¶
Writes variables from provided VariableList instance.
Elements of only and ignore can be real variable names or Unix-shell-style patterns. In any case, comparison is case-sensitive.
- Parameters
variables – a VariableList instance
only – List of variable names that should be written. Other names will be ignored. If None, all variables will be written.
ignore – List of variable names that should be ignored when writing
- class fastoad.io.variable_io.DataFile(file_path: str, formatter: Optional[fastoad.io.formatter.IVariableIOFormatter] = None, load_data=True)[source]¶
Bases:
fastoad.openmdao.variables.VariableList
Class for managing FAST-OAD data files.
Behaves like
VariableList
class but hasload()
andsave()
methods.- Parameters
file_path – the file path where data will be loaded and saved.
formatter – a class that determines the file format to be used. Defaults to FAST-OAD native format. See
VariableIO
for more information.load_data – if True and if file exists, its content will be loaded at instantiation.
- property file_path: str¶
Path of data file.
- property formatter: fastoad.io.formatter.IVariableIOFormatter¶
Class that defines the file format.