Source code functions for the TwoD generation

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

Functions for generation:

class dataprocess.DataProcess(debug=False)

The data process class

filter(data, labels, fsize=10, visual=False)

filter A function to provide balanced data with each class in fsize number

Parameters
  • data (numpy array) – the trajectory data

  • labels (numpy array) – the label corresponding to trajectory data

  • fsize (int, optional) – number of trajectories for each class in final result, defaults to 10

Returns

balanced data and balanced labels corresponding to the data

Return type

numpy.array numpy.array

dataprocess.classifier(data, head_size=0, tail_size=10000, eps=0.5, visual_flag=False, debug=False)

classifier A classifier depend on DBSCAN to label different traj with labels wrt their position

param data

traj data to be labelled, shape as (n_traj, n_dim, n_step)

type data

numpy array

param head_size

head index of the data used for clustering, defaults to 0

type head_size

int, optional

param tail_size

end index of the data used for clustering, defaults to 10000

type tail_size

int, optional

param eps

parameter epsilon of DBSCAN, larger means the DBSCAN would consider a larger search for one class,

defaults to 0.5
type eps

float, optional

param visual_flag

boolean value to indicate plot the labelling result or not, defaults to False

type visual_flag

bool, optional

return

corresponding labels of input trajectory data, shape as (n_traj,)

rtype

list

dataprocess.concatenate(data)

concatenate A function concatenate the trajectory data

Parameters

data (numpy array) – traj data that to be concatenated

Returns

concatenated data with shape (dim, n_traj * n_step)

Return type

numpy array

dataprocess.pickOut(data, labels, cnum=2, debug=False)

pickOut A atomic function for cleaning the data, picking out the outliner trajs that labelled as minority

param data

input raw data of trajs, not cleaned, shape as (n_traj, n_dim, n_step)

type data

numpy array

param labels

label of the raw data to be cleaned, shape as (ntraj,)

type labels

list

param cnum

number of class to be saved as the final output of cleaing, the top cnum number of labels would be kept,

defaults to 2
type cnum

int, optional

return

clean data, clean labels corresponding to the data

rtype

numpy array

class generateTraj.generateTraj(dx, dy, type, help=False)

A class to define trajectory generator types, params and so on

batch_generator(batch_size=100, visual=False)

batch_generator Generator function for producing batch of trajs, call the in-class generate function

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

  • visual (bool, optional) – flag variable indicating should print the plot of trajs or not, defaults to False

Returns

A numpy array containing the generated traj data, shape as (batchSize, dimension, stepIndex)

Return type

numpy array

Functions to define the spirals:

class spiral.potential_spiral(branches=2)

spiral potential generation class, including 3 example expressions of spiral potential with derivatives

expl_2b_dx(x, y)

An Example of 2d, 2-branch spiral derivative(wrt x) function generated by symbolic expressions, used for visualisation

expl_2b_dy(x, y)

An Example of 2d, 2-branch spiral derivative(wrt y) function generated by symbolic expressions, used for visualisation

expl_2b_potential(x, y)

An Example of 2d, 2-branch spiral potential function generated by symbolic expressions, used for visualisation

generate_function()

Generating the expression of potential function and corresponding derivatives

visualize_3d(ngrid=200)

Plotting the potential surface

And finally some of the Utils used in this module: