API Reference¶
-
adios.
readvar
(fname, varname)¶ Retrieve a variable value from an Adios file.
Parameters: - fname (str) – Adios file name
- varname (str) – Variable name to retrieve
Returns: variable value
Return type: NumPy ndarray
-
adios.
bpls
(fname)¶ Return meta data of an Adios file as a Python dictionary object.
Parameters: fname (str) – Adios file name Returns: Adios file meta data Return type: dict
file class¶
-
class
adios.
file
(str fname, str method_name='BP', MPI_Comm comm=MPI_COMM_WORLD, is_stream=False, ADIOS_LOCKMODE lock_mode=ADIOS_LOCKMODE_ALL, float timeout_sec=0.0)¶ file class for Adios file read and write.
Parameters: - fname (str) – filename.
- method_name (str, optional) – Adios read method (default: ‘BP’).
- comm (MPI_Comm, optional) – MPI_comm for parallel read/write (default: MPI_COMM_WORLD).
- is_stream (bool, optional) – Set True if use stream reader (default: False).
- lock_mode (int, optional) – ADIOS_LOCKMODE for stream reader (default: ADIOS_LOCKMODE_ALL).
- timeout_sec (float, optional) – Timeout seconds for stream reader (default: 0.0).
Example:
>>> import adios as ad >>> f = ad.file('adiosfile.bp')
-
advance
(self, int last=0, float timeout_sec=0.0)¶ Advance a timestep for stream reader.
Parameters: - last (int, optional) – last timestep index (default: 0).
- timeout_sec (float, optional) – timeout seconds (default: 0.0).
Returns: 0 if successful, non-zero otherwise.
Return type: int
-
close
(self)¶ Close the open file.
-
dirs
(self)¶ Return child dir names
-
is_open
(self)¶ Check whether file is open or closed
-
keys
(self)¶
-
printself
(self)¶ Print native ADIOS_FILE structure.
-
release_step
(self)¶ Release the current step lock and let the writer code to progress
-
attr
¶ attr – object
-
attrs
¶ attrs – adios.softdict
-
current_step
¶ The current timestep index.
-
endianness
¶ The endianness of the stored data.
-
file_size
¶ The size of Adios file.
-
is_stream
¶ Indicating reader type; file reader or stream reader
-
last_step
¶ The last timestep index.
-
name
¶ The filename (or stream name) associated with.
-
nattrs
¶ The number of attributes.
-
nvars
¶ The number of variables.
-
var
¶ var – object
-
vars
¶ vars – adios.softdict
-
version
¶ The version of Adios.
var class¶
-
class
adios.
var
(file file, str name)¶ Adios variable class.
Unlike attributes whose values are populated on initialization, variable’s values will be returned by explicitly calling read() or array access interface ([]).
Parameters: - file (file) – Associated file class
- name (str) – variable name
Note
Users do not need to create this class manually.
-
advance
(self)¶ Update variable information after the stream advanced
-
close
(self)¶ Close and free variable information
-
keys
(self)¶
-
printself
(self)¶ Print native ADIOS_VARINFO structure.
-
read
(self, tuple offset=(), tuple count=(), tuple scalar=(), from_steps=None, nsteps=None, fill=0, step_scalar=True)¶ Perform read.
Read data from an ADIOS BP file. Subset reading is supported. Without any options, this will read out a whole data.
Parameters: - offset (tuple of int, optional) – offset (default: ())
- count (tuple of int, optional) – count (default: ())
- scalar (tuple of bool, optional) – scalar (default: ())
- from_steps (int, optional) – starting step index (default: None)
- nsteps (int, optional) – number of time dimensions (default: None)
- fill (value, optional) – default fill value (default: 0)
- step_scalar (bool, optional) – add time dim or not (default: True)
Returns: NumPy ndarray
Raises: IndexError
– If dimension is mismatched or out of the boundary.Example:
The following command will read the full data:
>>> var.read()
which is equvalent to
>>> var[]
The following command is for subset reading:
>>> var.read(offset=(1,2), count=(3,4))
which will return an 3x4 array offset by (1,2) in the original data. With Numpy’s array notation, the following command does the same job:
>>> var[1:4, 2:6]
Similarly, the following two commands are same:
>>> var.read(count=(5,6)) >>> var[:5, :6]
-
read_points
(self, tuple points=(), from_steps=None, nsteps=None)¶ Perform points read.
Read data from an ADIOS BP file based on the given list of point index.
Parameters: - points (tuple of int, optional) – points index defined by ((o1,o2,...,oN),...) (default: ())
- from_steps (int, optional) – starting step index (default: None)
- nsteps (int, optional) – number of time dimensions (default: None)
Returns: NumPy 1-D ndarray
Raises: IndexError
– If dimension is mismatched or out of the boundary.
-
read_writeblock
(self, int rank, from_steps=None, nsteps=None)¶ Perform block read.
Read data from an ADIOS BP file based on the rank id.
Parameters: - rank (int) – rank id
- from_steps (int, optional) – starting step index (default: None)
- nsteps (int, optional) – number of time dimensions (default: None)
Returns: NumPy 1-D ndarray
Raises: IndexError
– If dimension is mismatched or out of the boundary.
-
attrs
¶ Attributes associated with the variable.
-
blockinfo
¶ Block information.
-
dims
¶ The shape of the variable.
-
dtype
¶ Variable type as in numpy.dtype.
-
name
¶ The variable name.
-
ndim
¶ The number of dimensions of the variable.
-
nsteps
¶ The number of time steps of the variable.
-
shape
¶ The shape of the variable.
-
size
¶ The number of elements in the array.
-
varid
¶ Internal variable id.
writer class¶
-
class
adios.
writer
(str fname, bool is_noxml=True, str mode='w', int stats=adios_stat_default, MPI_Comm comm=MPI_COMM_WORLD, str method='POSIX1', str method_params='')¶ writer class for Adios write.
Parameters: - fname (str) – filename.
- is_noxml (bool, optional) – Set True if use noxml APIs (default: True).
- comm (MPI_Comm, optional) – MPI_comm for parallel read/write (default: MPI_COMM_WORLD).
Example:
>>> import adios as ad >>> f = ad.writer('adiosfile.bp')
-
close
(self)¶ Write variables and attributes to a file and close the writer.
-
declare_group
(self, str gname=None, str method='POSIX1', str method_params='', int stats=adios_stat_default)¶ Define a group associated with the file.
Parameters: - gname (str) – group name.
- method (str, optional) – Adios write method (default: ‘POSIX1’)
- method_params (str, optional) – parameters for the write method (default: ‘’)
- stats (int, optional) – statistics (default: ‘DEFAULT’)
Example:
>>> fw.declare_group('group', method='MPI_, method_params='verbose=3')
-
define_attr
(self, str attrname)¶ Define attribute in the file.
Parameters: attrname (str) – attribute name.
-
define_dynamic_attr
(self, str attrname, str varname, dtype)¶
-
define_var
(self, str varname, ldim=<???>, gdim=<???>, offset=<???>, transform=None)¶ Define a variable associated with the file.
Parameters: - varname (str) – variable name
- ldim (tuple, optional) – local dimension (default: tuple())
- gdim (tuple, optional) – global dimension (default: tuple())
- offset (tuple, optional) – offset (default: tuple())
- transform (str) – transform name
Example:
Write ‘temperature’ variable of size of 2x3 array.
>>> fw.define_var ('temperature', (2,3))
-
set_time_aggregation
(self, buffer_size=None)¶ Set time-aggregation buffersize.
-
attrs
¶ Dictionary of attributes to write.
-
fname
¶ The filename to write.
-
gname
¶ The groupname associated with the file.
-
is_noxml
¶ Boolean to indicate using No-XML or not.
-
mode
¶ Writing mode – overwrite or append.
-
timeaggregation_buffersize
¶ Get time-aggregation buffersize.
-
vars
¶ Dictionary of variables to write.