data_read

libra_py.data_read.get_data(params)[source]

Read a single set of data files

Parameters

params (dictionary) –

parameters controlling the function execution

Required parameter keys:

  • params[“data_dim”] ( int ): matrix dimension how many lines/columns in the file [Required!]

  • params[“active_space”] ( list of ints ): the indices of the states we care

    about. These indices will be used to determine the size of the created CMATRIX objects and only these states will be extracted from the original files [ default: range(data_dim) ]

  • params[“isnap”] ( int ): index of the first file to read [Required!]

  • params[“fsnap”] ( int ): index of the final file to read [Required!]

  • params[“data_re_prefix”] ( string ): prefixes of the files with real part of the data [Required!]

  • params[“data_im_prefix”] ( string ): prefixes of the files with imaginary part of the data [Required!]

  • params[“data_re_suffix”] ( string ): suffixes of the files with real part of the Hvib(t) [default: “_re”]

  • params[“data_im_suffix”] ( string ): suffixes of the files with imaginary part of the Hvib(t) [default: “_im”]

Returns

data:

a time series of data matrices, such that data[time] is a data at time step time

Return type

list of CMATRIX objects

Example

This example will read 10 pairs of files: “Hvib_0_re”, “Hvib_0_im”, “Hvib_1_re”, “Hvib_1_im”, … “Hvib_9_re”, “Hvib_9_im”. Each file should contain a 4 x 4 matrix of numbers. It will generate a list of 4 x 4 complex-valued matrices.

>>> hvib = get_data({"data_dim":4, "isnap":0, "fsnap":10, "data_re_prefix":"Hvib", "data_im_prefix":"Hvib"})

The following example will do the same as the example above, however the intially-read 4 x 4 matrices will be partially discarded. Out of 16 values only 4 (the upper left block of 4 numbers) will be stored in the resulting list of 2 x 2 complex-valued matrices.

>>> hvib = get_data({"data_dim":4, "isnap":0, "fsnap":10, "data_re_prefix":"Hvib", "data_im_prefix":"Hvib", "active_space":[0,1]})
libra_py.data_read.get_data_from_file(filename, xindx, yindx, xminval=None, xmaxval=None, yminval=None, ymaxval=None)[source]

Read in the numeric data stored in a file as columns into Python lists

Parameters
  • filename (string) – The name of the data file

  • xindx (int) – the index of the column read as X

  • yindx (int) – the index of the column read as Y

  • xminval (double) – the minimal X value allowed in the read data set, the points with X values below it will not be included [ default: None ]

  • xmaxval (double) – the maximal X value allowed in the read data set, the points with X values above it will not be included [ default: None ]

  • yminval (double) – the minimal Y value allowed in the read data set, the points with Y values below it will not be included [ default: None ]

  • ymaxval (double) – the maximal Y value allowed in the read data set, the points with Y values above it will not be included [ default: None ]

Returns

(X, Y), where:

  • X ( list of doubles ): x values read from the file, cropped according the conditions

  • Y ( list of doubles ): y values read from the file, cropped according the conditions

Return type

(list, list)

libra_py.data_read.get_data_from_file2(filename, cols)[source]

Read in the numeric data stored in a file as columns into Python lists

Parameters
  • filename (string) – The name of the data file

  • cols (list of ints) – the indices of the columns to read

Returns

data

Return type

(list of lists)

libra_py.data_read.get_data_sets(params)[source]

Reads several sets of data files

Parameters

params (dictionary) –

parameters controlling the function execution [Required!]

Required parameter keys:

  • params[“data_set_paths”] ( list of strings ):

    define the paths of the directories where the data files for different data sets (e.g. independent MD trajectories) are located.

Note

In addition, requires parameters described in get_data()

Returns

data:

the time series of Hvib matrices for several data sets, such that data[idata][time] is a CMATRIX for the data set indexed by idata at time time

Return type

list of lists of CMATRIX

Example

The full name of the vibronic Hamiltonian files read by this module should be:

params[“data_set_paths”][idata]+params[“data_re_prefix”]+integer(time step)+params[“data_re_suffix”] - for real part

params[“data_set_paths”][idata]+params[“data_im_prefix”]+integer(time step)+params[“data_im_suffix”] - for imaginary part

Say, the directory “/home/alexeyak/test/step3/res0” contains files: Hvib_0_re, Hvib_1_re, …. , Hvib_999_re Hvib_0_im, Hvib_1_im, …. , Hvib_999_im

Then set:

>>> params["data_set_paths"] = ["/home/alexeyak/test/step3/res0/"]
>>> params["data_re_prefix"] = "Hvib_"
>>> params["data_re_suffix"] = "_re"
>>> params["data_im_prefix"] = "Hvib_"
>>> params["data_im_suffix"] = "_im"
libra_py.data_read.get_matrix(nrows, ncols, filename_re, filename_im, act_sp)[source]

This file reads the real and imaginary components of a matrix of given original size, takes its sub-matrix (as defined by the act_sp function) and returns the resulting complex matrix

Parameters
  • nrows (int) – the number of rows in the original matrix (read from the files)

  • ncols (int) – the number of columns in the original matrix (read from the files)

  • filename_re (string) – the name of the file containing the real part of the matrix

  • filename_im (string) – the name of the file containing the imaginary part of the matrix

  • act_sp (list of N ints) – the indices of the columns and rows to be taken to construct the resulting matrices. The indexing starts from 0. These numbers shold not be larger than nrows or ncols

Returns

where N is the number of actively included rows/columns

Return type

CMATRIX(N, N)

Example

The following snippet will create a 4 x 4 matrix from the files “Ham_0_re” and “Ham_0_im” from the “res” directory. Each of the files is expected to be a matrix of 10 x 10 in size. The rezulting 4 x 4 matrix will contain entries on the intersection of columns and rows with indices 0, 1, 3, and 4.

>>> X = get_matrix(10, 10, "res/Ham_0_re", "res/Ham_0_im", [0,1,3,4])
libra_py.data_read.read_2D_grid(filename)[source]

This function reads the 2D map pyplot formatted data from a file.

Parameters

filename (sting) – name of the file to read

Returns

X grid, Y grid, and the Z values of the grid points

Return type

double list, double list, list of lists of doubles