TwoD: application programming interface (API)

This module includes the programming interface to ease the use of the 2D potential generator, it is not the source code.

TwoD_pot_data.data_process_full(obj, raw_data, fsize, visual=False)

data_process_full Process the generated raw traj data until balanced level

Parameters
  • obj (DataProcess object) – DataProcess obeject generated by data_processor function

  • raw_data (numpy array) – unprocessed traj data, in shape of (n_traj, n_dim, n_step)

  • fsize (int) – number of trajs in each class final produced, should be changed wrt raw_data length

Returns

balance_data, balance_labels, processed data and corresponding labels

Return type

numpy array, numpy array

TwoD_pot_data.data_processor(type)

data_processor A function generate object of DataProcess class with respect to preset types

Parameters

type (str) – type of raw trajectory data input, choose from ‘s2’, ‘s3’, ‘z’

Returns

DataProcess object with modified params

Return type

DataProcess object

TwoD_pot_data.data_projection(obj, data)

data_projection a function produce projected data

Parameters
  • obj (Class Projector) – projector generated from Projector class by function data_projector

  • data (numpy array) – trajectory data, expected the balanced data from data_proecess

Returns

projs array, in shape as (n_trajs, n_features)

Return type

numpy array

TwoD_pot_data.data_projector(type, n_features=100)
data_projector A function to generate the projector object with respect to different sampling method

Including the following sample method: ‘rand’ and ‘grid’ ‘rand’: do the sampling randomly, which provide random coeffs for projector ‘grid’: do the sampling in grid wise, which would yield same difference between coeffs

Parameters
  • type (str) – type of potential that the data generates from, indicating how to tone the projector’s param automatically

  • n_features (int, optional) – number of features to be generated, defaults to 100

Returns

object of Projector Class

Return type

Class Projector

TwoD_pot_data.generate_traj(type, number=100, visual=False, help=False)

generate_traj A meta function that use for generating traj data, simply wrapped I/O of gemerateTraj class

Parameters
  • type (str) – pattern code of potential, indicating type of potential to generate traj on, including s2, s3 and z

  • number (int, optional) – number of trajs to be generated at once, defaults to 100

  • visual (bool, optional) – boolean value indicating plot the result of generated trajs or not, defaults to False

  • help (bool, optional) – boolean value indicating show the help information from generateTraj calss or not, defaults to False

Raises

ValueError – indicating the user input not match pre-set potential parrtern code, should be z, s2 or s3

Returns

An array containing all the traj data in shape of (traj_index, dim_index(x or y), step_index)

Return type

numpy.array

TwoD_pot_data.get_pot_func(obj, return_flag=False)

get_pot_func a function to print the generated expressions for defining potential and derivatives

Parameters
  • obj (object) – obeject of potential class, yield by generate_potential_func above, modified by user if they want

  • return_flag (bool, optional) – A boolean value indicating to save the expressions or not, defaults to False

TwoD_pot_data.pot_generator(name)

pot_generator A getter function to get the object from potential generation class

Parameters

name (str) – name of potential, spiral or zshape

Returns

an object that contains metadata for generating potential expressions

Return type

self defined object

TwoD_pot_data.show_pot_attributes(obj)

show_pot_attributes show the attributes of generated object, user could change those attributes before generation

Parameters

obj (object) – obeject of potential class, yield by generate_potential_func above

Returns

attributes dictionary of self defined potential class, user could use attributes to assign value, however this is not protected by type checking, so user should change the attributes very carefully and, only when they are sure that the new input should work for potential generation.

Return type

dict