datasets_phenom (models_class=<andi_datasets.models_phenom.models_phenom
object at 0x784bf39e3460>)
This class generates, saves and loads datasets of trajectories simulated from various phenomenological diffusion models (available at andi_datasets.models_phenom).
Given a list of dictionaries, generates trajectories of the demanded properties. The only compulsory input for every dictionary is model, i.e. the model from which trajectories must be generated. The rest of inputs are optional. You can see the input parameters of the different models in andi_datasets.models_phenom, This function checks and handles the input dataset and the manages both the creation, loading and saving of trajectories.
Type
Default
Details
dics
list | dict | bool
None
- if list or dictionary: the function generates trajectories with the properties stated in each dictionary. - if bool: the function generates trajectories with default parameters set for the ANDI 2 challenge (phenom) for every available diffusion model.
T
None | int
None
- if int: overrides the values of trajectory length in the dictionaries. - if None: uses the trajectory length values in the dictionaries. Caution: the minim T of all dictionaries will be considered!
N_model
None | int
None
- if int: overrides the values of number of trajectories in the dictionaries. - if None: uses the number of trajectories in the dictionaries
path
str
Path from where to save or load the dataset.
save
bool
False
If True, saves the generated dataset (see self._save_trajectories).
load
bool
False
If True, loads a dataset from path (see self._load_trajectories).
Returns
tuple
- trajs (array TxNx2): particles’ position. N considers here the sum of all trajectories generated from the input dictionaries. Note: if the dimensions of all trajectories are not equal, then trajs is a list. - labels (array TxNx2): particles’ labels (see ._multi_state for details on labels)
In the example below we create two dictionaries and generate a dataset with it. See the corresponding tutorial for more details.
L =50dict_model3 = {'model': 'dimerization', 'L': L,'Pu': 0.1, 'Pb': 1}dict_model5 = {'model': 'confinement','L': L, 'trans': 0.2}dict_all = [dict_model3, dict_model5]trajs, labels = datasets_phenom().create_dataset(N_model =10, # number of trajectories per model T =200, dics = dict_all )plot_trajs(trajs, L , N =10, num_to_plot =3, labels = labels, plot_labels =True )
False
False
Creating, saving and loading trajectories
These auxiliary functions used in create_trajectories that allow for manipulate trajectories in various forms.
Given a list of dictionaries, generates trajectories of the demanded properties. First checks in the .csv of each demanded model if a dataset of similar properties exists. If it does, it loads it from the corresponding file.
L =20dict_1 = {'model': 'single_state', 'L': L}dict_2 = {'model': 'immobile_traps', 'L': L}dict_all = [dict_1, dict_2]DP = datasets_phenom()trajs, labels = DP.create_dataset(N_model =13, # number of trajectories per model T =20, dics = dict_all )plot_trajs(trajs, L , N =10, num_to_plot =3, labels = labels, plot_labels =True )
Given a set of trajectories and labels, saves two things:
- In the .csv corresponding to the demanded model, all the input parameters of the generated dataset. This allows to keed that of what was created before. - In a .npy file, the trajectories and labels generated.
trajs, labels = DP.create_dataset(N_model =10, # number of trajectories per model T =20, dics = dict_all, save =True, path ='datasets_folder/' )plot_trajs(trajs, L , N =3)
Given the path for a dataset, loads the trajectories and labels
# You must run to cells above for this one to work. Check that this are the # exact same trajectories.trajs, labels = DP.create_dataset(N_model =10, # number of trajectories per model T =20, dics = dict_all[0], load =True, path ='datasets_folder/' )plot_trajs(trajs, L , N =3 )
/home/gorka/miniconda3/envs/andi/lib/python3.10/site-packages/fastcore/docscrape.py:225: UserWarning: potentially wrong underline length...
Returns
----------- in
Checks the information of the input dictionaries so that they fulfil the constraints of the program , completes missing information
with default values and then decides about loading/saving depending on parameters....
else: warn(msg)
Checks the information of the input dictionaries so that they fulfil the constraints of the program , completes missing information with default values and then decides about loading/saving depending on parameters.
Type
Details
dic
dict
Dictionary with the information of the trajectories we want to generate
Returns
tuple
df: dataframe collecting the information of the dataset to load. dataset_idx: location in the previous dataframe of the particular dataset we want to generate.