# Getting started with Iota Python Library and Iota IPython Terminal

This section provides an introduction on how to start using the Iota Python Library from the Iota IPython Terminal. The Iota iPython Terminal is installed during the installation process of Iota and is available at the Start menu of your OS inside the "Iota Suite" folder (see Figure 1).

![](https://4169062871-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ll27EGqsMiXI1nmomPu%2F-Ll27FeL8mLBf_skJM_2%2F-Ll27L76dXfzJbgUujJC%2FIota_iPython_Terminal.png?generation=1564494358870016\&alt=media) *Figure 1 - Start menu entry on Windows where Iota IPython Terminal is highlighted*

The Iota iPython Termnial is a [iPython](https://ipython.org) command shell that allows the users to perform computational operations in an interactive way and provides some useful features including:

* Comprehensive object introspection
* Shell syntax
* Tab completion
* Commands history

For More detailed information about iPython command shell, users can visit the [official IPython documenation](http://ipython.readthedocs.io/en/stable/) .

Executing the Iota IPython Terminal open an IPython terminal like the one shown in Figure 2. The IPython terminal is automatically started on the Iota Suite installation directory (e.g. "C:\Program Files\iota\_suite").

![](https://4169062871-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ll27EGqsMiXI1nmomPu%2F-Ll27FeL8mLBf_skJM_2%2F-Ll27L79XzweyvMFIUSY%2FIota_IPython_terminal_Open.PNG?generation=1564494358761989\&alt=media) *Figure 2 - Iota IPython terminal*

Once the Iota IPython terminal is open, users need to import the Iota Python Library. To do so, users need to execute the following command on the terminal:

```python
 import iota
```

This will load the Iota Python Library so that the users can have to the whole content on the library via the object `iota` (see the [Iota Python Reference Library](https://particle-analytics-1.gitbook.io/iota-python-api/iota) for more detailed information about the content of the library).

## [Starting a Session](#starting-a-session) <a href="#starting-a-session" id="starting-a-session"></a>

Users can start a session using the [`iota.session`](https://particle-analytics-1.gitbook.io/iota-python-api/iota/session) function that give access to the database and allows you load existing projects, create new ones and other actions as explained in [`iota.session` documentation](https://particle-analytics-1.gitbook.io/iota-python-api/iota/session):

```python
my_session = iota.session('my_Iota_username','my_home_folder/ParicleAnalytics/config.ini')
```

where `my_Iota_username` needs to be replaced by to your registered username in Iota and `my_home_folder` by your home directory on your operative sysem (e.g. `C:/Users/Stephen`).

Once the session has been started, you can ask for the list of projects in your database:

```python
my_session.projects
```

that will return a list containing the project including their manes and a brief summary of the scenario and assets contain in the project:

```python
[<Project: Backhoe optimization (2 scenarios, 2 files, 8, graphs, 3 meshes, 4 datasets),
 <Project: Rotary Drum mixer (2 scenarios, 0 files, 20, graphs, 3 meshes, 4 datasets),
 <Project: Soil tillage (1 scenarios, 0 files, 4, graphs, 0 meshes, 2 datasets),
```

## [Creating a New Project](#creating-a-new-project) <a href="#creating-a-new-project" id="creating-a-new-project"></a>

Once an [`iota.session`](https://particle-analytics-1.gitbook.io/iota-python-api/iota/session) can has been started, users can create new projects in their database using the method [`create_project`](https://particle-analytics-1.gitbook.io/iota-python-api/iota/session#create_project):

```python
my_project = my_session.create_project(name='My New Project', description='This is my new project')
```

## [Loading a Project](#loading-a-project) <a href="#loading-a-project" id="loading-a-project"></a>

Users can load existing projects by their names using the method [`get_project`](https://particle-analytics-1.gitbook.io/iota-python-api/iota/session#get_project) of the [`iota.session`](https://particle-analytics-1.gitbook.io/iota-python-api/iota/session) object:

```python
my_project = my_session.get_project('Backhoe optimization')
```

In this example, the [`iota.session.project`](https://particle-analytics-1.gitbook.io/iota-python-api/iota/project) object is stored in the variable `my_project`.

## [Creating-a-scenario](#creating-a-new-scenario) <a href="#creating-a-new-scenario" id="creating-a-new-scenario"></a>

Users can create new scenario using the method [`add_scenario`](https://particle-analytics-1.gitbook.io/iota-python-api/iota/project#add_scenario) of the [`iota.session`](https://particle-analytics-1.gitbook.io/iota-python-api/iota/session) object:

```python
my_scenario = my_project.add_scenario(name='Initial design', description='This is my new scenario')
```

## [Loading a Scenario](#loading-a-scenario) <a href="#loading-a-scenario" id="loading-a-scenario"></a>

Users can load a scenario using the method [`get_scenario`](https://particle-analytics-1.gitbook.io/iota-python-api/iota/project#get_scenario) of the [`iota.session`](https://particle-analytics-1.gitbook.io/iota-python-api/iota/session) object:

```python
my_scenario = my_project.get_scenario('Initial design')
```

## [Importing a Dataset](#importing-a-dataset) <a href="#importing-a-dataset" id="importing-a-dataset"></a>

Users can import a dataset into the scenario using the method [`add_dataset`](https://particle-analytics-1.gitbook.io/iota-python-api/iota/scenario#add_dataset) for datasets in **PADEM** and **PACG** format.

```python
my_scenario.add_dataset(name = 'backhoe_coarse-graining', data_format = 'PACG',file = '/path/to/my/pacg/dataset/backhoe_cg.meta')
```

In case of **EDEM 2017+** format, users can import the EDEM simulation by using the method [`import_dataset`](https://particle-analytics-1.gitbook.io/iota-python-api/iota/scenario#import_dataset):

```python
my_scenario.import_dataset(file = '/path/to/my/edem/dataset/simulation.dem', name = 'Backhoe Initial desing', data_format = 'EDEM 2017',include_graphs = True)
```

Note that `include_grahs=True` sets the generation and importing into the scenario of the reaction force and torque graphs of each geometry contained in the EDEM simulation to be imported.

## [Running Coarse-graining](#running-coarse-graining) <a href="#running-coarse-graining" id="running-coarse-graining"></a>

Users can run the coarse-graining analysis of a scenario using the method [`run_coarse_graining`](https://particle-analytics-1.gitbook.io/iota-python-api/iota/scenario#run_coarse_graining) of the [`scenario`](https://particle-analytics-1.gitbook.io/iota-python-api/iota/scenario) object:

```python
my_scenario.run_coarse_grainig()
```

In this example, coarse-graining would be run using the existing coarse-graining settings of scenario that the user may have set via the Graphical User Interface. For more information on how to run coarse-graining with custom settings using the Iota Python Library, please see [`get_coarse_graining_settings`](https://particle-analytics-1.gitbook.io/iota-python-api/iota/scenario#get_coarse_graining_settings) and [`run_coarse_graining_settings`](https://particle-analytics-1.gitbook.io/iota-python-api/iota/scenario#run_coarse_graining_settings) in the section [**Scenario**](https://particle-analytics-1.gitbook.io/iota-python-api/iota/scenario) of the Iota Python Reference Library.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://particle-analytics-1.gitbook.io/iota-python-api/using-ipl-from-ipython.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
