Project
iota.session.Project()
Description Iota project object.
Methods
Variables
name
(str) project namedescription
(str) project descriptionid
(int) project Id
Methods
Return a scenario belonging to a specified project, by name
Arguments
name
: (str) scenario name
Example
if project.exists_scenario('my_scenario'):
print('scenario exist')
Return a scenario belonging to a specified project, by name
Arguments
name
: (str) scenario name
Example
scenario = project.get_scenario(name='my_scenario')
Return the list of scenarios in the project
Example
for scenario in project.get_scenarios():
print('scenario: {}'.format(scenario.name))
Create and return a scenario, described by name and optional description and tags
Arguments
name
: (str) scenario namedescription
: (str) scenario description (default: None)
Example
new_scenario = project.add_scenario(
name = 'scenario 01',
description = 'simulation mixing analysis with speeed = 30 RPM'
)
Return a dataset record specified by name
Arguments
name
: (str) scenario namedata_format
: (str) data format of the dataset to be loaded. The project can have more than one dataset with the same name if data_format is different. (default: None)
Example
dataset = project.get_dataset(
name = 'mixing_rpm_30',
data_format = 'PADEM'
)
Return the list of dataset records in the project
Example
print('List of datasets in the project')
for dataset in project.get_datasets():
print('dataset: {} (format: {})'.format(dataset.name,dataset.data_format))
Add a Iota Dataset file to the project data_format must be one of PADEM or PACG
Arguments
name
: (str) dataset namedata_format
: (str) format of the datasetfile
: (str) dataset filepathdescription
: (str) dataset description (default: None)scenario
: (str) add dataset to a specific scenario (default: None)
Example
project.add_dataset(
name = 'mixing_rpm_32',
data_format = 'PADEM',
file = '/path/to/my/dataset/mixing_rpm_32.meta',
description = 'mixing analysis with drum speed of 32 RPM'
)
Import external Dataset to the project data_format must be one of the accepted formats: [EDEM 2017]
Arguments
file
: (str) dataset filepathname
: (str) dataset name. If not defined, used the basename of the filepath (Default: None)data_format
: (str) format of the datasetinclude_graphs
: (bool) import any graph available in the dataset to the projectdescription
: (str) dataset description (Default: None)scenario
: (str) add dataset to a specific scenario (default: None)
Example
project.import_dataset(
file = '/path/to/my/edem/dataset/simulation.dem',
name = 'mixing_rpm_34',
data_format = 'EDEM 2017',
include_graphs = True,
description = 'mixing analysis with drum speed of 34 RPM'
)
Return True if graph exists, specified by name (and tags)
Arguments
name
: (str) graph nametags
: (dict) tags dictionary
Example
exists_graph = project.exists_graph(
name = 'Reaction Force',
tags = {
'dataset': 'mixing_rpm_34'
}
)
if exists_graph:
print('graph exist!')
Return a graph, specified by name (and tags)
Arguments
name
: (str) graph nametags
: (dict) tags dictionary
Example
graph = project.get_graph(
name = 'Reaction Force',
tags = {
'dataset': 'mixing_rpm_34'
}
)
Return the list of graphs in the project
Example
print('List of graphs:')
for graph in project.get_graphs():
print('Graph: {}'.format(graph.name))
Add a new graph to the project. The graph can be defined in a csv file or by defining all the components (data, titles, etc)
Arguments
name
: (str) graph nametitle
: (str) graph titlefilepath
: (str) optional file path for new graph file (Default: None)xdata
: (iota.ArrayFloat) array of data representing the values of axis Xydata
: (list[iota.ArrayFloat]) list of arrays representing the data serieslegend
: (list[str]) list of names for the data seriesxtitle
: (str) title of the axis Xytitle
: (str) title of the axis Ycsvfile
: (str) csv file containing the graph data. If this is defined, none of the previous variables are considereddescription
: (str) graph descriptiontags
: (dict) tags dictionaryoverwrite
: (bool) overwrite graph file if already exists
Example
x_values = iota.ArrayFloat([0,1,2,3,4,5,6])
average_force = iota.ArrayFloat(len(x_values),10.0)
graph = project.add_graph(
name = 'Average Force',
title = 'Average Force',
xtitle = 'Step',
xdata = x_values,
ytitle = 'Force',
legend = ['Force'],
ydata = [average_force],
tags = {
'dataset': 'mixing_rpm_34'
},
overwrite = True
)
graph2 = project.add_graph(
name = 'Average Torque',
csvfile = '/path/to/my/graph/torque.csv',
tags = {
'dataset': 'mixing_rpm_34'
}
)
Return a mesh specified by a name
Arguments
name
: (str) mesh name
Example
mesh_record = project.get_mesh(
name = 'mixing_drum_v02'
)
Return th elist of meshes in the project
Example
print('List of meshes:')
for mesh in project.get_meshes():
print(' mesh: {}'.format(mesh.name))
Add a mesh by filepath to the project
Arguments
file
: (str) mesh filepathdescription
: (str) mesh description
Example
project.add_mesh(
file = '/path/to/my/mesh/mixing_drum_v2.stl',
description = 'Mixing drum with inclinantion of 30 degrees'
)
Return a file, specified by name
Arguments
name
: (str) file name
Example
file = project.get_file(
name = 'list of values test 2'
)
Return the list of files in the project
Example
print('List of files:')
for file in project.get_files():
print(' file: {}'.format(file.name))
Create and return a file, describe by name, filepath and optional description
Arguments
name
: (str) scenario namefilepath
: (str) file pathdescription
: (str) file description (Default: None)
Example
project.add_file(
name = 'my text file',
filepath= '/path/to/my/file/text.txt',
description='this file contains the summary of parameters used for the simulations'
)
Return a script spcified by a name
Arguments
name
: (str) script name
Example
script_file = project.get_script(
name = 'calculate mixing index'
)
Return the list of scripts in the project
Example
print('List of scripts:')
for script in project.get_scripts():
print(' script: {}'.format(script.name))
Add a script (python file) to the project
Arguments
name
: (str) script namefilepath
: (str) script file pathdescription
: (str) script description (Default: None)
Example
project.add_script(
name = 'calculate mixing index',
filepath = '/path/to/my/scripts/calculate_mixing_index.py',
description = 'This script calculate the Lacey mixing index using binning'
)
Add a video file to the project
Arguments
file
: (str) video file pathname
: (str) video namedescription
: (str) video description (Default: None)tags
: (dict) tags dictionary (Default: None)thumbnail
: (str) image file to be used as a thumbnail (Default: None)
Example
project.add_video(
file = '/path/to/my/videos/mixer_rpm_32_velocity_X.mp4',
name = 'Mixer at 32 RPM',
description = 'This video shows the velocity profile in X direction for the case with drum speed at 32 RPM',
tags = {
'dataset': 'mixer_rpm_32',
'result': 'Velocity (X)'
}
)
Add image file to the project
Arguments
file
: (str) screenshot file pathname
: (str) screenshot namedescription
: (str) screenshot description (Default: None)tags
: (dict) tags dictionary (Default: None)
Example
project.add_video(
file = '/path/to/my/images/mixer_rpm_32_velocity-Y_time3.42.png',
name = 'Mixer at 32 RPM',
description = 'Velocity profile in Y direction for the case with drum speed at 32 RPM. Time = 3.42s',
tags = {
'dataset': 'mixer_rpm_32',
'result': 'Velocity (Y)',
'timestep': '3.42'
}
)
Delete project from the database (and disk if applicable)
Example
name = project.name
project.delete()
if not session.exist_project(name):
print('project removed')
Last updated
Was this helpful?