savetxt_matrix

mdtools.file_handler.savetxt_matrix(fname, data, var1, var2, init_values1=None, init_values2=None, upper_left=0, **kwargs)[source]

Save a data matrix to a text file.

Write data that are a function of two independent variables, var1 and var2, as a matrix to a text file using mdtools.file_handler.savetxt(). The dependency of the data from var1 is represented by the rows and the dependency from var2 is represented by the columns.

Parameters:
  • fname (str or os.PathLike) – The name of the file to create.

  • data (array_like) – 2-dimensional array of data to be saved. Must be of shape (n, m), where n is the number of samples of the first independent variable (depicted row wise) and m is the number of samples of the second independent variable (depicted column wise).

  • var1, var2 (array_like) – Array of shape (n,) (var1) or (m,) (var2) containing the values of the first or second independent variable at which the data were sampled.

  • init_values1, init_values2 (array_like, optional) – If supplied, the values stored in this array will be handled as special initial data values corresponding to the very first value in var1 or var2. Must be an array of shape (m,) (init_values1) or (n,) (init_values2). If given, data must be of shape (n-1, m) or (n, m-1) or (n-1, m-1) if both are given.

  • upper_left (scalar, optional) – Value to put in the upper left corner of the final data matrix. Usually, this value is meaningless and set to zero.

  • kwargs (dict, optional) – Additional keyword arguments to parse to mdtools.file_handler.savetxt(). See there for possible arguments and their description.

See also

mdtools.file_handler.savetxt()

Save an array to a text file

mdtools.file_handler.write_matrix_block()

Save a data matrix as block to a text file

mdtools.file_handler.backup()

Backup a file by renaming it

Notes

Internally, this function calls mdtools.file_handler.savetxt() which in turn calls numpy.savetxt().